-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfx_ship_expl.cpp
46 lines (34 loc) · 990 Bytes
/
fx_ship_expl.cpp
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "fx_ship_expl.h"
#include "pe_smoketrail.h"
#include "snoutlib/timer.h"
FX_Ship_Explosion::FX_Ship_Explosion(const vec2& pos) :
m_pos(pos),m_num_trails(5)
{
vec2 gravity = vec2(0.0,0.4);
for(int i=0;i<m_num_trails;++i)
m_trails.push_back(new PE_SmokeTrail(m_pos,vec2(rand_range(-0.4, 0.4),rand_range(-0.6,-0.3)),gravity));
m_start_time = g_timer->now();
m_duration = 5.0;
m_running = true;
}
FX_Ship_Explosion::~FX_Ship_Explosion()
{
for(int i=0;i<m_num_trails;++i)
delete m_trails[i];
}
void FX_Ship_Explosion::update(void)
{
if (!m_running) return;
if (g_timer->now() - m_start_time > m_duration) {
m_running = false;
return;
}
for(int i=0;i<m_num_trails;++i) m_trails[i]->update();
}
void FX_Ship_Explosion::draw(void)
{
if (!m_running) return;
for(int i=0;i<m_num_trails;++i) m_trails[i]->draw();
}
bool FX_Ship_Explosion::finished(void) { return !m_running; }
bool FX_Ship_Explosion::running(void) { return m_running; }