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>
impl<'a> Engine<'a>
Sourcepub fn new(
app: &'a mut dyn Application,
title: &'a str,
width: u32,
height: u32,
) -> Result<Engine<'a>, String>
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?
More examples
Sourcepub fn start(&mut self, present_vsync: bool) -> Result<(), Box<dyn Error>>
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?
More examples
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more