6aae3ed78f6ad583563a8e60d3208f34164f1e89
[physics.git] / src / Entities / Particle.cpp
1 #include "Particle.h"
2
3 #include "../Vector2.h"
4
5
6 /// ***** Constructors/Destructors *****
7
8 Particle::Particle(const Vector2& pos, bool canDie)
9     : Entity(pos), canDie(canDie)
10 {
11
12 }
13 Particle::Particle(const Vector2& pos, float lifeTime)
14     : Entity(pos), lifeTime(lifeTime)
15 {
16
17 }
18 Particle::~Particle()
19 {
20
21 }
22
23 /// ***** Public Class Methods *****
24
25 void Particle::update(float time_step)
26 {
27     if(isDead)
28         return;
29
30     if (canDie)
31     {
32         lifeTime -= time_step;
33         isDead = lifeTime <= 0;
34     }
35     position += velocity * time_step;
36 }