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

  1. All updates happen in discrete time steps.
  2. Multiple updates can happen sequentially in order to handle lag and get back on step.
  3. 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.
  4. The amount of "lag" time is passed in to the render function so that the user can accomodate for lag.