[][src]Trait tetra::State

pub trait State<E = TetraError> {
    pub fn update(&mut self, ctx: &mut Context) -> Result<(), E> { ... }
pub fn draw(&mut self, ctx: &mut Context) -> Result<(), E> { ... }
pub fn event(&mut self, ctx: &mut Context, event: Event) -> Result<(), E> { ... } }

Implemented by types that contain game state and provide logic for updating it and drawing it to the screen.

The methods on State allow you to return a Result, either explicitly or via the ? operator. If an error is returned, the game will close and the error will be returned from the run function that was used to start it.

The error type defaults to TetraError, but this can be overridden by adding a type parameter to your State implementation (e.g. State<MyError>).

Provided methods

pub fn update(&mut self, ctx: &mut Context) -> Result<(), E>[src]

Called when it is time for the game to update.

pub fn draw(&mut self, ctx: &mut Context) -> Result<(), E>[src]

Called when it is time for the game to be drawn.

pub fn event(&mut self, ctx: &mut Context, event: Event) -> Result<(), E>[src]

Called when a window or input event occurs.

Loading content...

Implementors

Loading content...