Struct game_time::runner::FrameRunner
[−]
[src]
pub struct FrameRunner<C: FrameCount> { /* fields omitted */ }
A helper type for running frame simulations with a frame counter.
FrameRunner
combines a GameClock
and a FrameCount
object,
tracking each frame as well as a framerate. FrameRunner
provides
a tick
method like GameClock
, and updates both the GameClock
and
FrameCount
objects contained.
Methods
impl<C> FrameRunner<C> where
C: FrameCount,
[src]
C: FrameCount,
fn new(clock: GameClock, counter: C) -> FrameRunner<C>
Construct a new FrameRunner
from a GameClock
and a FrameCount
.
fn clock(&self) -> &GameClock
Get a reference to the contained GameClock
.
fn clock_mut(&mut self) -> &mut GameClock
Get a mutable reference to the contained GameClock
.
fn counter(&self) -> &C
Get a reference to the contained FrameCount
.
fn counter_mut(&mut self) -> &mut C
Get a mutable reference to the contained FrameCount
.
fn tick<T: TimeStep>(&mut self, time_step: &T) -> GameTime
Mark the start of a new frame, updating time and frame rate statistics.
The GameTime
for the new frame is returned, with the same properties as that
returned from GameClock::tick
.
fn tick_with_wall_time<T: TimeStep>(
&mut self,
time_step: &T,
frame_start: DateTime<Local>
) -> GameTime
&mut self,
time_step: &T,
frame_start: DateTime<Local>
) -> GameTime
Mark the start of a new frame with a specified wall time, updating time statistics.
This function is like tick
but allows for the start time for the
frame to be specified.
fn do_frame<T, F>(&mut self, time_step: &T, frame_fn: F) where
T: TimeStep,
F: FnOnce(GameTime),
T: TimeStep,
F: FnOnce(GameTime),
Perform one frame of the simulation using frame_fn
.
The closure is passed the GameTime
for the frame by calling tick
and will call
GameClock::sleep_remaining
after the closure has ended.