Trait let_engine::Game

source ·
pub trait Game {
    // Required method
    fn exit(&self) -> bool;

    // Provided methods
    fn start(&mut self) { ... }
    fn update(&mut self) { ... }
    fn frame_update(&mut self) { ... }
    fn tick(&mut self) { ... }
    fn event(&mut self, event: Event) { ... }
}
Expand description

Represents the game application with essential methods for a game’s lifetime.

§Usage

use let_engine::prelude::*;

struct Game {
    exit: bool,
}

impl let_engine::Game for Game {
    fn exit(&self) -> bool {
       // exits the program in case self.exit is true
       self.exit
    }
    fn update(&mut self) {
        // runs every frame or every engine loop update.
        //...
    }
}

Required Methods§

source

fn exit(&self) -> bool

If true exits the program, stopping the loop and closing the window.

Provided Methods§

source

fn start(&mut self)

Runs right before the first frame is drawn and the window gets displayed, initializing the instance.

source

fn update(&mut self)

Runs before the frame is drawn.

source

fn frame_update(&mut self)

Runs after the frame is drawn.

source

fn tick(&mut self)

Runs based on the configured tick settings of the engine.

source

fn event(&mut self, event: Event)

Handles engine and window events.

Implementors§