author | koda |
Wed, 22 Sep 2010 02:22:15 +0200 | |
changeset 3893 | 568bfd083465 |
parent 3764 | eb91c02f2d84 |
child 3909 | 4ba25a3d15af |
permissions | -rw-r--r-- |
3441 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2004-2010 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
18 |
procedure doStepFlake(Gear: PVisualGear; Steps: Longword); |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
19 |
var sign: float; |
3441 | 20 |
begin |
3641 | 21 |
if vobCount = 0 then exit; |
3611 | 22 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
23 |
sign:= 1; |
3441 | 24 |
with Gear^ do |
25 |
begin |
|
26 |
inc(FrameTicks, Steps); |
|
27 |
if FrameTicks > vobFrameTicks then |
|
28 |
begin |
|
29 |
dec(FrameTicks, vobFrameTicks); |
|
30 |
inc(Frame); |
|
31 |
if Frame = vobFramesCount then Frame:= 0 |
|
32 |
end; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
33 |
X:= X + (cWindSpeedf * 200 + dX + tdX) * Steps; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
34 |
Y:= Y + (dY + tdY + cGravityf * vobFallSpeed) * Steps; |
3441 | 35 |
Angle:= Angle + dAngle * Steps; |
36 |
||
3764 | 37 |
if (round(X) >= cLeftScreenBorder) and |
38 |
(round(X) <= cRightScreenBorder) and |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
39 |
(round(Y) <= (LAND_HEIGHT + 75)) and |
3441 | 40 |
(Timer > 0) and (Timer-Steps > 0) then |
41 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
42 |
if tdX > 0 then sign := 1 |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
43 |
else sign:= -1; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
44 |
tdX:= tdX - 0.005*Steps*sign; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
45 |
if ((sign < 0) and (tdX > 0)) or ((sign > 0) and (tdX < 0)) then tdX:= 0; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
46 |
if tdX > 0 then sign := 1 |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
47 |
else sign:= -1; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
48 |
tdY:= tdY - 0.005*Steps*sign; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
49 |
if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then tdY:= 0; |
3441 | 50 |
dec(Timer, Steps) |
51 |
end |
|
52 |
else |
|
53 |
begin |
|
3764 | 54 |
if round(X) < cLeftScreenBorder then X:= X + cScreenSpace else |
55 |
if round(X) > cRightScreenBorder then X:= X - cScreenSpace; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
56 |
// if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + float(25); // For if flag is set for flakes rising upwards? |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
57 |
if round(Y) > (LAND_HEIGHT + 75) then Y:= Y - float(1024 + 150); // TODO - configure in theme (jellies for example could use limited range) |
3441 | 58 |
Timer:= 0; |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
59 |
tdX:= 0; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
60 |
tdY:= 0 |
3441 | 61 |
end; |
62 |
end; |
|
63 |
||
64 |
end; |
|
65 |
||
66 |
//////////////////////////////////////////////////////////////////////////////// |
|
67 |
procedure doStepBeeTrace(Gear: PVisualGear; Steps: Longword); |
|
68 |
begin |
|
69 |
if Gear^.FrameTicks > Steps then |
|
70 |
dec(Gear^.FrameTicks, Steps) |
|
71 |
else |
|
72 |
DeleteVisualGear(Gear); |
|
73 |
end; |
|
74 |
||
75 |
//////////////////////////////////////////////////////////////////////////////// |
|
76 |
procedure doStepCloud(Gear: PVisualGear; Steps: Longword); |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
77 |
var s: Longword; |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
78 |
t: float; |
3441 | 79 |
begin |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
80 |
Gear^.X:= Gear^.X + (cWindSpeedf * 200 + Gear^.dX) * Steps; |
3441 | 81 |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
82 |
// up-and-down-bounce magic |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
83 |
s := (GameTicks + Gear^.Timer) mod 4096; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
84 |
t := 8 * AngleSin(s mod 2048).QWordValue / 4294967296; |
3597
978c30ef50fc
visual gears: fixing nemo's c-style assignment/multiplications
sheepluva
parents:
3593
diff
changeset
|
85 |
if (s < 2048) then t := -t; |
3441 | 86 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
87 |
Gear^.Y := LAND_HEIGHT-1184 + Gear^.Timer mod 8 + t; |
3441 | 88 |
|
3764 | 89 |
if round(Gear^.X) < cLeftScreenBorder then Gear^.X:= Gear^.X + cScreenSpace else |
90 |
if round(Gear^.X) > cRightScreenBorder then Gear^.X:= Gear^.X - cScreenSpace |
|
3441 | 91 |
end; |
92 |
||
93 |
//////////////////////////////////////////////////////////////////////////////// |
|
94 |
procedure doStepExpl(Gear: PVisualGear; Steps: Longword); |
|
95 |
begin |
|
96 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
97 |
||
98 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
99 |
//Gear^.dY:= Gear^.dY + cGravityf; |
3441 | 100 |
|
101 |
if Gear^.FrameTicks <= Steps then |
|
102 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
103 |
else |
|
104 |
begin |
|
105 |
dec(Gear^.Frame); |
|
106 |
Gear^.FrameTicks:= cExplFrameTicks |
|
107 |
end |
|
108 |
else dec(Gear^.FrameTicks, Steps) |
|
109 |
end; |
|
110 |
||
111 |
//////////////////////////////////////////////////////////////////////////////// |
|
3704 | 112 |
procedure doStepNote(Gear: PVisualGear; Steps: Longword); |
113 |
begin |
|
114 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
115 |
||
116 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3706 | 117 |
Gear^.dY:= Gear^.dY + cGravityf * Steps / 2; |
3704 | 118 |
|
3706 | 119 |
Gear^.Angle:= Gear^.Angle + (Gear^.Frame + 1) * Steps / 10; |
120 |
while Gear^.Angle > cMaxAngle do |
|
121 |
Gear^.Angle:= Gear^.Angle - cMaxAngle; |
|
3704 | 122 |
|
123 |
if Gear^.FrameTicks <= Steps then |
|
124 |
DeleteVisualGear(Gear) |
|
125 |
else |
|
126 |
dec(Gear^.FrameTicks, Steps) |
|
127 |
end; |
|
128 |
||
129 |
//////////////////////////////////////////////////////////////////////////////// |
|
3441 | 130 |
procedure doStepEgg(Gear: PVisualGear; Steps: Longword); |
131 |
begin |
|
132 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
133 |
||
134 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
135 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 136 |
|
137 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
138 |
||
139 |
if Gear^.FrameTicks <= Steps then |
|
140 |
DeleteVisualGear(Gear) |
|
141 |
else |
|
142 |
dec(Gear^.FrameTicks, Steps) |
|
143 |
end; |
|
144 |
||
145 |
//////////////////////////////////////////////////////////////////////////////// |
|
146 |
procedure doStepFire(Gear: PVisualGear; Steps: Longword); |
|
3751 | 147 |
var vgt: PVisualGear; |
3441 | 148 |
begin |
149 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
150 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
151 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravityf * (Steps * Steps); |
3751 | 152 |
if (Gear^.State and gstTmpFlag) = 0 then |
153 |
begin |
|
154 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
|
3764 | 155 |
if ((GameTicks mod 200) < Steps + 1) then |
3751 | 156 |
begin |
157 |
vgt:= AddVisualGear(round(Gear^.X), round(Gear^.Y), vgtFire); |
|
158 |
if vgt <> nil then |
|
159 |
begin |
|
160 |
vgt^.dx:= 0; |
|
161 |
vgt^.dy:= 0; |
|
162 |
vgt^.State:= gstTmpFlag; |
|
163 |
end; |
|
164 |
end |
|
165 |
end |
|
166 |
else |
|
167 |
inc(Steps, Steps); |
|
3441 | 168 |
|
169 |
if Gear^.FrameTicks <= Steps then |
|
170 |
DeleteVisualGear(Gear) |
|
171 |
else |
|
172 |
dec(Gear^.FrameTicks, Steps) |
|
173 |
end; |
|
174 |
||
175 |
//////////////////////////////////////////////////////////////////////////////// |
|
176 |
procedure doStepShell(Gear: PVisualGear; Steps: Longword); |
|
177 |
begin |
|
178 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
179 |
||
180 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
181 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 182 |
|
183 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
184 |
||
185 |
if Gear^.FrameTicks <= Steps then |
|
186 |
DeleteVisualGear(Gear) |
|
187 |
else |
|
188 |
dec(Gear^.FrameTicks, Steps) |
|
189 |
end; |
|
190 |
||
191 |
procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword); |
|
192 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
193 |
Gear^.Y:= Gear^.Y - 0.02 * Steps; |
3441 | 194 |
|
195 |
if Gear^.FrameTicks <= Steps then |
|
196 |
DeleteVisualGear(Gear) |
|
197 |
else |
|
198 |
dec(Gear^.FrameTicks, Steps) |
|
199 |
end; |
|
200 |
||
201 |
//////////////////////////////////////////////////////////////////////////////// |
|
202 |
procedure doStepBubble(Gear: PVisualGear; Steps: Longword); |
|
203 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
204 |
Gear^.X:= Gear^.X + (cWindSpeedf * 100 + Gear^.dX) * Steps; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
205 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 206 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
207 |
if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then |
3441 | 208 |
DeleteVisualGear(Gear) |
209 |
else |
|
210 |
dec(Gear^.FrameTicks, Steps) |
|
211 |
end; |
|
212 |
||
213 |
//////////////////////////////////////////////////////////////////////////////// |
|
214 |
procedure doStepHealth(Gear: PVisualGear; Steps: Longword); |
|
215 |
begin |
|
216 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
217 |
Gear^.Y:= Gear^.Y - Gear^.dY * Steps; |
|
218 |
||
219 |
if Gear^.FrameTicks <= Steps then |
|
220 |
DeleteVisualGear(Gear) |
|
221 |
else |
|
222 |
dec(Gear^.FrameTicks, Steps); |
|
223 |
end; |
|
224 |
||
225 |
//////////////////////////////////////////////////////////////////////////////// |
|
226 |
procedure doStepSteam(Gear: PVisualGear; Steps: Longword); |
|
227 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
228 |
Gear^.X:= Gear^.X + (cWindSpeedf * 100 + Gear^.dX) * Steps; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
229 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 230 |
|
231 |
if Gear^.FrameTicks <= Steps then |
|
232 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
233 |
else |
|
234 |
begin |
|
235 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
236 |
Gear^.FrameTicks:= cExplFrameTicks |
|
237 |
end |
|
238 |
else dec(Gear^.FrameTicks, Steps) |
|
239 |
end; |
|
240 |
||
241 |
//////////////////////////////////////////////////////////////////////////////// |
|
242 |
procedure doStepAmmo(Gear: PVisualGear; Steps: Longword); |
|
243 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
244 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 245 |
|
246 |
Gear^.scale:= Gear^.scale + 0.0025 * Steps; |
|
247 |
Gear^.alpha:= Gear^.alpha - 0.0015 * Steps; |
|
248 |
||
249 |
if Gear^.alpha < 0 then DeleteVisualGear(Gear) |
|
250 |
end; |
|
251 |
||
252 |
//////////////////////////////////////////////////////////////////////////////// |
|
253 |
procedure doStepSmoke(Gear: PVisualGear; Steps: Longword); |
|
254 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
255 |
Gear^.X:= Gear^.X + (cWindSpeedf + Gear^.dX) * Steps; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
256 |
Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps; |
3441 | 257 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
258 |
Gear^.dX := Gear^.dX + (cWindSpeedf * 0.3 * Steps); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
259 |
//Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995); |
3441 | 260 |
|
261 |
if Gear^.FrameTicks <= Steps then |
|
262 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
263 |
else |
|
264 |
begin |
|
265 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
266 |
Gear^.FrameTicks:= cExplFrameTicks |
|
267 |
end |
|
268 |
else dec(Gear^.FrameTicks, Steps) |
|
269 |
end; |
|
270 |
||
271 |
//////////////////////////////////////////////////////////////////////////////// |
|
272 |
procedure doStepDust(Gear: PVisualGear; Steps: Longword); |
|
273 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
274 |
Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps; |
3441 | 275 |
Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; |
276 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
277 |
Gear^.dX := Gear^.dX - (Gear^.dX * 0.005 * Steps); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
278 |
Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps); |
3441 | 279 |
|
280 |
if Gear^.FrameTicks <= Steps then |
|
281 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
282 |
else |
|
283 |
begin |
|
284 |
dec(Gear^.Frame); |
|
285 |
Gear^.FrameTicks:= cExplFrameTicks |
|
286 |
end |
|
287 |
else dec(Gear^.FrameTicks, Steps) |
|
288 |
end; |
|
289 |
||
290 |
//////////////////////////////////////////////////////////////////////////////// |
|
291 |
procedure doStepSplash(Gear: PVisualGear; Steps: Longword); |
|
292 |
begin |
|
293 |
if Gear^.FrameTicks <= Steps then |
|
294 |
DeleteVisualGear(Gear) |
|
295 |
else |
|
296 |
dec(Gear^.FrameTicks, Steps); |
|
297 |
end; |
|
298 |
||
299 |
//////////////////////////////////////////////////////////////////////////////// |
|
300 |
procedure doStepDroplet(Gear: PVisualGear; Steps: Longword); |
|
301 |
begin |
|
302 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
303 |
||
304 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
305 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 306 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
307 |
if round(Gear^.Y) > cWaterLine then begin |
3441 | 308 |
DeleteVisualGear(Gear); |
309 |
PlaySound(TSound(ord(sndDroplet1) + Random(3))); |
|
310 |
end; |
|
311 |
end; |
|
312 |
||
313 |
//////////////////////////////////////////////////////////////////////////////// |
|
314 |
procedure doStepSmokeRing(Gear: PVisualGear; Steps: Longword); |
|
315 |
begin |
|
316 |
inc(Gear^.Timer, Steps); |
|
317 |
if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear) |
|
318 |
else |
|
319 |
begin |
|
320 |
Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4; |
|
321 |
Gear^.alpha := 1 - power(Gear^.Timer / 350, 4); |
|
322 |
if Gear^.alpha < 0 then Gear^.alpha:= 0; |
|
323 |
end; |
|
324 |
end; |
|
325 |
||
326 |
//////////////////////////////////////////////////////////////////////////////// |
|
327 |
procedure doStepFeather(Gear: PVisualGear; Steps: Longword); |
|
328 |
begin |
|
329 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
330 |
||
331 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
332 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 333 |
|
334 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
335 |
||
336 |
if Gear^.FrameTicks <= Steps then |
|
337 |
DeleteVisualGear(Gear) |
|
338 |
else |
|
339 |
dec(Gear^.FrameTicks, Steps) |
|
340 |
end; |
|
341 |
||
342 |
//////////////////////////////////////////////////////////////////////////////// |
|
343 |
const cSorterWorkTime = 640; |
|
344 |
var thexchar: array[0..cMaxTeams] of |
|
345 |
record |
|
346 |
dy, ny, dw: LongInt; |
|
347 |
team: PTeam; |
|
348 |
SortFactor: QWord; |
|
349 |
end; |
|
350 |
currsorter: PVisualGear = nil; |
|
351 |
||
352 |
procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword); |
|
353 |
var i, t: LongInt; |
|
354 |
begin |
|
355 |
for t:= 1 to Steps do |
|
356 |
begin |
|
357 |
dec(Gear^.Timer); |
|
358 |
if (Gear^.Timer and 15) = 0 then |
|
359 |
for i:= 0 to Pred(TeamsCount) do |
|
360 |
with thexchar[i] do |
|
361 |
begin |
|
362 |
{$WARNINGS OFF} |
|
363 |
team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div 640; |
|
364 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime; |
|
365 |
{$WARNINGS ON} |
|
366 |
end; |
|
367 |
||
368 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
|
369 |
begin |
|
370 |
if currsorter = Gear then currsorter:= nil; |
|
371 |
DeleteVisualGear(Gear); |
|
372 |
exit |
|
373 |
end |
|
374 |
end |
|
375 |
end; |
|
376 |
||
377 |
procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword); |
|
378 |
var i: Longword; |
|
379 |
b: boolean; |
|
380 |
t: LongInt; |
|
381 |
begin |
|
382 |
Steps:= Steps; // avoid compiler hint |
|
383 |
for t:= 0 to Pred(TeamsCount) do |
|
384 |
with thexchar[t] do |
|
385 |
begin |
|
386 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
387 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
388 |
team:= TeamsArray[t]; |
|
389 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
390 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
391 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
392 |
end; |
|
393 |
||
394 |
if TeamsCount > 1 then |
|
395 |
repeat |
|
396 |
b:= true; |
|
397 |
for t:= 0 to TeamsCount - 2 do |
|
398 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
399 |
begin |
|
400 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
401 |
thexchar[t]:= thexchar[Succ(t)]; |
|
402 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
403 |
b:= false |
|
404 |
end |
|
405 |
until b; |
|
406 |
||
407 |
t:= - 4; |
|
408 |
for i:= 0 to Pred(TeamsCount) do |
|
409 |
with thexchar[i] do |
|
410 |
begin |
|
411 |
dec(t, team^.HealthTex^.h + 2); |
|
412 |
ny:= t; |
|
413 |
dy:= dy - ny |
|
414 |
end; |
|
415 |
||
416 |
Gear^.Timer:= cSorterWorkTime; |
|
417 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
418 |
currsorter:= Gear; |
|
419 |
//doStepTeamHealthSorterWork(Gear, Steps) |
|
420 |
end; |
|
421 |
||
422 |
//////////////////////////////////////////////////////////////////////////////// |
|
423 |
procedure doStepSpeechBubbleWork(Gear: PVisualGear; Steps: Longword); |
|
424 |
begin |
|
425 |
if Gear^.Timer > Steps then dec(Gear^.Timer, Steps) else Gear^.Timer:= 0; |
|
426 |
||
427 |
if (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then |
|
428 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
429 |
Gear^.X:= PHedgehog(Gear^.Hedgehog)^.Gear^.X.QWordValue/4294967296 + (Gear^.Tex^.w div 2 - Gear^.FrameTicks); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
430 |
Gear^.Y:= PHedgehog(Gear^.Hedgehog)^.Gear^.Y.QWordValue/4294967296 - (16 + Gear^.Tex^.h); |
3441 | 431 |
end; |
432 |
||
433 |
if Gear^.Timer = 0 then |
|
434 |
begin |
|
435 |
if PHedgehog(Gear^.Hedgehog)^.SpeechGear = Gear then |
|
436 |
PHedgehog(Gear^.Hedgehog)^.SpeechGear:= nil; |
|
437 |
DeleteVisualGear(Gear) |
|
438 |
end; |
|
439 |
end; |
|
440 |
||
441 |
procedure doStepSpeechBubble(Gear: PVisualGear; Steps: Longword); |
|
442 |
begin |
|
443 |
Steps:= Steps; // avoid compiler hint |
|
444 |
||
445 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
446 |
if SpeechGear <> nil then SpeechGear^.Timer:= 0; |
|
447 |
||
448 |
PHedgehog(Gear^.Hedgehog)^.SpeechGear:= Gear; |
|
449 |
||
450 |
Gear^.Timer:= max(Length(Gear^.Text) * 150, 3000); |
|
451 |
||
452 |
Gear^.Tex:= RenderSpeechBubbleTex(Gear^.Text, Gear^.FrameTicks, fnt16); |
|
453 |
||
454 |
case Gear^.FrameTicks of |
|
455 |
1: Gear^.FrameTicks:= SpritesData[sprSpeechTail].Width-28; |
|
456 |
2: Gear^.FrameTicks:= SpritesData[sprThoughtTail].Width-20; |
|
457 |
3: Gear^.FrameTicks:= SpritesData[sprShoutTail].Width-10; |
|
458 |
end; |
|
459 |
||
460 |
Gear^.doStep:= @doStepSpeechBubbleWork; |
|
461 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
462 |
Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h) |
3441 | 463 |
end; |
464 |
||
465 |
//////////////////////////////////////////////////////////////////////////////// |
|
466 |
procedure doStepHealthTagWork(Gear: PVisualGear; Steps: Longword); |
|
467 |
begin |
|
468 |
if Steps > Gear^.Timer then |
|
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
469 |
DeleteVisualGear(Gear) |
3441 | 470 |
else |
471 |
begin |
|
472 |
dec(Gear^.Timer, Steps); |
|
473 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
474 |
end; |
|
475 |
end; |
|
476 |
||
477 |
procedure doStepHealthTagWorkUnderWater(Gear: PVisualGear; Steps: Longword); |
|
478 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
479 |
if round(Gear^.Y) < cWaterLine + 10 then |
3441 | 480 |
DeleteVisualGear(Gear) |
481 |
else |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
482 |
Gear^.Y:= Gear^.Y - 0.08 * Steps; |
3441 | 483 |
|
484 |
end; |
|
485 |
||
486 |
procedure doStepHealthTag(Gear: PVisualGear; Steps: Longword); |
|
487 |
var s: shortstring; |
|
488 |
begin |
|
489 |
s:= ''; |
|
490 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
491 |
Gear^.dY:= -0.08; |
3441 | 492 |
|
493 |
str(Gear^.State, s); |
|
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
494 |
if Gear^.Hedgehog <> nil then |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
495 |
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16) |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
496 |
else |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
497 |
Gear^.Tex:= RenderStringTex(s, cWhiteColor, fnt16); |
3441 | 498 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
499 |
if round(Gear^.Y) < cWaterLine then |
3441 | 500 |
Gear^.doStep:= @doStepHealthTagWork |
501 |
else |
|
502 |
Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
|
503 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
504 |
Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h); |
3441 | 505 |
|
506 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
507 |
end; |
|
508 |
||
509 |
//////////////////////////////////////////////////////////////////////////////// |
|
510 |
procedure doStepSmokeTrace(Gear: PVisualGear; Steps: Longword); |
|
511 |
begin |
|
512 |
inc(Gear^.Timer, Steps ); |
|
513 |
if Gear^.Timer > 64 then |
|
514 |
begin |
|
515 |
dec(Gear^.State, Gear^.Timer div 65); |
|
516 |
Gear^.Timer:= Gear^.Timer mod 65; |
|
517 |
end; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
518 |
Gear^.dX:= Gear^.dX + cWindSpeedf * Steps; |
3587 | 519 |
Gear^.X:= Gear^.X + Gear^.dX; |
3441 | 520 |
if Gear^.State = 0 then DeleteVisualGear(Gear); |
521 |
end; |
|
522 |
||
523 |
//////////////////////////////////////////////////////////////////////////////// |
|
524 |
procedure doStepExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
525 |
begin |
|
526 |
inc(Gear^.Timer, Steps); |
|
527 |
if Gear^.Timer > 75 then |
|
528 |
begin |
|
529 |
inc(Gear^.State, Gear^.Timer div 76); |
|
530 |
Gear^.Timer:= Gear^.Timer mod 76; |
|
531 |
if Gear^.State > 5 then DeleteVisualGear(Gear); |
|
532 |
end; |
|
533 |
end; |
|
534 |
||
535 |
procedure doStepExplosion(Gear: PVisualGear; Steps: Longword); |
|
536 |
var i: LongWord; |
|
3590 | 537 |
gX,gY: LongInt; |
3441 | 538 |
begin |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
539 |
gX:= round(Gear^.X); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
540 |
gY:= round(Gear^.Y); |
3590 | 541 |
for i:= 0 to 31 do AddVisualGear(gX, gY, vgtFire); |
542 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart); |
|
543 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart2); |
|
3441 | 544 |
Gear^.doStep:= @doStepExplosionWork; |
545 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
546 |
end; |
|
547 |
||
548 |
||
549 |
//////////////////////////////////////////////////////////////////////////////// |
|
550 |
procedure doStepBigExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
3587 | 551 |
//var maxMovement: LongInt; |
3441 | 552 |
begin |
553 |
||
554 |
inc(Gear^.Timer, Steps); |
|
3466
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
555 |
(* |
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
556 |
FIXME - This block desyncs due to the way WorldDx is important for various things network related. |
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
557 |
One possible solution is, instead of using WorldDx, to use straight gl/SDL calls to jitter the screen a bit. |
3441 | 558 |
if (Gear^.Timer and 5) = 0 then |
559 |
begin |
|
560 |
maxMovement := max(1, 13 - ((Gear^.Timer * 15) div 250)); |
|
561 |
ShakeCamera(maxMovement); |
|
562 |
end; |
|
3466
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
563 |
*) |
3441 | 564 |
if Gear^.Timer > 250 then DeleteVisualGear(Gear); |
565 |
end; |
|
566 |
||
567 |
procedure doStepBigExplosion(Gear: PVisualGear; Steps: Longword); |
|
568 |
var i: LongWord; |
|
569 |
gX,gY: LongInt; |
|
570 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
571 |
gX:= round(Gear^.X); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
572 |
gY:= round(Gear^.Y); |
3441 | 573 |
AddVisualGear(gX, gY, vgtSmokeRing); |
574 |
for i:= 0 to 46 do AddVisualGear(gX, gY, vgtFire); |
|
575 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart); |
|
576 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart2); |
|
577 |
Gear^.doStep:= @doStepBigExplosionWork; |
|
578 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
579 |
end; |
|
3689 | 580 |
|
581 |
procedure doStepChunk(Gear: PVisualGear; Steps: Longword); |
|
582 |
begin |
|
583 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
584 |
||
585 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
586 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
|
587 |
||
588 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
589 |
||
590 |
if round(Gear^.Y) > cWaterLine then |
|
591 |
begin |
|
3699 | 592 |
AddVisualGear(round(Gear^.X), round(Gear^.Y), vgtDroplet); |
3689 | 593 |
DeleteVisualGear(Gear); |
594 |
end |
|
595 |
end; |