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
impl Particle
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub fn add_location(self, x: f32, y: f32, z: f32) -> Self
pub fn add_location(self, x: f32, y: f32, z: f32) -> Self
Add the x, y, z argument values to the location of Particle.
Sourcepub fn sub_location(self, x: f32, y: f32, z: f32) -> Self
pub fn sub_location(self, x: f32, y: f32, z: f32) -> Self
Subtract the x, y, z argument values to the location of Particle.
Sourcepub fn set_location(&mut self, x: f32, y: f32, z: f32)
pub fn set_location(&mut self, x: f32, y: f32, z: f32)
Set the location of the particle to x, y, z argument.
Sourcepub fn set_color(&mut self, r: f32, g: f32, b: f32, a: f32)
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.
Trait Implementations§
Source§impl ParticleSys for Particle
impl ParticleSys for Particle
type T = Particle
Source§fn is_active(&self) -> bool
fn is_active(&self) -> bool
true if ParticleSys is in active state. Else false.Source§fn is_looping(&self) -> bool
fn is_looping(&self) -> bool
true if ParticleSys is in active looping state. Else false.Source§fn is_initialized(&mut self) -> bool
fn is_initialized(&mut self) -> bool
true if LinearParticles is initialized and ready to use.Source§fn reset_time(&mut self)
fn reset_time(&mut self)
Source§fn elapsed_time(&mut self) -> Option<f32>
fn elapsed_time(&mut self) -> Option<f32>
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>
fn setup(&mut self, _should_loop: bool, _p: Option<f32>) -> Result<(), String>
Source§fn tear_down(&mut self)
fn tear_down(&mut self)
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 moreSource§fn next_frame(&mut self, _time: Option<f32>) -> Result<bool, String>
fn next_frame(&mut self, _time: Option<f32>) -> Result<bool, String>
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