-
Notifications
You must be signed in to change notification settings - Fork 0
/
effects.cpp
92 lines (80 loc) · 1.76 KB
/
effects.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <vector>
#include "effects.h"
extern std::vector<Effect> effects;
void addEffect(effecType type, float x, float y, float z, int i, int j, int k)
{
Effect effect = {type,x,y,z,i,j,k};
effects.push_back(effect);
}
void addShineEffect(int i)
{
addEffect(effShine,0.0,0.0,0.0,i,1000,0);
}
void addFlickerEffect(int i)
{
addEffect(effFlicker,0.0,0.0,0.0,i,1000,0);
}
void addExplosionEffect(float x, float y, float z)
{
addEffect(effExplosion,x,y,z,0,500,0);
}
bool moveOnEffect(Effect & effect, int dt)
{
switch(effect.type)
{
case effShine:
{
effect.j -= dt;
if(effect.j <= 0) return false;
else return true;
}
case effFlicker:
{
effect.j -= dt;
if(effect.j <= 0) return false;
else return true;
}
case effExplosion:
{
effect.j -= dt;
if(effect.j <= 0) return false;
else return true;
}
}
}
int findEffectI(effecType type, int i)
{
for(int n = 0; n < effects.size(); n++)
if(effects.at(n).i==i && effects.at(n).type==type) return n;
return -1;
}
int findEffectJ(effecType type, int j)
{
for(int n = 0; n < effects.size(); n++)
if(effects.at(n).j==j && effects.at(n).type==type) return n;
return -1;
}
int findEffectK(effecType type, int k)
{
for(int n = 0; n < effects.size(); n++)
if(effects.at(n).k==k && effects.at(n).type==type) return n;
return -1;
}
int findEffectX(effecType type, float x)
{
for(int n = 0; n < effects.size(); n++)
if(effects.at(n).x==x && effects.at(n).type==type) return n;
return -1;
}
int findEffectY(effecType type, float y)
{
for(int n = 0; n < effects.size(); n++)
if(effects.at(n).y==y && effects.at(n).type==type) return n;
return -1;
}
int findEffectZ(effecType type, float z)
{
for(int n = 0; n < effects.size(); n++)
if(effects.at(n).z==z && effects.at(n).type==type) return n;
return -1;
}