pub struct Game {
pub title: String,
pub width: u32,
pub height: u32,
/* private fields */
}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§
Source§impl 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)>(&self, func: F) -> Result<()>
pub fn run<F: FnMut(&mut Context)>(&self, func: F) -> Result<()>
Runs the game. Note: this method blocks, as it uses an infinite loop.
game.run(|ctx| {
// 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 !Freeze for Game
impl !RefUnwindSafe for Game
impl Send for Game
impl !Sync for Game
impl Unpin for Game
impl UnsafeUnpin for Game
impl UnwindSafe for Game
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