Skip to main content

Game

Trait Game 

Source
pub trait Game: Sized + 'static {
    // Required methods
    fn init(ctx: &mut Context) -> Result<Self, Error>;
    fn update(&mut self, ctx: &mut Context, dt: f32);
    fn render(&mut self, ctx: &mut Context, frame: &mut Frame);

    // Provided methods
    fn event(&mut self, _ctx: &mut Context, _event: &GameEvent) { ... }
    fn raw_window_event(
        &mut self,
        _ctx: &mut Context,
        _event: &WindowEvent,
    ) -> bool { ... }
    fn shutdown(&mut self, _ctx: &mut Context) { ... }
}

Required Methods§

Source

fn init(ctx: &mut Context) -> Result<Self, Error>

Source

fn update(&mut self, ctx: &mut Context, dt: f32)

Source

fn render(&mut self, ctx: &mut Context, frame: &mut Frame)

Provided Methods§

Source

fn event(&mut self, _ctx: &mut Context, _event: &GameEvent)

Source

fn raw_window_event(&mut self, _ctx: &mut Context, _event: &WindowEvent) -> bool

Raw winit window-event hook. Return true to mark the event consumed so it is not forwarded to the toolkit’s game_toolkit_input::Input state. Use this for egui or other overlays that need first crack at events.

Source

fn shutdown(&mut self, _ctx: &mut Context)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§