Trait pixel_engine::Game

source ·
pub trait Game: Sized {
    fn create(engine: &mut Engine) -> Result<Self, Box<dyn Error>>;
    fn update(&mut self, engine: &mut Engine) -> Result<bool, Box<dyn Error>>;

    fn receive_input(&mut self, _engine: &mut Engine, _input: String) { ... }
}
Expand description

This is the core of the Game ran by the Engine

Required Methods§

Create the Game instance

Errors

This is allowed to return an error. It will be printed in the console with either debug formatting in debug builds (debug_assertions enabled) and display in release builds

If you use a closure as the game type this will always return an error

This is the core loop of the engine. It will be called every time the games needs a redraw.

Returns

The return value of the function will determine if the game needs to be shut down or not. Returning Ok(true) will continue to the next frame Ok(false) will gracefully shut down the program Err(_) will print out the error onto stderr and stop the program

Provided Methods§

This function will be called when the input mode finishes.

Implementors§