Module game

Source
Expand description

Game orchestration: integrates model and renderer, encapsulating the main loop. Game encapsulates Model and Render classes and implements the main loop. Be aware that all the Game, Model and Render instances have the same lifetime.

§Example

fn main() -> Result<(), Box> { init_log(log::LevelFilter::Info, “log/snake.log”); info!(“Snake(rust_pixel) start…”); let ad = Audio::new(); ad.play_file(“assets/snake/back.mp3”, true); let m = SnakeModel::new(); let r = SnakeRender::new(); let mut g = Game::new(m, r); g.init(); g.run()?; g.render.term.reset(&mut g.context); Ok(()) }

Structs§

Game
Game encapsulates a Model,a Render and a Context structure

Traits§

Model
The Model interface, main entrance for data and core logic
Render
The Render interface, takes context and model as input params. It renders every single frame