Struct lux::game::GameRunner
[−]
[src]
pub struct GameRunner<G: Game> {
pub window: Window,
pub game: G,
// some fields omitted
}A struct that wraps a Game and a Window and implementes a game loop.
Fields
window | The window being used to run the game. |
game | The wrapped game. |
Methods
impl<G: Game> GameRunner<G>
fn new(game: G) -> LuxResult<GameRunner<G>>
Constructs a new GameRunner wrapping a game.
Attempts to build a window as well.
fn run_until_end(&mut self) -> LuxResult<()>
Runs the game until the game is terminated.
The game loop is fairly complicated but is explained as the final example in this blog post: http://gameprogrammingpatterns.com/game-loop.html
Main features
- All updates happen in discrete time steps.
- Multiple updates can happen sequentially in order to handle lag and get back on step.
- Multiple renders can happen sequentially if the computer is too fast. Renders will keep occuring until enough time has built up to trigger another update.
- The amount of "lag" time is passed in to the render function so that the user can accomodate for lag.