[][src]Enum gameloop::FrameAction

pub enum FrameAction {
    Tick,
    Render {
        interpolation: f64,
    },
}

Represents a tick or render instruction, to be interpreted by your game.

Example

This example is not tested
let mut my_game = MyGame::default();
let game_loop = GameLoop::new(20, 5).unwrap();

while !my_game.should_quit() {
    my_game.handle_window_events();

    for action in game_loop.actions() {
        match action {
            FrameAction::Tick => my_game.tick(),
            FrameAction::Render { interpolation } => {
                let prev_state = my_game.previous_state();
                let curr_state = my_game.current_state();

                let interpolated_state = prev_state.interpolate(curr_state, interpolation);
                my_game.render(interpolated_state);
            }
        }
    }
}

Variants

Tick

The game should simulate one tick.

Render

The game should render the game state interpolated by the given amount between the previous tick and the current.

Fields of Render

interpolation: f64

Trait Implementations

impl Debug for FrameAction[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.