Skip to main content

FixedTimestep

Struct FixedTimestep 

Source
pub struct FixedTimestep {
    pub step: f64,
    pub tick_count: u64,
    /* private fields */
}
Expand description

Fixed-timestep configuration stored as a resource.

The game loop ticks the schedule at a fixed rate (default 10 Hz for RTS). A time accumulator ensures deterministic simulation: the same inputs produce the same outputs regardless of frame rate.

Fields§

§step: f64

Seconds per tick (1.0 / tick_rate).

§tick_count: u64

Total number of ticks executed.

Implementations§

Source§

impl FixedTimestep

Source

pub const MIN_HZ: f64 = 1.0

Minimum tick rate (1 Hz). Below this, use event-driven scheduling instead.

Source

pub const MAX_HZ: f64 = 240.0

Maximum tick rate (240 Hz). Beyond this, the per-tick budget is too small for meaningful simulation work and risks death-spiraling the game loop.

Source

pub fn new(tick_rate: f64) -> Self

Create a new fixed timestep at the given tick rate (Hz).

Source

pub fn default_rts() -> Self

Create a 10 Hz timestep (default for RTS).

Source

pub fn strategy() -> Self

20 Hz — good for turn-like strategy with smooth interpolation.

Source

pub fn action() -> Self

30 Hz — action games, third-person, adventure.

Source

pub fn fast() -> Self

60 Hz — platformers, FPS, fighting games.

Source

pub fn tick_rate(&self) -> f64

Returns the tick rate in Hz.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.