blob: d2b18805d540b4ae747d99759e13b691136f7e4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "Particle.h"
#include "api/Transform.h"
using namespace crepe;
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::stop_movement() {
this->velocity = {0,0};
}
|