-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticle.h
More file actions
108 lines (89 loc) · 2.18 KB
/
Copy pathParticle.h
File metadata and controls
108 lines (89 loc) · 2.18 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/********************************
Name: Particle
Copyright:
Author: Martin Cardozo
Date: 12/06/08 11:17
Description: Particula Genérica
*********************************/
/************************
INCLUDES
************************/
/************************
CLASS
************************/
class Particle {
public:
//CONSTRUCTOR
Particle(float XC, float YC, int minXC, int maxXC, int minYC, int maxYC, int lifeTimeC, float amplitudeC, float forceC, int redC, int greenC, int blueC);
//FUNCTIONS
bool update();
//VARIABLES
float X;
float Y;
int red;
int green;
int blue;
private:
//FUNCTIONS
bool checkLife();
float randFloat(float max);
float GAR(float max);
//VARIABLES
int minX;
int maxX;
int minY;
int maxY;
int lifeTime;
float weight;
float amplitude;
float force;
};
/************************
CONSTRUCTOR
************************/
Particle::Particle(float XC, float YC, int minXC, int maxXC, int minYC, int maxYC, int lifeTimeC, float amplitudeC, float forceC, int redC, int greenC, int blueC)
{
X = XC;
Y = YC;
minX = minXC;
maxX = maxXC;
minY = minYC;
maxY = maxYC;
amplitude = randFloat(amplitudeC)/5000;
force = GAR(forceC + (randFloat(50)/5000));
weight = MathFunc.randFloat(1)/5000;
force += weight;
lifeTime = lifeTimeC;
red = redC;
green = greenC;
blue = blueC;
};
/************************
PUBLIC METHODS
************************/
bool Particle::update(){
if (!checkLife()){return false;}
X += amplitude;
Y += force;
};
bool Particle::checkLife(){
if (!(lifeTime--)){return false;}
return true;
};
/************************
PRIVATE METHODS
************************/
float Particle::randFloat(float max){
if (rand()%2){
return -(MathFunc.randFloat(max));
}else{
return MathFunc.randFloat(max);
}
};
float Particle::GAR(float max){
if (rand()%2){
return (-max);
}else{
return max;
}
};