Struct firefly_rust::DPad
source · pub struct DPad {
pub left: bool,
pub right: bool,
pub up: bool,
pub down: bool,
}
Expand description
DPad-like representation of the Pad
.
Constructed with Pad::as_dpad
. Useful for simple games and ports.
The middle of the pad is a “dead zone” pressing which will not activate any direction.
Invariant: it’s not possible for opposite directions (left and right, or down and up) to be active at the same time. However, it’s possible for heighboring directions (like up and right) to be active at the same time if the player presses a diagonal.
Fields§
§left: bool
§right: bool
§up: bool
§down: bool
Implementations§
source§impl DPad
impl DPad
sourcepub fn just_pressed(&self, old: &Self) -> Self
pub fn just_pressed(&self, old: &Self) -> Self
Given the old state, get directions that were not pressed but are pressed now.
sourcepub fn just_released(&self, old: &Self) -> Self
pub fn just_released(&self, old: &Self) -> Self
Given the old state, get directions that were pressed but aren’t pressed now.
Trait Implementations§
source§impl Ord for DPad
impl Ord for DPad
source§impl PartialEq for DPad
impl PartialEq for DPad
source§impl PartialOrd for DPad
impl PartialOrd for DPad
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for DPad
impl Eq for DPad
impl StructuralPartialEq for DPad
Auto Trait Implementations§
impl Freeze for DPad
impl RefUnwindSafe for DPad
impl Send for DPad
impl Sync for DPad
impl Unpin for DPad
impl UnwindSafe for DPad
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.