aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/ParticleEmitter.hpp
diff options
context:
space:
mode:
authorjaroWMR <jarorutjes07@gmail.com>2024-10-07 10:04:23 +0200
committerjaroWMR <jarorutjes07@gmail.com>2024-10-07 10:04:23 +0200
commit094ce1806156e191ffb554d4e88e636421cb0242 (patch)
tree675168131ac24bf29ffb161334be176e4d4022e0 /src/crepe/ParticleEmitter.hpp
parentbd24f87e18bef29679023ee9a60028f2afdbb470 (diff)
particle direction is random
Diffstat (limited to 'src/crepe/ParticleEmitter.hpp')
-rw-r--r--src/crepe/ParticleEmitter.hpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/crepe/ParticleEmitter.hpp b/src/crepe/ParticleEmitter.hpp
index 682a2ae..9b3f2ad 100644
--- a/src/crepe/ParticleEmitter.hpp
+++ b/src/crepe/ParticleEmitter.hpp
@@ -1,28 +1,30 @@
#pragma once
#include <vector>
-#include <cstdlib>
-#include <ctime>
#include "Particle.hpp"
-#include <cmath>
class ParticleEmitter {
public:
- std::vector<Particle> particles;
+ 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 Position { //struct to hold position
int x;
int y;
- } position;
-
- int maxParticles;
- float emissionRate;
- float elapsedTime;
+ };
- ParticleEmitter(int maxParticles, float emissionRate);
- void update(float deltaTime);
+ 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
-private:
- void emitParticle();
- float randFloat(float minangle, float maxangle, float minVel, float maxVel);
+ std::vector<Particle> particles; //collection of particles
};