aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/Particle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/Particle.cpp')
-rw-r--r--src/crepe/Particle.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp
index 3254b5b..8cf7f7e 100644
--- a/src/crepe/Particle.cpp
+++ b/src/crepe/Particle.cpp
@@ -1,16 +1,23 @@
#include "Particle.hpp"
#include <iostream>
-Particle::Particle(float lifespan, Position position, Position velocity)
- : lifespan(lifespan), position(position), velocity(velocity), timeInLife(0.0f) {}
+Particle::Particle()
+{
+ this->active = false;
+}
+
+void Particle::reset(float lifespan, Position position, Position velocity) {
+ this->timeInLife = 0;
+ this->lifespan = lifespan;
+ this->position = position;
+ this->velocity = velocity;
+ this->active = true;
+}
void Particle::update(float deltaTime) {
timeInLife += deltaTime;
position.x += velocity.x * deltaTime;
position.y += velocity.y * deltaTime;
+ if(timeInLife >= lifespan)this->active = false;
}
-bool Particle::isAlive() const {
- std::cout << "lifespan" << lifespan << std::endl;
- return timeInLife < lifespan;
-}