blob: 9b3f2ad50e331c8d2fc55fdc3a81da0e03e4e82e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#pragma once
#include <vector>
#include "Particle.hpp"
class ParticleEmitter {
public:
ParticleEmitter(unsigned int maxParticles, unsigned int emissionRate, unsigned int speed, unsigned int speedOffset, unsigned int angle, unsigned int angleOffset);
void update(float deltaTime); // Keep deltaTime as float
const std::vector<Particle>& getParticles() const; //returns the collection of particles
void setPosition(int x, int y); //sets the position of the emitter
private:
void emitParticle(); //emits a new particle
struct Position { //struct to hold position
int x;
int y;
};
Position m_position; //position of the emitter
unsigned int m_maxParticles; //maximum number of particles
unsigned int m_emissionRate; //rate of particle emission
float m_elapsedTime; //elapsed time since the last emission
unsigned int m_speed; //base speed of the particles
unsigned int m_speedOffset; //offset for random speed variation
unsigned int m_minAngle; //min angle of particle emission
unsigned int m_maxAngle; //max angle of particle emission
std::vector<Particle> particles; //collection of particles
};
|