Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

Particle

Struct Particle 

Source
pub struct Particle {
    pub x: i16,
    pub y: i16,
    pub x_frac: u8,
    pub y_frac: u8,
    pub vx: i16,
    pub vy: i16,
    pub r: u8,
    pub g: u8,
    pub b: u8,
    pub ttl: u8,
    pub spawn_ttl: u8,
}
Expand description

One live particle.

Positions are in screen-space pixels (i16). Velocities are Q4.4 sub-pixel – vx = 32 means 2 px / frame. That keeps enough resolution for slow drift + fast bursts out of the same i16 channel.

Fields§

§x: i16

Top-left x position in pixels.

§y: i16

Top-left y position in pixels.

§x_frac: u8

Fraction of a pixel x has advanced, in sixteenths (0..=15). The pool carries the part of vx that does not fill a whole pixel here, so slow particles drift instead of freezing.

§y_frac: u8

Fraction of a pixel y has advanced, in sixteenths (0..=15).

§vx: i16

Velocity along x, Q4.4 pixels/frame.

§vy: i16

Velocity along y, Q4.4 pixels/frame. Positive = downward.

§r: u8

Colour at spawn – the renderer scales this by ttl / spawn_ttl for a fade-out.

§g: u8

Green at spawn.

§b: u8

Blue at spawn.

§ttl: u8

Frames remaining. 0 = slot empty.

§spawn_ttl: u8

TTL originally passed at spawn. Kept so the fade ratio is correct when different bursts have different lifespans.

Implementations§

Source§

impl Particle

Source

pub const fn empty() -> Self

A dead / empty slot. Useful for static-array init.

Source

pub const fn is_alive(&self) -> bool

Is this particle currently alive and worth rendering?

Trait Implementations§

Source§

impl Clone for Particle

Source§

fn clone(&self) -> Particle

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Particle

Source§

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

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

impl Copy for Particle

Auto Trait Implementations§

§

impl Freeze for Particle

§

impl RefUnwindSafe for Particle

§

impl Send for Particle

§

impl Sync for Particle

§

impl Unpin for Particle

§

impl UnsafeUnpin for Particle

§

impl UnwindSafe for Particle

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.