Struct ggez::game::Game [] [src]

pub struct Game<'a, S: GameState> { /* fields omitted */ }

The Game struct takes an object you define that implements the GameState trait and does the actual work of running a gameloop, passing events to your handlers, and all that stuff.


impl<'a, S: GameState + 'static> Game<'a, S>

Creates a new Game with the given default config (which will be used if there is no config file). It will initialize a hardware context and call the load() method of the given GameState type to create a new GameState.

The id field is a unique identifier for your game that will be used to create a save directory to write files to.

Replaces the gamestate with the given one without having to re-initialize the hardware context.

Re-creates a fresh GameState using the existing one's ::load() method.

Calls the given function to create a new gamestate, and replaces the current one with it.

Runs the game's mainloop. Continues until a Quit event is created, for instance via Context::quit()

Trait Implementations

impl<'a, S: Debug + GameState> Debug for Game<'a, S>

Formats the value using the given formatter.