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.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp
new file mode 100644
index 0000000..90957db
--- /dev/null
+++ b/src/crepe/Particle.cpp
@@ -0,0 +1,14 @@
+#include "Particle.hpp"
+
+Particle::Particle(float lifespan, Position position, Position velocity)
+ : lifespan(lifespan), position(position), velocity(velocity), timeInLife(0.0f) {}
+
+void Particle::update(float deltaTime) {
+ timeInLife += deltaTime;
+ position.x += static_cast<int>(velocity.x * deltaTime);
+ position.y += static_cast<int>(velocity.y * deltaTime);
+}
+
+bool Particle::isAlive() const {
+ return timeInLife < lifespan;
+}