pub trait Game {
// Required methods
fn init(lili: &Lili) -> Self;
fn update(&mut self, lili: &Lili);
fn draw(&mut self, lili: &Lili);
}Expand description
Implement this trait for your game.
It provides methods to init, update and draw your game.
§Example
use musi_lili::{Game, Lili};
struct MyGame;
impl Game for MyGame {
fn init(_lili: &Lili) -> Self {
Self
}
fn update(&mut self, _lili: &Lili) {
// the code to update your game
}
fn draw(&mut self, lili: &Lili) {
// draw your game
lili.clear(0);
lili.txt("toki", 5, 5, 3);
}
}
fn main() {
musi_lili::run::<MyGame>(musi_lili::load!("my-game"));
}Required Methods§
Sourcefn init(lili: &Lili) -> Self
fn init(lili: &Lili) -> Self
Use this to initialize your game.
This method is only called one time before the game start or after a rest of the game.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".