pub struct HurryClock {
pub delay: f32,
pub factor: f32,
/* private fields */
}Expand description
The clock of one timed step: each frame’s seconds as they pass, faster once the player has held the key a moment, and whether a press has skipped the step.
Its owner calls tick each frame with whether the key
that hurries is held, and moves its step on by the seconds it returns.
A press calls skip, and the owner, seeing
is_skipped, finishes the step at once. A new step
resets the clock.
The hold counts from the first frame the key is held, including that
frame: the part of a frame past delay goes
factor times as fast, the part before it as fast as
ever.
Fields§
§delay: f32Seconds the key must be held before time passes faster.
factor: f32How much faster time passes after that.
Implementations§
Source§impl HurryClock
impl HurryClock
Sourcepub const fn new(delay: f32, factor: f32) -> Self
pub const fn new(delay: f32, factor: f32) -> Self
A clock that passes time factor times as fast once the key has
been held delay seconds; nothing held, nothing skipped.
Sourcepub fn hold(&mut self, held: bool, dt: f32)
pub fn hold(&mut self, held: bool, dt: f32)
Counts dt seconds of the key held, or, let go, starts the count
over. A dt that is not finite or is negative counts as 0.
Sourcepub fn passing(&self, dt: f32) -> f32
pub fn passing(&self, dt: f32) -> f32
The seconds that pass for a frame of dt that the key has been held
through so far: dt, with the part of it past the delay
factor times as fast. A dt that is not finite
or is negative counts as 0.
Sourcepub fn release(&mut self)
pub fn release(&mut self)
The key is no longer counted as held (the step waits on something else), as if let go.
Sourcepub fn skip(&mut self)
pub fn skip(&mut self)
A press finishes the step: is_skipped until
reset.
Sourcepub fn is_skipped(&self) -> bool
pub fn is_skipped(&self) -> bool
Whether a press has skipped the step.
Trait Implementations§
Source§impl Clone for HurryClock
impl Clone for HurryClock
Source§fn clone(&self) -> HurryClock
fn clone(&self) -> HurryClock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for HurryClock
Source§impl Debug for HurryClock
impl Debug for HurryClock
Source§impl Default for HurryClock
impl Default for HurryClock
Source§fn default() -> Self
fn default() -> Self
The text box’s: HURRY_DELAY and HURRY_FACTOR.