TickLoopState

Struct TickLoopState 

Source
pub struct TickLoopState { /* private fields */ }
Expand description

Implementation of a tickloop according to http://www.koonsolo.com/news/dewitters-gameloop/

Implementations§

Source§

impl TickLoopState

Source

pub fn new(ticks_per_second: u32) -> Self

Creates a new tickloop with the given target tick-rate.

Source

pub fn pre(&mut self)

Resets the tickloop.

Source

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.

Source

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.

Source

pub fn interpolation(&self, current_time: Instant) -> f64

Returns the interpolation factor between the previous and next tick, for smooth rendering.

Source

pub fn get_minimum_tick_duration(&self) -> Duration

Returns the intended minimum duration of a single tick.

Source

pub fn get_start(&self) -> Instant

Returns when the tickloop was created.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.