pub trait Engine {
    fn render(&mut self, api: &mut dyn DoryenApi);

    fn init(&mut self, _api: &mut dyn DoryenApi) { ... }
    fn update(&mut self, _api: &mut dyn DoryenApi) -> Option<UpdateEvent> { ... }
    fn resize(&mut self, _api: &mut dyn DoryenApi) { ... }
}
Expand description

This is the trait you must implement to update and render your game. See App::set_engine

Required Methods

This is called before drawing the console on the screen. The framerate depends on the screen frequency, the graphic cards and on whether you activated vsync or not. The framerate is not reliable so don’t update time related stuff in this function. The screen will display the content of the root console provided by api.con()

Provided Methods

Called before the first game loop for one time initialization

This is called 60 times per second and is independant of the framerate. Put your world update logic in there. You can return Some(UpdateEvent::Exit) to stop the program

This is called when the size of the game window has changed. You can override this method if your game display or logic depends on the window size. You get the new window size with api.con().get_screen_size(). See the resize example

Implementors