pub struct TickLoopState { /* private fields */ }Expand description
Implementation of a tickloop according to http://www.koonsolo.com/news/dewitters-gameloop/
Implementations§
Source§impl TickLoopState
impl TickLoopState
Sourcepub fn new(ticks_per_second: u32) -> Self
pub fn new(ticks_per_second: u32) -> Self
Creates a new tickloop with the given target tick-rate.
Sourcepub fn tick<F: FnOnce(&mut TickLoopEvent)>(
&mut self,
current_time: Instant,
function: F,
) -> bool
pub fn tick<F: FnOnce(&mut TickLoopEvent)>( &mut self, current_time: Instant, function: F, ) -> bool
Attempt to do a tick (at current tickrate per second), returning true if one happened.
Sourcepub fn tock<F: FnOnce(&mut TockLoopEvent)>(
&mut self,
current_time: Instant,
function: F,
) -> bool
pub fn tock<F: FnOnce(&mut TockLoopEvent)>( &mut self, current_time: Instant, function: F, ) -> bool
Attempt to do a tock (once per second), returning true if one happened.
Sourcepub fn interpolation(&self, current_time: Instant) -> f64
pub fn interpolation(&self, current_time: Instant) -> f64
Returns the interpolation factor between the previous and next tick, for smooth rendering.
Sourcepub fn get_minimum_tick_duration(&self) -> Duration
pub fn get_minimum_tick_duration(&self) -> Duration
Returns the intended minimum duration of a single tick.
Auto Trait Implementations§
impl Freeze for TickLoopState
impl RefUnwindSafe for TickLoopState
impl Send for TickLoopState
impl Sync for TickLoopState
impl Unpin for TickLoopState
impl UnwindSafe for TickLoopState
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