author | sheepluva |
Wed, 30 Jun 2010 22:20:52 +0200 | |
changeset 3597 | 978c30ef50fc |
parent 3593 | ae50f63e4fa9 |
child 3611 | ed00aa2b339e |
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 |
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
|
21 |
sign:= 1; |
3441 | 22 |
with Gear^ do |
23 |
begin |
|
24 |
inc(FrameTicks, Steps); |
|
25 |
if FrameTicks > vobFrameTicks then |
|
26 |
begin |
|
27 |
dec(FrameTicks, vobFrameTicks); |
|
28 |
inc(Frame); |
|
29 |
if Frame = vobFramesCount then Frame:= 0 |
|
30 |
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
|
31 |
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
|
32 |
Y:= Y + (dY + tdY + cGravityf * vobFallSpeed) * Steps; |
3441 | 33 |
Angle:= Angle + dAngle * Steps; |
34 |
||
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
|
35 |
if (round(X) >= -cScreenWidth - 64) and |
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
|
36 |
(round(X) <= cScreenWidth + LAND_WIDTH) and |
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
|
37 |
(round(Y) <= (LAND_HEIGHT + 75)) and |
3441 | 38 |
(Timer > 0) and (Timer-Steps > 0) then |
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then tdY:= 0; |
3441 | 48 |
dec(Timer, Steps) |
49 |
end |
|
50 |
else |
|
51 |
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
|
52 |
if round(X) < -cScreenWidth - 64 then X:= float(cScreenWidth + LAND_WIDTH) else |
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
|
53 |
if round(X) > cScreenWidth + LAND_WIDTH then X:= float(-cScreenWidth - 64); |
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
|
54 |
// 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
|
55 |
if round(Y) > (LAND_HEIGHT + 75) then Y:= Y - float(1024 + 150); // TODO - configure in theme (jellies for example could use limited range) |
3441 | 56 |
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
|
57 |
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
|
58 |
tdY:= 0 |
3441 | 59 |
end; |
60 |
end; |
|
61 |
||
62 |
end; |
|
63 |
||
64 |
//////////////////////////////////////////////////////////////////////////////// |
|
65 |
procedure doStepBeeTrace(Gear: PVisualGear; Steps: Longword); |
|
66 |
begin |
|
67 |
if Gear^.FrameTicks > Steps then |
|
68 |
dec(Gear^.FrameTicks, Steps) |
|
69 |
else |
|
70 |
DeleteVisualGear(Gear); |
|
71 |
end; |
|
72 |
||
73 |
//////////////////////////////////////////////////////////////////////////////// |
|
74 |
procedure doStepCloud(Gear: PVisualGear; Steps: Longword); |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
75 |
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
|
76 |
t: float; |
3441 | 77 |
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
|
78 |
Gear^.X:= Gear^.X + (cWindSpeedf * 200 + Gear^.dX) * Steps; |
3441 | 79 |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
80 |
// 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
|
81 |
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
|
82 |
t := 8 * AngleSin(s mod 2048).QWordValue / 4294967296; |
3597
978c30ef50fc
visual gears: fixing nemo's c-style assignment/multiplications
sheepluva
parents:
3593
diff
changeset
|
83 |
if (s < 2048) then t := -t; |
3441 | 84 |
|
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
|
85 |
Gear^.Y := LAND_HEIGHT-1184 + Gear^.Timer mod 8 + 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 |
if round(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= float(cScreenWidth + LAND_WIDTH) else |
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
|
88 |
if round(Gear^.X) > cScreenWidth + LAND_WIDTH then Gear^.X:= float(-cScreenWidth - 256) |
3441 | 89 |
end; |
90 |
||
91 |
//////////////////////////////////////////////////////////////////////////////// |
|
92 |
procedure doStepExpl(Gear: PVisualGear; Steps: Longword); |
|
93 |
begin |
|
94 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
95 |
||
96 |
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
|
97 |
//Gear^.dY:= Gear^.dY + cGravityf; |
3441 | 98 |
|
99 |
if Gear^.FrameTicks <= Steps then |
|
100 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
101 |
else |
|
102 |
begin |
|
103 |
dec(Gear^.Frame); |
|
104 |
Gear^.FrameTicks:= cExplFrameTicks |
|
105 |
end |
|
106 |
else dec(Gear^.FrameTicks, Steps) |
|
107 |
end; |
|
108 |
||
109 |
//////////////////////////////////////////////////////////////////////////////// |
|
110 |
procedure doStepEgg(Gear: PVisualGear; Steps: Longword); |
|
111 |
begin |
|
112 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
113 |
||
114 |
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
|
115 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 116 |
|
117 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
118 |
||
119 |
if Gear^.FrameTicks <= Steps then |
|
120 |
DeleteVisualGear(Gear) |
|
121 |
else |
|
122 |
dec(Gear^.FrameTicks, Steps) |
|
123 |
end; |
|
124 |
||
125 |
//////////////////////////////////////////////////////////////////////////////// |
|
126 |
procedure doStepFire(Gear: PVisualGear; Steps: Longword); |
|
127 |
begin |
|
128 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
129 |
||
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
|
130 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravityf * (Steps * 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
|
131 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 132 |
|
133 |
if Gear^.FrameTicks <= Steps then |
|
134 |
DeleteVisualGear(Gear) |
|
135 |
else |
|
136 |
dec(Gear^.FrameTicks, Steps) |
|
137 |
end; |
|
138 |
||
139 |
//////////////////////////////////////////////////////////////////////////////// |
|
140 |
procedure doStepShell(Gear: PVisualGear; Steps: Longword); |
|
141 |
begin |
|
142 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
143 |
||
144 |
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
|
145 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 146 |
|
147 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
148 |
||
149 |
if Gear^.FrameTicks <= Steps then |
|
150 |
DeleteVisualGear(Gear) |
|
151 |
else |
|
152 |
dec(Gear^.FrameTicks, Steps) |
|
153 |
end; |
|
154 |
||
155 |
procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword); |
|
156 |
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
|
157 |
Gear^.Y:= Gear^.Y - 0.02 * Steps; |
3441 | 158 |
|
159 |
if Gear^.FrameTicks <= Steps then |
|
160 |
DeleteVisualGear(Gear) |
|
161 |
else |
|
162 |
dec(Gear^.FrameTicks, Steps) |
|
163 |
end; |
|
164 |
||
165 |
//////////////////////////////////////////////////////////////////////////////// |
|
166 |
procedure doStepBubble(Gear: PVisualGear; Steps: Longword); |
|
167 |
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
|
168 |
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
|
169 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 170 |
|
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
|
171 |
if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then |
3441 | 172 |
DeleteVisualGear(Gear) |
173 |
else |
|
174 |
dec(Gear^.FrameTicks, Steps) |
|
175 |
end; |
|
176 |
||
177 |
//////////////////////////////////////////////////////////////////////////////// |
|
178 |
procedure doStepHealth(Gear: PVisualGear; Steps: Longword); |
|
179 |
begin |
|
180 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
181 |
Gear^.Y:= Gear^.Y - Gear^.dY * Steps; |
|
182 |
||
183 |
if Gear^.FrameTicks <= Steps then |
|
184 |
DeleteVisualGear(Gear) |
|
185 |
else |
|
186 |
dec(Gear^.FrameTicks, Steps); |
|
187 |
end; |
|
188 |
||
189 |
//////////////////////////////////////////////////////////////////////////////// |
|
190 |
procedure doStepSteam(Gear: PVisualGear; Steps: Longword); |
|
191 |
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
|
192 |
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
|
193 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 194 |
|
195 |
if Gear^.FrameTicks <= Steps then |
|
196 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
197 |
else |
|
198 |
begin |
|
199 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
200 |
Gear^.FrameTicks:= cExplFrameTicks |
|
201 |
end |
|
202 |
else dec(Gear^.FrameTicks, Steps) |
|
203 |
end; |
|
204 |
||
205 |
//////////////////////////////////////////////////////////////////////////////// |
|
206 |
procedure doStepAmmo(Gear: PVisualGear; Steps: Longword); |
|
207 |
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
|
208 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 209 |
|
210 |
Gear^.scale:= Gear^.scale + 0.0025 * Steps; |
|
211 |
Gear^.alpha:= Gear^.alpha - 0.0015 * Steps; |
|
212 |
||
213 |
if Gear^.alpha < 0 then DeleteVisualGear(Gear) |
|
214 |
end; |
|
215 |
||
216 |
//////////////////////////////////////////////////////////////////////////////// |
|
217 |
procedure doStepSmoke(Gear: PVisualGear; Steps: Longword); |
|
218 |
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
|
219 |
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
|
220 |
Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps; |
3441 | 221 |
|
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
|
222 |
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
|
223 |
//Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995); |
3441 | 224 |
|
225 |
if Gear^.FrameTicks <= Steps then |
|
226 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
227 |
else |
|
228 |
begin |
|
229 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
230 |
Gear^.FrameTicks:= cExplFrameTicks |
|
231 |
end |
|
232 |
else dec(Gear^.FrameTicks, Steps) |
|
233 |
end; |
|
234 |
||
235 |
//////////////////////////////////////////////////////////////////////////////// |
|
236 |
procedure doStepDust(Gear: PVisualGear; Steps: Longword); |
|
237 |
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
|
238 |
Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps; |
3441 | 239 |
Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; |
240 |
||
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
|
241 |
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
|
242 |
Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps); |
3441 | 243 |
|
244 |
if Gear^.FrameTicks <= Steps then |
|
245 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
246 |
else |
|
247 |
begin |
|
248 |
dec(Gear^.Frame); |
|
249 |
Gear^.FrameTicks:= cExplFrameTicks |
|
250 |
end |
|
251 |
else dec(Gear^.FrameTicks, Steps) |
|
252 |
end; |
|
253 |
||
254 |
//////////////////////////////////////////////////////////////////////////////// |
|
255 |
procedure doStepSplash(Gear: PVisualGear; Steps: Longword); |
|
256 |
begin |
|
257 |
if Gear^.FrameTicks <= Steps then |
|
258 |
DeleteVisualGear(Gear) |
|
259 |
else |
|
260 |
dec(Gear^.FrameTicks, Steps); |
|
261 |
end; |
|
262 |
||
263 |
//////////////////////////////////////////////////////////////////////////////// |
|
264 |
procedure doStepDroplet(Gear: PVisualGear; Steps: Longword); |
|
265 |
begin |
|
266 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
267 |
||
268 |
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
|
269 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 270 |
|
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
|
271 |
if round(Gear^.Y) > cWaterLine then begin |
3441 | 272 |
DeleteVisualGear(Gear); |
273 |
PlaySound(TSound(ord(sndDroplet1) + Random(3))); |
|
274 |
end; |
|
275 |
end; |
|
276 |
||
277 |
//////////////////////////////////////////////////////////////////////////////// |
|
278 |
procedure doStepSmokeRing(Gear: PVisualGear; Steps: Longword); |
|
279 |
begin |
|
280 |
inc(Gear^.Timer, Steps); |
|
281 |
if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear) |
|
282 |
else |
|
283 |
begin |
|
284 |
Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4; |
|
285 |
Gear^.alpha := 1 - power(Gear^.Timer / 350, 4); |
|
286 |
if Gear^.alpha < 0 then Gear^.alpha:= 0; |
|
287 |
end; |
|
288 |
end; |
|
289 |
||
290 |
//////////////////////////////////////////////////////////////////////////////// |
|
291 |
procedure doStepFeather(Gear: PVisualGear; Steps: Longword); |
|
292 |
begin |
|
293 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
294 |
||
295 |
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
|
296 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 297 |
|
298 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
299 |
||
300 |
if Gear^.FrameTicks <= Steps then |
|
301 |
DeleteVisualGear(Gear) |
|
302 |
else |
|
303 |
dec(Gear^.FrameTicks, Steps) |
|
304 |
end; |
|
305 |
||
306 |
//////////////////////////////////////////////////////////////////////////////// |
|
307 |
const cSorterWorkTime = 640; |
|
308 |
var thexchar: array[0..cMaxTeams] of |
|
309 |
record |
|
310 |
dy, ny, dw: LongInt; |
|
311 |
team: PTeam; |
|
312 |
SortFactor: QWord; |
|
313 |
end; |
|
314 |
currsorter: PVisualGear = nil; |
|
315 |
||
316 |
procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword); |
|
317 |
var i, t: LongInt; |
|
318 |
begin |
|
319 |
for t:= 1 to Steps do |
|
320 |
begin |
|
321 |
dec(Gear^.Timer); |
|
322 |
if (Gear^.Timer and 15) = 0 then |
|
323 |
for i:= 0 to Pred(TeamsCount) do |
|
324 |
with thexchar[i] do |
|
325 |
begin |
|
326 |
{$WARNINGS OFF} |
|
327 |
team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div 640; |
|
328 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime; |
|
329 |
{$WARNINGS ON} |
|
330 |
end; |
|
331 |
||
332 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
|
333 |
begin |
|
334 |
if currsorter = Gear then currsorter:= nil; |
|
335 |
DeleteVisualGear(Gear); |
|
336 |
exit |
|
337 |
end |
|
338 |
end |
|
339 |
end; |
|
340 |
||
341 |
procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword); |
|
342 |
var i: Longword; |
|
343 |
b: boolean; |
|
344 |
t: LongInt; |
|
345 |
begin |
|
346 |
Steps:= Steps; // avoid compiler hint |
|
347 |
for t:= 0 to Pred(TeamsCount) do |
|
348 |
with thexchar[t] do |
|
349 |
begin |
|
350 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
351 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
352 |
team:= TeamsArray[t]; |
|
353 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
354 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
355 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
356 |
end; |
|
357 |
||
358 |
if TeamsCount > 1 then |
|
359 |
repeat |
|
360 |
b:= true; |
|
361 |
for t:= 0 to TeamsCount - 2 do |
|
362 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
363 |
begin |
|
364 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
365 |
thexchar[t]:= thexchar[Succ(t)]; |
|
366 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
367 |
b:= false |
|
368 |
end |
|
369 |
until b; |
|
370 |
||
371 |
t:= - 4; |
|
372 |
for i:= 0 to Pred(TeamsCount) do |
|
373 |
with thexchar[i] do |
|
374 |
begin |
|
375 |
dec(t, team^.HealthTex^.h + 2); |
|
376 |
ny:= t; |
|
377 |
dy:= dy - ny |
|
378 |
end; |
|
379 |
||
380 |
Gear^.Timer:= cSorterWorkTime; |
|
381 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
382 |
currsorter:= Gear; |
|
383 |
//doStepTeamHealthSorterWork(Gear, Steps) |
|
384 |
end; |
|
385 |
||
386 |
//////////////////////////////////////////////////////////////////////////////// |
|
387 |
procedure doStepSpeechBubbleWork(Gear: PVisualGear; Steps: Longword); |
|
388 |
begin |
|
389 |
if Gear^.Timer > Steps then dec(Gear^.Timer, Steps) else Gear^.Timer:= 0; |
|
390 |
||
391 |
if (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then |
|
392 |
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
|
393 |
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
|
394 |
Gear^.Y:= PHedgehog(Gear^.Hedgehog)^.Gear^.Y.QWordValue/4294967296 - (16 + Gear^.Tex^.h); |
3441 | 395 |
end; |
396 |
||
397 |
if Gear^.Timer = 0 then |
|
398 |
begin |
|
399 |
if PHedgehog(Gear^.Hedgehog)^.SpeechGear = Gear then |
|
400 |
PHedgehog(Gear^.Hedgehog)^.SpeechGear:= nil; |
|
401 |
DeleteVisualGear(Gear) |
|
402 |
end; |
|
403 |
end; |
|
404 |
||
405 |
procedure doStepSpeechBubble(Gear: PVisualGear; Steps: Longword); |
|
406 |
begin |
|
407 |
Steps:= Steps; // avoid compiler hint |
|
408 |
||
409 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
410 |
if SpeechGear <> nil then SpeechGear^.Timer:= 0; |
|
411 |
||
412 |
PHedgehog(Gear^.Hedgehog)^.SpeechGear:= Gear; |
|
413 |
||
414 |
Gear^.Timer:= max(Length(Gear^.Text) * 150, 3000); |
|
415 |
||
416 |
Gear^.Tex:= RenderSpeechBubbleTex(Gear^.Text, Gear^.FrameTicks, fnt16); |
|
417 |
||
418 |
case Gear^.FrameTicks of |
|
419 |
1: Gear^.FrameTicks:= SpritesData[sprSpeechTail].Width-28; |
|
420 |
2: Gear^.FrameTicks:= SpritesData[sprThoughtTail].Width-20; |
|
421 |
3: Gear^.FrameTicks:= SpritesData[sprShoutTail].Width-10; |
|
422 |
end; |
|
423 |
||
424 |
Gear^.doStep:= @doStepSpeechBubbleWork; |
|
425 |
||
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
|
426 |
Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h) |
3441 | 427 |
end; |
428 |
||
429 |
//////////////////////////////////////////////////////////////////////////////// |
|
430 |
procedure doStepHealthTagWork(Gear: PVisualGear; Steps: Longword); |
|
431 |
begin |
|
432 |
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
|
433 |
DeleteVisualGear(Gear) |
3441 | 434 |
else |
435 |
begin |
|
436 |
dec(Gear^.Timer, Steps); |
|
437 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
438 |
end; |
|
439 |
end; |
|
440 |
||
441 |
procedure doStepHealthTagWorkUnderWater(Gear: PVisualGear; Steps: Longword); |
|
442 |
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
|
443 |
if round(Gear^.Y) < cWaterLine + 10 then |
3441 | 444 |
DeleteVisualGear(Gear) |
445 |
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
|
446 |
Gear^.Y:= Gear^.Y - 0.08 * Steps; |
3441 | 447 |
|
448 |
end; |
|
449 |
||
450 |
procedure doStepHealthTag(Gear: PVisualGear; Steps: Longword); |
|
451 |
var s: shortstring; |
|
452 |
begin |
|
453 |
s:= ''; |
|
454 |
||
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
|
455 |
Gear^.dY:= -0.08; |
3441 | 456 |
|
457 |
str(Gear^.State, s); |
|
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
458 |
if Gear^.Hedgehog <> nil then |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
459 |
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
|
460 |
else |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
461 |
Gear^.Tex:= RenderStringTex(s, cWhiteColor, fnt16); |
3441 | 462 |
|
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
|
463 |
if round(Gear^.Y) < cWaterLine then |
3441 | 464 |
Gear^.doStep:= @doStepHealthTagWork |
465 |
else |
|
466 |
Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
|
467 |
||
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
|
468 |
Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h); |
3441 | 469 |
|
470 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
471 |
end; |
|
472 |
||
473 |
//////////////////////////////////////////////////////////////////////////////// |
|
474 |
procedure doStepSmokeTrace(Gear: PVisualGear; Steps: Longword); |
|
475 |
begin |
|
476 |
inc(Gear^.Timer, Steps ); |
|
477 |
if Gear^.Timer > 64 then |
|
478 |
begin |
|
479 |
dec(Gear^.State, Gear^.Timer div 65); |
|
480 |
Gear^.Timer:= Gear^.Timer mod 65; |
|
481 |
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
|
482 |
Gear^.dX:= Gear^.dX + cWindSpeedf * Steps; |
3587 | 483 |
Gear^.X:= Gear^.X + Gear^.dX; |
3441 | 484 |
if Gear^.State = 0 then DeleteVisualGear(Gear); |
485 |
end; |
|
486 |
||
487 |
//////////////////////////////////////////////////////////////////////////////// |
|
488 |
procedure doStepExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
489 |
begin |
|
490 |
inc(Gear^.Timer, Steps); |
|
491 |
if Gear^.Timer > 75 then |
|
492 |
begin |
|
493 |
inc(Gear^.State, Gear^.Timer div 76); |
|
494 |
Gear^.Timer:= Gear^.Timer mod 76; |
|
495 |
if Gear^.State > 5 then DeleteVisualGear(Gear); |
|
496 |
end; |
|
497 |
end; |
|
498 |
||
499 |
procedure doStepExplosion(Gear: PVisualGear; Steps: Longword); |
|
500 |
var i: LongWord; |
|
3590 | 501 |
gX,gY: LongInt; |
3441 | 502 |
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
|
503 |
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
|
504 |
gY:= round(Gear^.Y); |
3590 | 505 |
for i:= 0 to 31 do AddVisualGear(gX, gY, vgtFire); |
506 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart); |
|
507 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart2); |
|
3441 | 508 |
Gear^.doStep:= @doStepExplosionWork; |
509 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
510 |
end; |
|
511 |
||
512 |
||
513 |
//////////////////////////////////////////////////////////////////////////////// |
|
514 |
procedure doStepBigExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
3587 | 515 |
//var maxMovement: LongInt; |
3441 | 516 |
begin |
517 |
||
518 |
inc(Gear^.Timer, Steps); |
|
3466
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
519 |
(* |
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
520 |
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
|
521 |
One possible solution is, instead of using WorldDx, to use straight gl/SDL calls to jitter the screen a bit. |
3441 | 522 |
if (Gear^.Timer and 5) = 0 then |
523 |
begin |
|
524 |
maxMovement := max(1, 13 - ((Gear^.Timer * 15) div 250)); |
|
525 |
ShakeCamera(maxMovement); |
|
526 |
end; |
|
3466
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
527 |
*) |
3441 | 528 |
if Gear^.Timer > 250 then DeleteVisualGear(Gear); |
529 |
end; |
|
530 |
||
531 |
procedure doStepBigExplosion(Gear: PVisualGear; Steps: Longword); |
|
532 |
var i: LongWord; |
|
533 |
gX,gY: LongInt; |
|
534 |
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
|
535 |
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
|
536 |
gY:= round(Gear^.Y); |
3441 | 537 |
AddVisualGear(gX, gY, vgtSmokeRing); |
538 |
for i:= 0 to 46 do AddVisualGear(gX, gY, vgtFire); |
|
539 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart); |
|
540 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart2); |
|
541 |
Gear^.doStep:= @doStepBigExplosionWork; |
|
542 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
543 |
end; |