diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-12-07 22:44:35 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-12-07 22:44:35 +0100 |
commit | 8c81bf4a33a13fc21dca7e3fe78a6dc334ac964b (patch) | |
tree | 591cf1d62731c6f206a9a54d011ddf462631c41a /src/crepe/Particle.cpp | |
parent | 31e4ba33bec0cc5c33d9668cd0244972523bf8ad (diff) |
changed spawnrate of particles (bound to delta time)
Diffstat (limited to 'src/crepe/Particle.cpp')
-rw-r--r-- | src/crepe/Particle.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp index ce000a1..b340826 100644 --- a/src/crepe/Particle.cpp +++ b/src/crepe/Particle.cpp @@ -15,16 +15,17 @@ void Particle::reset(unsigned int lifespan, const vec2 & position, const vec2 & this->force_over_time = {0, 0}; } -void Particle::update() { +void Particle::update(double dt) { // Deactivate particle if it has exceeded its lifespan - if (++time_in_life >= lifespan) { + time_in_life += dt; + if (time_in_life >= lifespan) { this->active = false; return; } // Update velocity based on accumulated force and update position - this->velocity += force_over_time; - this->position += velocity; + this->velocity += force_over_time * dt; + this->position += velocity * dt; } void Particle::stop_movement() { |