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