pub enum FrameAction {
Tick,
Render {
interpolation: f64,
},
}Expand description
Represents a tick or render instruction, to be interpreted by your game.
§Example
ⓘ
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FrameAction
impl RefUnwindSafe for FrameAction
impl Send for FrameAction
impl Sync for FrameAction
impl Unpin for FrameAction
impl UnsafeUnpin for FrameAction
impl UnwindSafe for FrameAction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more