game

Function game 

Source
pub fn game<S>(
    name: impl Into<String>,
    update: impl Fn(&mut S),
) -> Game<S, impl Fn(&mut S)>
Expand description

Entrypoint function for baba games.

This function creates a Game object, which you can set many options in. To start your game, simply call .run() or .run_with(MyGame::new) on it. Check out Game for the options you can set!

fn main() -> baba::Result {
    baba::game("My game", MyGame::update)
        .window_title("Hello!")
        .run()
}

#[derive(Default)]
struct MyGame {
    // ...
}

If you don’t want to implement Default, you can instead use run_with:

fn main() -> baba::Result {
    baba::game("My game", MyGame::update)
        .run_with(MyGame::new)
}

impl MyGame {
    fn new() -> Self {
        Self {
            // ...
        }
    }
}
Examples found in repository?
examples/soko.rs (line 4)
3fn main() -> baba::Result {
4    baba::game("SOKOBAN", Soko::update)
5        .viewport(Viewport::new(32 * 7, 32 * 7))
6        .run_with(Soko::new)
7}