pub struct Buttons { /* private fields */ }Implementations§
Source§impl Buttons
impl Buttons
pub const Left: Buttons
pub const Right: Buttons
pub const Up: Buttons
pub const Down: Buttons
pub const B: Buttons
pub const A: Buttons
Sourcepub const fn all_bits() -> Self
pub const fn all_bits() -> Self
Returns a bitmask that contains all values.
This will include bits that do not have any flags.
Use ::all_flags() if you only want to use flags.
Sourcepub const fn is_all_bits(&self) -> bool
pub const fn is_all_bits(&self) -> bool
Returns true if the bitmask contains all values.
This will check for bits == !0,
use .is_all_flags() if you only want to check for all flags
Sourcepub const fn is_all_flags(&self) -> bool
pub const fn is_all_flags(&self) -> bool
Returns true if the bitmask contains all flags.
This will fail if any unused bit is set,
consider using .truncate() first.
Sourcepub const fn all() -> Self
👎Deprecated: Please use the ::all_bits() constructor
pub const fn all() -> Self
::all_bits() constructorReturns a bitmask that contains all values.
This will include bits that do not have any flags.
Use ::all_flags() if you only want to use flags.
Sourcepub const fn is_all(&self) -> bool
👎Deprecated: Please use the .is_all_bits() method
pub const fn is_all(&self) -> bool
.is_all_bits() methodReturns true if the bitmask contains all values.
This will check for bits == !0,
use .is_all_flags() if you only want to check for all flags
Sourcepub const fn full() -> Self
👎Deprecated: Please use the ::all_flags() constructor
pub const fn full() -> Self
::all_flags() constructorReturns a bitmask that contains all flags.
Sourcepub const fn is_full(&self) -> bool
👎Deprecated: Please use the .is_all_flags() method
pub const fn is_full(&self) -> bool
.is_all_flags() methodReturns true if the bitmask contains all flags.
This will fail if any unused bit is set,
consider using .truncate() first.
Sourcepub const fn truncate(&self) -> Self
pub const fn truncate(&self) -> Self
Returns a bitmask that only has bits corresponding to flags
Sourcepub const fn intersects(&self, other: Self) -> bool
pub const fn intersects(&self, other: Self) -> bool
Returns true if self intersects with any value in other,
or if other does not contain any values.
This is equivalent to (self & other) != 0 || other == 0.
Sourcepub const fn contains(&self, other: Self) -> bool
pub const fn contains(&self, other: Self) -> bool
Returns true if self contains all values of other.
This is equivalent to (self & other) == other.
Examples found in repository?
174 fn update(&mut self, _delta: f32) {
175 let button_state = PLAYDATE.system.get_button_state();
176 let prev_scale = self.scale;
177 let prev_center = self.center;
178 // Scale
179 if button_state.current.contains(Buttons::A) {
180 self.scale /= 1.1;
181 } else if button_state.current.contains(Buttons::B) {
182 self.scale *= 1.1
183 }
184 if !PLAYDATE.system.is_crank_docked() {
185 let crank = PLAYDATE.system.get_crank_change();
186 if crank > 0.0 {
187 self.scale /= 1.05;
188 } else if crank < 0.0 {
189 self.scale *= 1.05;
190 }
191 }
192 // Move
193 if button_state.current.contains(Buttons::Up) {
194 self.center.im += 10.0 * self.scale
195 } else if button_state.current.contains(Buttons::Down) {
196 self.center.im -= 10.0 * self.scale
197 }
198 if button_state.current.contains(Buttons::Left) {
199 self.center.re -= 10.0 * self.scale
200 } else if button_state.current.contains(Buttons::Right) {
201 self.center.re += 10.0 * self.scale
202 }
203 if prev_center != self.center || prev_scale != self.scale {
204 self.draw_frame();
205 }
206 // Draw metadata
207 self.draw_meta();
208 // Draw FPS
209 PLAYDATE.system.draw_fps(vec2![0, 0]);
210 }Trait Implementations§
Source§impl BitAndAssign for Buttons
impl BitAndAssign for Buttons
Source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&= operation. Read moreSource§impl BitOrAssign for Buttons
impl BitOrAssign for Buttons
Source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|= operation. Read moreSource§impl BitXorAssign for Buttons
impl BitXorAssign for Buttons
Source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^= operation. Read more