Skip to main content

BoulderDustState

Struct BoulderDustState 

Source
pub struct BoulderDustState { /* private fields */ }
Expand description

The 2×2 smoke-puff block kicked up when a pushed boulder slides one tile. The block is written once, anchored to the player’s map tile at push time (the animation outlives the push lockout, so the anchor must not track the player afterward), then runs BOULDER_DUST_STEPS steps of BOULDER_DUST_STEP_FRAMES frames each. Every step the block drifts 1px against the boulder’s slide direction and the sprite palette toggles, flashing two gray shades.

Implementations§

Source§

impl BoulderDustState

Source

pub const fn inactive() -> Self

A finished (inactive) state — no dust showing.

Source

pub const fn new(facing: Direction, anchor_x: u16, anchor_y: u16) -> Self

Start the dust for a push in facing direction, anchored to the player’s map tile at push time.

Source

pub fn tick(&mut self)

Advance one frame. No-op once the animation has finished.

Source

pub fn is_active(&self) -> bool

True while the puff is showing (steps 0..7).

Source

pub fn facing(&self) -> Direction

The push direction.

Source

pub fn anchor(&self) -> (u16, u16)

The player’s map tile at push time — the dust’s world anchor.

Source

pub fn step(&self) -> u8

Current animation step index (0..=7).

Source

pub fn base_offset(&self) -> (i32, i32)

Base pixel offset of the dust block’s top-left corner from the player sprite’s top-left (the puff appears at the boulder’s base, “2 blocks away from the player”).

Source

pub fn drift_px(&self) -> (i32, i32)

Per-step pixel drift of the dust block — opposite to the boulder’s slide direction. The puff lingers as the boulder slides away from it.

Source

pub fn tile_drifts(&self) -> [(i32, i32); 4]

Per-step pixel delta of each of the block’s four 8×8 tiles (upper-left, upper-right, lower-left, lower-right). Vertical pushes move the whole block; horizontal pushes move only the upper-right, lower-left and lower-right tiles — the upper-left tile stays in place.

Source

pub fn palette_flipped(&self) -> bool

True on odd steps: the palette toggles once per step, flashing the two gray shades of the smoke sprite.

Trait Implementations§

Source§

impl Clone for BoulderDustState

Source§

fn clone(&self) -> BoulderDustState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BoulderDustState

Source§

impl Debug for BoulderDustState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for BoulderDustState

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for BoulderDustState

Source§

impl PartialEq for BoulderDustState

Source§

fn eq(&self, other: &BoulderDustState) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for BoulderDustState

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for BoulderDustState

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.