aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/Particle.cpp
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-12-17 14:36:33 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-12-17 14:36:33 +0100
commit473f807b1ec0fc67f40c65b310e132e4b83a76a3 (patch)
treeb5509f1fea0238707ae887ee26ccea2fc8f59a69 /src/crepe/Particle.cpp
parentf2a95686ec6d33d15f38fef4420700cefc875e89 (diff)
parentc96ef5f62a1369d66e8eba9bf8ed192e3cf8e716 (diff)
Merge remote-tracking branch 'origin/master' into max/game
Diffstat (limited to 'src/crepe/Particle.cpp')
-rw-r--r--src/crepe/Particle.cpp13
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() {