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