pub struct Clock { /* private fields */ }
Expand description
A data structure storing a time accumulator and some parameters for controlling the progression of game time. This implementation yields a fixed-timestep simulation loop following Fix Your Timestep! with optional improvements to smoothness and avoidance of death spirals based on Tyler Glaiel’s blog post.
Implementations§
source§impl Clock
impl Clock
sourcepub fn new(dt: f32, fudge_amount: f32, max_frames_per_tick: usize) -> Self
pub fn new(dt: f32, fudge_amount: f32, max_frames_per_tick: usize) -> Self
Creates a clock with the given target simulation frame rate.
fudge_amount
, if non-zero, will “fudge” time intervals to nearby standard frame rates (e.g., 15hz, 30hz, 60hz, 120hz, 144hz) to smooth out small differences under vertical sync.
max_frames_per_tick
limits the largest number of steps to simulate at once in order to avoid “death spirals” (where one slow frame causes multiple simulation steps, which delays the next frame, which then needs to make up for even more steps).
Auto Trait Implementations§
impl Freeze for Clock
impl RefUnwindSafe for Clock
impl Send for Clock
impl Sync for Clock
impl Unpin for Clock
impl UnwindSafe for Clock
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
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.