diff options
author | Jaro <jarorutjes07@gmail.com> | 2024-11-08 19:20:05 +0100 |
---|---|---|
committer | Jaro <jarorutjes07@gmail.com> | 2024-11-08 19:20:05 +0100 |
commit | d69adb5666fd6f73edbc6d410afcdf23c24e7c6b (patch) | |
tree | 00dd0280e603be5f67753fa1171582109b1065c4 /src/crepe/Particle.cpp | |
parent | 0feda3d123ff99a1b9e41837482268bebfd9140a (diff) |
particle updated
Diffstat (limited to 'src/crepe/Particle.cpp')
-rw-r--r-- | src/crepe/Particle.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/crepe/Particle.cpp b/src/crepe/Particle.cpp index 4810e80..d2b1880 100644 --- a/src/crepe/Particle.cpp +++ b/src/crepe/Particle.cpp @@ -1,20 +1,29 @@ #include "Particle.h" -using namespace crepe; +#include "api/Transform.h" -Particle::Particle() { this->active = false; } +using namespace crepe; -void Particle::reset(float lifespan, Position position, Position velocity) { +void Particle::reset(uint32_t lifespan, Vector2 position, Vector2 velocity, double angle) { this->time_in_life = 0; this->lifespan = lifespan; this->position = position; this->velocity = velocity; this->active = true; + this->angle = angle; +} + +void Particle::update() { + time_in_life++; + if (time_in_life >= lifespan) + { + this->active = false; + return; + } + velocity += force_over_time; + position += velocity; } -void Particle::update(float deltaTime) { - time_in_life += deltaTime; - position.x += velocity.x * deltaTime; - position.y += velocity.y * deltaTime; - if (time_in_life >= lifespan) this->active = false; +void Particle::stop_movement() { + this->velocity = {0,0}; } |