aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/Particle.cpp
blob: f6bbd344bd6f3890882f8f27c1da9b5683d9445b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#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 += velocity.x * deltaTime;
    position.y += velocity.y * deltaTime;
}

bool Particle::isAlive() const {
    return timeInLife < lifespan;
}