diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-12-16 21:17:03 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-12-16 21:17:03 +0100 |
commit | cfbfef8deb9e278ad9a9023bda36fd3aa3f17373 (patch) | |
tree | a5a4ed0ddbe735638979b0457c81941d2ac8234a /src/crepe/Particle.cpp | |
parent | 16f3aa77cfbfd3327a50a3f11f27e7d7dd303026 (diff) | |
parent | 20d19e3c714d3e8ca3e35c170c07c563ecc719bb (diff) |
Merge branch 'jaro/particle-system-improvement' of github.com:lonkaars/crepe into jaro/collision-system-handeling
Diffstat (limited to 'src/crepe/Particle.cpp')
-rw-r--r-- | src/crepe/Particle.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp index 485a0d4..b340826 100644 --- a/src/crepe/Particle.cpp +++ b/src/crepe/Particle.cpp @@ -2,8 +2,8 @@ using namespace crepe; -void Particle::reset(uint32_t lifespan, const vec2 & position, const vec2 & velocity, - double angle) { +void Particle::reset(unsigned int lifespan, const vec2 & position, const vec2 & velocity, + float angle) { // Initialize the particle state this->time_in_life = 0; this->lifespan = lifespan; @@ -15,16 +15,17 @@ void Particle::reset(uint32_t lifespan, const vec2 & position, const vec2 & velo 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() { |