-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathparticles.h
233 lines (195 loc) · 5.6 KB
/
particles.h
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/* --------------------------------------------------------------------
EXTREME TUXRACER
Copyright (C) 1999-2001 Jasmin F. Patry (Tuxracer)
Copyright (C) 2010 Extreme Tuxracer Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
---------------------------------------------------------------------*/
#ifndef PARTICLES_H
#define PARTICLES_H
#include "bh.h"
// --------------------------------------------------------------------
// snow for menu screens
// --------------------------------------------------------------------
void init_ui_snow (void );
void update_ui_snow (double time_step);
void push_ui_snow (TVector2 pos );
void draw_ui_snow (void );
void make_ui_snow (TVector2 pos );
void reset_ui_snow_cursor_pos (TVector2 pos );
// --------------------------------------------------------------------
// snow particles during race
// --------------------------------------------------------------------
void create_new_particles (TVector3 loc, TVector3 vel, int num );
void update_particles (double time_step );
void clear_particles ();
void draw_particles (CControl *ctrl );
void generate_particles (CControl *ctrl, double dtime, TVector3 pos, double speed);
// --------------------------------------------------------------------
// snow flakes for short distances
// --------------------------------------------------------------------
#define MAX_FLAKEAREAS 6
typedef struct {
TVector3 pt;
float size;
TVector3 vel;
TVector2 tex_min;
TVector2 tex_max;
} TFlake;
typedef struct {
int num_flakes;
float xrange;
float ytop;
float yrange;
float zback;
float zrange;
float minSize;
float maxSize;
float speed;
bool rotate_flake;
float left;
float right;
float bottom;
float top;
float front;
float back;
TFlake *flakes;
} TFlakeArea;
class CFlakes {
private:
TVector3 snow_lastpos;
TFlakeArea areas[MAX_FLAKEAREAS];
int numAreas;
void MakeSnowFlake (int ar, int i);
void GenerateSnowFlakes (CControl *ctrl);
void UpdateAreas (CControl *ctrl);
void DrawArea (int ar, CControl *ctrl);
void CreateArea (
int num_flakes,
float xrange,
float ytop,
float yrange,
float zback,
float zrange,
float minSize,
float maxSize,
float speed,
bool rotate);
public:
CFlakes ();
~CFlakes ();
void Init (int grade, CControl *ctrl);
void Reset ();
void Update (double timestep, CControl *ctrl);
void Draw (CControl *ctrl);
};
// --------------------------------------------------------------------
// snow clouds for medium distances
// --------------------------------------------------------------------
// intended for future versions
// --------------------------------------------------------------------
// snow curtains for greater distances
// --------------------------------------------------------------------
#define MAX_CURTAIN_COLS 16
#define MAX_CURTAIN_ROWS 8
#define MAX_CURTAINS 6
typedef struct {
TVector3 pt;
float angle;
float height;
float zrandom;
} TCurtainElement;
class CCurtain {
private:
TCurtainElement curtains[MAX_CURTAINS][MAX_CURTAIN_COLS][MAX_CURTAIN_ROWS];
int numCols[MAX_CURTAINS];
int numRows[MAX_CURTAINS];
float zdist[MAX_CURTAINS];
float size[MAX_CURTAINS];
float speed[MAX_CURTAINS];
float angledist[MAX_CURTAINS];
float startangle[MAX_CURTAINS];
float lastangle[MAX_CURTAINS];
float minheight[MAX_CURTAINS];
bool enabled[MAX_CURTAINS];
int texture[MAX_CURTAINS];
int chg[MAX_CURTAINS][MAX_CURTAIN_ROWS]; // for each row
void GenerateCurtain (
int nr,
int num_rows,
float z_dist,
float tex_size,
float base_speed,
float start_angle,
float min_height,
int curt_texture);
void SetStartParams (CControl *ctrl);
void CurtainVec (float angle, float zdist, float &x, float &z);
public:
CCurtain ();
~CCurtain ();
void Init (CControl *ctrl);
void Update (float timestep, CControl *ctrl);
void Draw (CControl *ctrl);
void Reset ();
};
// --------------------------------------------------------------------
// wind
// --------------------------------------------------------------------
typedef struct {
float minSpeed;
float maxSpeed;
float minChange;
float maxChange;
float minAngle;
float maxAngle;
float minAngleChange;
float maxAngleChange;
float topSpeed;
float topProbability;
float nullProbability;
} TWindParams;
class CWind {
private:
bool windy;
float CurrTime;
TWindParams params;
// if dest > curr state the modes are 1, otherwise 0
int SpeedMode;
int AngleMode;
float WSpeed;
float WAngle;
TVector3 WVector;
float DestSpeed;
float DestAngle;
float WindChange;
float AngleChange;
void SetParams (int grade);
void CalcDestSpeed ();
void CalcDestAngle ();
public:
CWind ();
~CWind ();
void Update (float timestep);
void Init (int wind_id);
bool Windy () { return windy; }
float Angle () { return WAngle; }
float Speed () { return WSpeed; }
TVector3 WindDrift () { return WVector; }
};
extern CWind Wind;
// --------------------------------------------------------------------
// Acess functions
// --------------------------------------------------------------------
void InitSnow (CControl *ctrl);
void UpdateSnow (double timestep, CControl *ctrl);
void DrawSnow (CControl *ctrl);
void InitWind ();
void UpdateWind (double timestep, CControl *ctrl);
#endif