Expand description
Representation of the game.
Fields
title: StringThe title that the window displays.
width: u32The width of the opened window
height: u32The height of the opened window
Implementations
sourceimpl Game
impl Game
sourcepub fn new(title: &str, width: u32, height: u32) -> Self
pub fn new(title: &str, width: u32, height: u32) -> Self
Creates a new Game struct.
Make sure to use Self::run() to actually begin the game logic.
Game::new("cool game", 1000, 1000);sourcepub fn run<F: FnMut(&mut Context, &mut Events)>(&self, func: F) -> Result<()>
pub fn run<F: FnMut(&mut Context, &mut Events)>(&self, func: F) -> Result<()>
Runs the game. Note: this method blocks, as it uses an infinite loop.
game.run(|ctx, events| {
// Game logic goes here
});sourcepub fn terminate(&self)
pub fn terminate(&self)
Stops the game loop. This method should be called inside the closure that you passed to Self::run().
// ... in the game loop:
game.terminate();Auto Trait Implementations
impl !RefUnwindSafe for Game
impl Send for Game
impl !Sync for Game
impl Unpin for Game
impl UnwindSafe for Game
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more