[−][src]Struct babalcore::InputJump
Used to handle jump input. This is to encapsulate all the nitty-picky logic about considering a button is still pressed a fraction of seconds after it has been pressed, etc. It does not actually poll and/or listens to the real hardware, it just keeps track of what's happening with push/pop operations.
Fields
stickiness: Option<Duration>
How long a button should be considered pressed after it has actually been pressed. This is used to work around the fact that you might require a jump just before you actually land.
Implementations
impl InputJump
[src]
pub fn new() -> InputJump
[src]
pub fn set_stickiness_secs_f64(&mut self, stickiness_secs_f64: Option<f64>)
[src]
Set the stickiness value, in seconds.
Examples
use babalcore::*; let mut input_jump = InputJump::new(); input_jump.set_stickiness_secs_f64(Some(0.1));
pub fn push_jump(&mut self, now: Option<Instant>)
[src]
Push a jump request. It is possible to omit the current now timestamp, or you may provide your own. If omitted, the default is the current instant (AKA now). Pushing several jump requests will not queue them, only the last one is registered.
Examples
use babalcore::*; let mut input_jump = InputJump::new(); // Player pressed the jump key, clicked on mouse input_jump.push_jump(None);
pub fn pop_jump(&mut self, now: Option<Instant>) -> bool
[src]
Pop a jump request. It is possible to omit the current now timestamp, or you may provide your own. If omitted, the default is the current instant (AKA now). Once a jump request is popped, it is cleared from the object. However, if stickiness is set, it will continue to return true for some time, defined by stickiness. This is to avoid the following "bug": a player would press jump just before it can actually jump (eg: the ball did not land yet). But a fraction of a second later it would be OK to jump... You'd want it to jump now. To work around this, pop will return true for some time, typically 1/10th of a second.
Examples
use babalcore::*; let mut input_jump = InputJump::new(); assert!(!input_jump.pop_jump(None)); input_jump.push_jump(None); assert!(input_jump.pop_jump(None));
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for InputJump
[src]
impl Send for InputJump
[src]
impl Sync for InputJump
[src]
impl Unpin for InputJump
[src]
impl UnwindSafe for InputJump
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,