21 , particles(maxParticles)
32 for (uint32_t i = 0; i < count; ++i) {
63 if (p.age >= p.lifetime) {
70 p.position += p.velocity * dt;
79 const float t = p.age / p.lifetime;
87 p.position.x - (size / 2.0F), p.position.y - (size / 2.0F), size, size);
103 const Color color { r, g, b, a };
129 p.velocity =
Vec2<float>(std::cos(angle) * speed, std::sin(angle) * speed);
void draw() override
Draw alive particles.
std::vector< Particle > particles
float emission_accumulator
uint32_t get_alive_count() const
Get the number of alive particles.
ParticleEmitter()=default
Create a default ParticleEmitter with no particles.
void emit(uint32_t count)
Emit a burst of particles at current position.
void set_emission_rate(float rate)
Set emission rate (particles per second), 0 to disable auto-emit.
void start()
Start continuous emission.
void update(float dt) override
Update particles.
void stop()
Stop continuous emission.
Vec2< T > position
The position of the rectangle.
float alpha
Opacity of the object.
asw::Quad< float > transform
The transform of the object.
Routines for drawing sprites and primitives to the screen.
void circle_fill(const asw::Vec2< float > &position, float radius, asw::Color color)
Draw a filled circle.
void stretch_sprite(const asw::Texture &tex, const asw::Quad< float > &position)
Draw a sprite with the option to stretch it.
void set_alpha(const asw::Texture &texture, float alpha)
Set the alpha of a texture.
int between(int min, int max)
Generate a random integer between min and max.
T lerp(const T &a, const T &b, float t)
Lerp between two values.
Lightweight particle emitter system.
Random module for the ASW library.
RGBA color struct with 8-bit channels.
Configuration for particle emitters.
General utility functions.