Struct Engine

Source
pub struct Engine<'a> {
    pub show_fps: bool,
    /* private fields */
}
Expand description

The main game engine, which manages the display and input.

Fields§

§show_fps: bool

Whether the FPS should be calculated and displayed in the titlebar of the window.

Implementations§

Source§

impl<'a> Engine<'a>

Source

pub fn new( app: &'a mut dyn Application, title: &'a str, width: u32, height: u32, ) -> Result<Engine<'a>, String>

Create a new engine.

§Parameters
  • app: Defines the application’s logic.
  • title: Title of the window.
  • width: Width (in pixels) of the window.
  • height: Height (in pixels) of the window.
§Example
use simple_game_engine::Engine;
let mut app = App {}; // Some `Application` implementation
let engine = Engine::new(&mut app, "Window Title", 640, 480)?;
Examples found in repository?
examples/colour_cycle.rs (line 58)
56fn main() -> Result<(), Box<dyn Error>> {
57    let mut app = App::new();
58    let mut engine = sge::Engine::new(&mut app, "Test App", SCREEN_WIDTH, SCREEN_HEIGHT)?;
59    engine.start(false)
60}
More examples
Hide additional examples
examples/moving_circle.rs (line 57)
55fn main() -> Result<(), Box<dyn Error>> {
56    let mut app = App::new();
57    let mut engine = sge::Engine::new(&mut app, "Test App", SCREEN_WIDTH, SCREEN_HEIGHT)?;
58    engine.start(false)
59}
examples/moving_rect.rs (line 62)
60fn main() -> Result<(), Box<dyn Error>> {
61    let mut app = App::new();
62    let mut engine = sge::Engine::new(&mut app, "Test App", SCREEN_WIDTH, SCREEN_HEIGHT)?;
63    engine.start(false)
64}
Source

pub fn start(&mut self, present_vsync: bool) -> Result<(), Box<dyn Error>>

Create and show the window and start the main event loop.

§Parameters
  • present_vsync: Whether to limit the frame rate of the application to the frame rate of the display.
§Example
use simple_game_engine::Engine;
let mut app = App {}; // Some `Application` implementation
let mut engine = Engine::new(&mut app, "Window Title", 640, 480)?;
engine.start(true)?; // Starts with vsync enabled
Examples found in repository?
examples/colour_cycle.rs (line 59)
56fn main() -> Result<(), Box<dyn Error>> {
57    let mut app = App::new();
58    let mut engine = sge::Engine::new(&mut app, "Test App", SCREEN_WIDTH, SCREEN_HEIGHT)?;
59    engine.start(false)
60}
More examples
Hide additional examples
examples/moving_circle.rs (line 58)
55fn main() -> Result<(), Box<dyn Error>> {
56    let mut app = App::new();
57    let mut engine = sge::Engine::new(&mut app, "Test App", SCREEN_WIDTH, SCREEN_HEIGHT)?;
58    engine.start(false)
59}
examples/moving_rect.rs (line 63)
60fn main() -> Result<(), Box<dyn Error>> {
61    let mut app = App::new();
62    let mut engine = sge::Engine::new(&mut app, "Test App", SCREEN_WIDTH, SCREEN_HEIGHT)?;
63    engine.start(false)
64}

Auto Trait Implementations§

§

impl<'a> Freeze for Engine<'a>

§

impl<'a> !RefUnwindSafe for Engine<'a>

§

impl<'a> !Send for Engine<'a>

§

impl<'a> !Sync for Engine<'a>

§

impl<'a> Unpin for Engine<'a>

§

impl<'a> !UnwindSafe for Engine<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.