Skip to main content

Particle

Struct Particle 

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

Single Particle struct. Contains the location and color. Because macroquad does not support 3 dimensional points or single pixels, a Particle is implemented as a small line. This is why it contains the end_location member, as it is used as the ending point of the line.

This design choice can be embraced fully when creating a particle system that operates on a continuous line by setting the end_location somewhere near the the next point of the particle system to imitate continuity.

Implementations§

Source§

impl Particle

Source

pub fn new( (x, y, z): (f32, f32, f32), (r, g, b, a): (f32, f32, f32, f32), size: f32, length: f32, sloped: bool, ) -> Result<Self, String>

Instantiate a new Particle at (x, y, z) location with (r, g, b, a) color and s size, length l. sloped determines if the particle’s opacity fades out or not.

Source

pub fn new_line( (x, y, z): (f32, f32, f32), (xe, ye, ze): (f32, f32, f32), (r, g, b, a): (f32, f32, f32, f32), length: f32, sloped: bool, ) -> Result<Self, String>

Instantiate a new Particle at (x, y, z) location and ending location (x, y, z) with (r, g, b, a) color, length l. sloped determines if the particle’s opacity fades out or not.

Source

pub fn add_location(self, x: f32, y: f32, z: f32) -> Self

Add the x, y, z argument values to the location of Particle.

Source

pub fn sub_location(self, x: f32, y: f32, z: f32) -> Self

Subtract the x, y, z argument values to the location of Particle.

Source

pub fn set_location(&mut self, x: f32, y: f32, z: f32)

Set the location of the particle to x, y, z argument.

Source

pub fn set_color(&mut self, r: f32, g: f32, b: f32, a: f32)

Set the color of the particle to r, g, b, a argument.

Source

pub fn draw(&mut self) -> bool

Draw the Particle within the macroquad world coords. Returns true if Particle has surpassed its length, else false.

Source

pub fn reset(&mut self)

Reset the ellapsed time for the Particle object

Trait Implementations§

Source§

impl Clone for Particle

Source§

fn clone(&self) -> Particle

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 Debug for Particle

Source§

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

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

impl Default for Particle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Particle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ParticleSys for Particle

Source§

type T = Particle

Source§

fn is_active(&self) -> bool

Check if ParticleSys is active. Returns true if ParticleSys is in active state. Else false.
Source§

fn is_looping(&self) -> bool

Check if ParticleSys is looping. Return true if ParticleSys is in active looping state. Else false.
Source§

fn is_initialized(&mut self) -> bool

Return true if LinearParticles is initialized and ready to use.
Source§

fn reset_time(&mut self)

Reset the elapsed time counter for the ParticleSys. Read more
Source§

fn elapsed_time(&mut self) -> Option<f32>

Return the Some(elapsed) where elapsed is total elapsed seconds counted by the ParticleSys as f32, or None if that’s desirable.
Source§

fn setup(&mut self, _should_loop: bool, _p: Option<f32>) -> Result<(), String>

Set up the ParticleSys such that it is ready to be displayed. This function isn’t intended to be called by the user but by other trait methods. Read more
Source§

fn tear_down(&mut self)

Tear down the ParticleSys such that is_active() and is_initialized() return false and any other resetting of variables necessary for the ParticleSys to be able to call setup(). This function isn’t intended to be called by the user, but by other trait methods. Read more
Source§

fn next_frame(&mut self, _time: Option<f32>) -> Result<bool, String>

Display the next frame of the ParticleSys Particles with elapsed time time if Some(time), else the ParticleSys own counting mechanism. This function isn’t intended to be called by the user, but by the trait’s run method. Read more
Source§

fn iter(&self) -> Option<Iter<'_, Self::T>>

Return an Iterator over the Particle Pieces managed by the ParticleSys.
Source§

fn iter_mut(&mut self) -> Option<IterMut<'_, Self::T>>

Return a Mutable Iterator over the Particle Pieces managed by the ParticleSys.
Source§

fn with_period(self, p: f32) -> Result<Self, String>

Returns self with period p.
Source§

fn start_loop(&mut self) -> Result<(), String>

Set up ParticleSys into its looping active state.
Source§

fn start(&mut self) -> Result<(), String>

Set up ParticleSys into its active state.
Source§

fn stop(&mut self)

Tear down and deactivate ParticleSys object.
Source§

fn run(&mut self) -> Result<bool, String>

Display the next frame available from the LinearParticle. Read more
Source§

impl Copy for Particle

Source§

impl StructuralPartialEq for Particle

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> 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 = Infallible

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

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

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V