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
sourcefn render(&mut self, api: &mut dyn DoryenApi)
fn render(&mut self, api: &mut dyn DoryenApi)
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
sourcefn init(&mut self, _api: &mut dyn DoryenApi)
fn init(&mut self, _api: &mut dyn DoryenApi)
Called before the first game loop for one time initialization
sourcefn update(&mut self, _api: &mut dyn DoryenApi) -> Option<UpdateEvent>
fn update(&mut self, _api: &mut dyn DoryenApi) -> Option<UpdateEvent>
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