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