author | unc0rr |
Sat, 09 May 2009 11:56:46 +0000 | |
changeset 2040 | 7c366fc3c099 |
parent 2014 | c028362c5d72 |
child 2042 | 905c554d62e6 |
permissions | -rw-r--r-- |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
3 |
* Copyright (c) 2008 Andrey Korotaev <unC0Rr@gmail.com> |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
4 |
* |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
8 |
* |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
13 |
* |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
17 |
*) |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
18 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
19 |
unit uVisualGears; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
20 |
interface |
1906 | 21 |
uses SDLh, uConsts, |
22 |
{$IFDEF IPHONE} |
|
23 |
gles11, |
|
24 |
{$ELSE} |
|
25 |
GL, |
|
26 |
{$ENDIF} |
|
27 |
uFloat; |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
28 |
{$INCLUDE options.inc} |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
29 |
const AllInactive: boolean = false; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
30 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
31 |
type PVisualGear = ^TVisualGear; |
1505 | 32 |
TVGearStepProcedure = procedure (Gear: PVisualGear; Steps: Longword); |
33 |
TVisualGear = record |
|
34 |
NextGear, PrevGear: PVisualGear; |
|
35 |
Frame, |
|
36 |
FrameTicks: Longword; |
|
37 |
X : hwFloat; |
|
38 |
Y : hwFloat; |
|
39 |
dX: hwFloat; |
|
40 |
dY: hwFloat; |
|
41 |
mdY: QWord; |
|
2005 | 42 |
Timer: Longword; |
1505 | 43 |
Angle, dAngle: real; |
44 |
Kind: TVisualGearType; |
|
45 |
doStep: TVGearStepProcedure; |
|
46 |
Tex: PTexture; |
|
47 |
end; |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
48 |
|
805 | 49 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
50 |
procedure ProcessVisualGears(Steps: Longword); |
1045 | 51 |
procedure DrawVisualGears(Layer: LongWord); |
1041 | 52 |
procedure DeleteVisualGear(Gear: PVisualGear); |
803 | 53 |
procedure AddClouds; |
1505 | 54 |
procedure AddDamageTag(X, Y, Damage, Color: LongWord); |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
55 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
56 |
var VisualGearsList: PVisualGear = nil; |
1505 | 57 |
vobFrameTicks, vobFramesCount: Longword; |
58 |
vobVelocity, vobFallSpeed: LongInt; |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
59 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
60 |
implementation |
2005 | 61 |
uses uWorld, uMisc, uStore, uTeams; |
1047 | 62 |
const cExplFrameTicks = 110; |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
63 |
|
1505 | 64 |
procedure AddDamageTag(X, Y, Damage, Color: LongWord); |
65 |
var s: shortstring; |
|
1729 | 66 |
Gear: PVisualGear; |
1505 | 67 |
begin |
68 |
if cAltDamage then |
|
1729 | 69 |
begin |
70 |
Gear:= AddVisualGear(X, Y, vgtSmallDamageTag); |
|
71 |
if Gear <> nil then |
|
72 |
with Gear^ do |
|
73 |
begin |
|
74 |
str(Damage, s); |
|
75 |
Tex:= RenderStringTex(s, Color, fntSmall); |
|
76 |
end |
|
77 |
end |
|
1505 | 78 |
end; |
79 |
||
80 |
||
803 | 81 |
// ================================================================== |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
82 |
procedure doStepFlake(Gear: PVisualGear; Steps: Longword); |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
83 |
begin |
805 | 84 |
with Gear^ do |
1505 | 85 |
begin |
86 |
inc(FrameTicks, Steps); |
|
87 |
if FrameTicks > vobFrameTicks then |
|
88 |
begin |
|
89 |
dec(FrameTicks, vobFrameTicks); |
|
90 |
inc(Frame); |
|
91 |
if Frame = vobFramesCount then Frame:= 0 |
|
92 |
end |
|
93 |
end; |
|
805 | 94 |
|
95 |
Gear^.X:= Gear^.X + (cWindSpeed * 200 + Gear^.dX) * Steps; |
|
808 | 96 |
Gear^.Y:= Gear^.Y + (Gear^.dY + cGravity * vobFallSpeed) * Steps; |
97 |
Gear^.Angle:= Gear^.Angle + Gear^.dAngle * Steps; |
|
805 | 98 |
|
1760 | 99 |
if hwRound(Gear^.X) < -cScreenWidth - 64 then Gear^.X:= int2hwFloat(cScreenWidth + LAND_WIDTH) else |
100 |
if hwRound(Gear^.X) > cScreenWidth + LAND_WIDTH then Gear^.X:= int2hwFloat(-cScreenWidth - 64); |
|
1869 | 101 |
// if hwRound(Gear^.Y) < (LAND_HEIGHT - 1024 - 75) then Gear^.Y:= Gear^.Y + int2hwFloat(25); // For if flag is set for flakes rising upwards? |
102 |
if hwRound(Gear^.Y) > (LAND_HEIGHT + 75) then Gear^.Y:= Gear^.Y - int2hwFloat(1024 + 150) // TODO - configure in theme (jellies for example could use limited range) |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
103 |
end; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
104 |
|
803 | 105 |
procedure doStepCloud(Gear: PVisualGear; Steps: Longword); |
1079 | 106 |
var i: Longword; |
803 | 107 |
begin |
108 |
Gear^.X:= Gear^.X + (cWindSpeed * 200 + Gear^.dX) * Steps; |
|
805 | 109 |
|
1079 | 110 |
for i:= 0 to Steps - 1 do |
111 |
begin |
|
1776 | 112 |
if hwRound(Gear^.Y) > LAND_HEIGHT-1184 then // TODO - configure in theme |
1079 | 113 |
Gear^.dY:= Gear^.dY - _1div50000 |
114 |
else |
|
115 |
Gear^.dY:= Gear^.dY + _1div50000; |
|
116 |
||
117 |
Gear^.Y:= Gear^.Y + Gear^.dY |
|
118 |
end; |
|
805 | 119 |
|
1801 | 120 |
if hwRound(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= int2hwFloat(cScreenWidth + LAND_WIDTH) else |
1762 | 121 |
if hwRound(Gear^.X) > cScreenWidth + LAND_WIDTH then Gear^.X:= int2hwFloat(-cScreenWidth - 256) |
803 | 122 |
end; |
123 |
||
1041 | 124 |
procedure doStepExpl(Gear: PVisualGear; Steps: Longword); |
125 |
begin |
|
1046 | 126 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
1041 | 127 |
|
1046 | 128 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
129 |
//Gear^.dY:= Gear^.dY + cGravity; |
|
1041 | 130 |
|
1045 | 131 |
if Gear^.FrameTicks <= Steps then |
132 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
133 |
else |
|
134 |
begin |
|
135 |
dec(Gear^.Frame); |
|
136 |
Gear^.FrameTicks:= cExplFrameTicks |
|
137 |
end |
|
138 |
else dec(Gear^.FrameTicks, Steps) |
|
1041 | 139 |
end; |
140 |
||
1046 | 141 |
procedure doStepFire(Gear: PVisualGear; Steps: Longword); |
142 |
begin |
|
143 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
144 |
||
145 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravity * (Steps * Steps); |
|
146 |
Gear^.dY:= Gear^.dY + cGravity * Steps; |
|
147 |
||
148 |
if Gear^.FrameTicks <= Steps then |
|
149 |
DeleteVisualGear(Gear) |
|
150 |
else |
|
151 |
dec(Gear^.FrameTicks, Steps) |
|
152 |
end; |
|
153 |
||
1505 | 154 |
procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword); |
155 |
begin |
|
156 |
Gear^.Y:= Gear^.Y - _0_02 * Steps; |
|
157 |
||
158 |
if Gear^.FrameTicks <= Steps then |
|
159 |
DeleteVisualGear(Gear) |
|
160 |
else |
|
161 |
dec(Gear^.FrameTicks, Steps) |
|
162 |
end; |
|
163 |
||
2005 | 164 |
//////////////////////////////////////////////////////////////////////////////// |
165 |
const cSorterWorkTime = 640; |
|
166 |
var thexchar: array[0..cMaxTeams] of |
|
167 |
record |
|
168 |
dy, ny, dw: LongInt; |
|
169 |
team: PTeam; |
|
170 |
SortFactor: QWord; |
|
171 |
end; |
|
172 |
currsorter: PVisualGear = nil; |
|
173 |
||
174 |
procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword); |
|
175 |
var i, t: LongInt; |
|
176 |
begin |
|
177 |
for t:= 1 to Steps do |
|
178 |
begin |
|
179 |
dec(Gear^.Timer); |
|
180 |
if (Gear^.Timer and 15) = 0 then |
|
181 |
for i:= 0 to Pred(TeamsCount) do |
|
182 |
with thexchar[i] do |
|
183 |
begin |
|
184 |
{$WARNINGS OFF} |
|
185 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
|
186 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
187 |
{$WARNINGS ON} |
|
188 |
end; |
|
189 |
||
190 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
|
191 |
begin |
|
192 |
if currsorter = Gear then currsorter:= nil; |
|
193 |
DeleteVisualGear(Gear); |
|
194 |
exit |
|
195 |
end |
|
196 |
end |
|
197 |
end; |
|
198 |
||
199 |
procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword); |
|
200 |
var i: Longword; |
|
201 |
b: boolean; |
|
202 |
t: LongInt; |
|
203 |
begin |
|
204 |
for t:= 0 to Pred(TeamsCount) do |
|
205 |
with thexchar[t] do |
|
206 |
begin |
|
207 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
208 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
209 |
team:= TeamsArray[t]; |
|
210 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
211 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
212 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
213 |
end; |
|
214 |
||
215 |
if TeamsCount > 1 then |
|
216 |
repeat |
|
217 |
b:= true; |
|
218 |
for t:= 0 to TeamsCount - 2 do |
|
219 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
220 |
begin |
|
221 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
222 |
thexchar[t]:= thexchar[Succ(t)]; |
|
223 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
224 |
b:= false |
|
225 |
end |
|
226 |
until b; |
|
227 |
||
228 |
t:= - 4; |
|
229 |
for i:= 0 to Pred(TeamsCount) do |
|
230 |
with thexchar[i] do |
|
231 |
begin |
|
232 |
dec(t, team^.HealthTex^.h + 2); |
|
233 |
ny:= t; |
|
234 |
dy:= dy - ny |
|
235 |
end; |
|
236 |
||
237 |
Gear^.Timer:= cSorterWorkTime; |
|
238 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
239 |
currsorter:= Gear; |
|
240 |
//doStepTeamHealthSorterWork(Gear, Steps) |
|
241 |
end; |
|
242 |
||
803 | 243 |
// ================================================================== |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
244 |
const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure = |
1505 | 245 |
( |
246 |
@doStepFlake, |
|
247 |
@doStepCloud, |
|
248 |
@doStepExpl, |
|
249 |
@doStepExpl, |
|
250 |
@doStepFire, |
|
2005 | 251 |
@doStepSmallDamage, |
252 |
@doStepTeamHealthSorter |
|
1505 | 253 |
); |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
254 |
|
805 | 255 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
256 |
var Result: PVisualGear; |
1045 | 257 |
t: Longword; |
258 |
sp: hwFloat; |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
259 |
begin |
1642 | 260 |
if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then // we're scrolling now |
261 |
if Kind <> vgtCloud then |
|
262 |
begin |
|
263 |
AddVisualGear:= nil; |
|
264 |
exit |
|
265 |
end; |
|
266 |
||
2014 | 267 |
if cReducedQuality and (Kind <> vgtTeamHealthSorter) then |
1812 | 268 |
begin |
269 |
AddVisualGear:= nil; |
|
270 |
exit |
|
271 |
end; |
|
272 |
||
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
273 |
New(Result); |
812
cbc392576990
Fix memory corrupt due to wrong parameter in sizeof()
unc0rr
parents:
808
diff
changeset
|
274 |
FillChar(Result^, sizeof(TVisualGear), 0); |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
275 |
Result^.X:= int2hwFloat(X); |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
276 |
Result^.Y:= int2hwFloat(Y); |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
277 |
Result^.Kind := Kind; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
278 |
Result^.doStep:= doStepHandlers[Kind]; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
279 |
|
1505 | 280 |
with Result^ do |
281 |
case Kind of |
|
282 |
vgtFlake: begin |
|
283 |
FrameTicks:= random(vobFrameTicks); |
|
284 |
Frame:= random(vobFramesCount); |
|
285 |
Angle:= random * 360; |
|
286 |
dx.isNegative:= random(2) = 0; |
|
287 |
dx.QWordValue:= random(100000000); |
|
288 |
dy.isNegative:= false; |
|
289 |
dy.QWordValue:= random(70000000); |
|
290 |
dAngle:= (random(2) * 2 - 1) * (1 + random) * vobVelocity / 1000 |
|
291 |
end; |
|
292 |
vgtCloud: begin |
|
293 |
Frame:= random(4); |
|
294 |
dx.isNegative:= random(2) = 0; |
|
295 |
dx.QWordValue:= random(214748364); |
|
296 |
dy.isNegative:= random(2) = 0; |
|
297 |
dy.QWordValue:= 21474836 + random(64424509); |
|
298 |
mdY:= dy.QWordValue |
|
299 |
end; |
|
300 |
vgtExplPart, |
|
301 |
vgtExplPart2: begin |
|
302 |
t:= random(1024); |
|
303 |
sp:= _0_001 * (random(95) + 70); |
|
304 |
dx:= AngleSin(t) * sp; |
|
305 |
dx.isNegative:= random(2) = 0; |
|
306 |
dy:= AngleCos(t) * sp; |
|
307 |
dy.isNegative:= random(2) = 0; |
|
308 |
Frame:= 7 - random(3); |
|
309 |
FrameTicks:= cExplFrameTicks |
|
310 |
end; |
|
311 |
vgtFire: begin |
|
312 |
t:= random(1024); |
|
313 |
sp:= _0_001 * (random(85) + 95); |
|
314 |
dx:= AngleSin(t) * sp; |
|
315 |
dx.isNegative:= random(2) = 0; |
|
316 |
dy:= AngleCos(t) * sp; |
|
317 |
dy.isNegative:= random(2) = 0; |
|
318 |
FrameTicks:= 650 + random(250); |
|
319 |
Frame:= random(8) |
|
320 |
end; |
|
321 |
vgtSmallDamageTag: begin |
|
322 |
Result^.FrameTicks:= 1100 |
|
323 |
end; |
|
324 |
end; |
|
803 | 325 |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
326 |
if VisualGearsList <> nil then |
1505 | 327 |
begin |
328 |
VisualGearsList^.PrevGear:= Result; |
|
329 |
Result^.NextGear:= VisualGearsList |
|
330 |
end; |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
331 |
VisualGearsList:= Result; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
332 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
333 |
AddVisualGear:= Result |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
334 |
end; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
335 |
|
1041 | 336 |
procedure DeleteVisualGear(Gear: PVisualGear); |
337 |
begin |
|
1505 | 338 |
if Gear^.Tex <> nil then |
339 |
FreeTexture(Gear^.Tex); |
|
340 |
||
1041 | 341 |
if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
342 |
if Gear^.PrevGear <> nil then Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
343 |
else VisualGearsList:= Gear^.NextGear; |
|
344 |
||
345 |
Dispose(Gear) |
|
346 |
end; |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
347 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
348 |
procedure ProcessVisualGears(Steps: Longword); |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
349 |
var Gear, t: PVisualGear; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
350 |
begin |
803 | 351 |
if Steps = 0 then exit; |
352 |
||
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
353 |
t:= VisualGearsList; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
354 |
while t <> nil do |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
355 |
begin |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
356 |
Gear:= t; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
357 |
t:= Gear^.NextGear; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
358 |
Gear^.doStep(Gear, Steps) |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
359 |
end |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
360 |
end; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
361 |
|
1045 | 362 |
procedure DrawVisualGears(Layer: LongWord); |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
363 |
var Gear: PVisualGear; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
364 |
begin |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
365 |
Gear:= VisualGearsList; |
1045 | 366 |
case Layer of |
367 |
0: while Gear <> nil do |
|
368 |
begin |
|
369 |
case Gear^.Kind of |
|
370 |
vgtFlake: if vobVelocity = 0 then |
|
371 |
DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame) |
|
372 |
else |
|
373 |
DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); |
|
374 |
vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame); |
|
375 |
end; |
|
376 |
Gear:= Gear^.NextGear |
|
377 |
end; |
|
378 |
1: while Gear <> nil do |
|
379 |
begin |
|
380 |
case Gear^.Kind of |
|
381 |
vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame); |
|
1047 | 382 |
vgtExplPart2: DrawSprite(sprExplPart2, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 7 - Gear^.Frame); |
1046 | 383 |
vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8); |
1505 | 384 |
vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex); |
1045 | 385 |
end; |
386 |
Gear:= Gear^.NextGear |
|
387 |
end |
|
388 |
end |
|
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
389 |
end; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
390 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
391 |
procedure AddClouds; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
392 |
var i: LongInt; |
803 | 393 |
begin |
1132 | 394 |
for i:= 0 to cCloudsNumber - 1 do |
1801 | 395 |
AddVisualGear( - cScreenWidth + i * ((cScreenWidth * 2 + (LAND_WIDTH+256)) div (cCloudsNumber + 1)), LAND_HEIGHT-1184, vgtCloud) |
802
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
396 |
end; |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
397 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
398 |
initialization |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
399 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
400 |
finalization |
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
401 |
|
ed5450a89b96
Start implementing 'visual gears' - gears, that don't need to be synchronized (clouds and flakes)
unc0rr
parents:
diff
changeset
|
402 |
end. |