author | unc0rr |
Fri, 24 Aug 2012 14:51:12 +0400 | |
changeset 7593 | b966e2d833f2 |
parent 7592 | cf67e58313ea |
child 7594 | 5f03595335e6 |
permissions | -rw-r--r-- |
7592 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2004-2012 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 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
unit uGearsHandlersRope; |
|
21 |
interface |
|
22 |
||
23 |
uses uTypes; |
|
24 |
||
25 |
procedure doStepRope(Gear: PGear); |
|
26 |
||
27 |
implementation |
|
28 |
uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils, |
|
29 |
uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender; |
|
30 |
||
31 |
procedure doStepRopeAfterAttack(Gear: PGear); |
|
32 |
var |
|
33 |
HHGear: PGear; |
|
34 |
begin |
|
35 |
HHGear := Gear^.Hedgehog^.Gear; |
|
36 |
if ((HHGear^.State and gstHHDriven) = 0) |
|
37 |
or (CheckGearDrowning(HHGear)) |
|
38 |
or (TestCollisionYwithGear(HHGear, 1) <> 0) then |
|
39 |
begin |
|
40 |
DeleteGear(Gear); |
|
41 |
isCursorVisible := false; |
|
42 |
ApplyAmmoChanges(HHGear^.Hedgehog^); |
|
43 |
exit |
|
44 |
end; |
|
45 |
||
46 |
HedgehogChAngle(HHGear); |
|
47 |
||
48 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
|
49 |
SetLittle(HHGear^.dX); |
|
50 |
||
51 |
if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then |
|
52 |
HHGear^.dY := _0; |
|
53 |
HHGear^.X := HHGear^.X + HHGear^.dX; |
|
54 |
HHGear^.Y := HHGear^.Y + HHGear^.dY; |
|
55 |
HHGear^.dY := HHGear^.dY + cGravity; |
|
56 |
||
57 |
if (GameFlags and gfMoreWind) <> 0 then |
|
58 |
HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density; |
|
59 |
||
60 |
if (Gear^.Message and gmAttack) <> 0 then |
|
61 |
begin |
|
62 |
Gear^.X := HHGear^.X; |
|
63 |
Gear^.Y := HHGear^.Y; |
|
64 |
||
65 |
ApplyAngleBounds(Gear^.Hedgehog^, amRope); |
|
66 |
||
67 |
Gear^.dX := SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); |
|
68 |
Gear^.dY := -AngleCos(HHGear^.Angle); |
|
69 |
Gear^.Friction := _4_5 * cRopePercent; |
|
70 |
Gear^.Elasticity := _0; |
|
71 |
Gear^.State := Gear^.State and (not gsttmpflag); |
|
72 |
Gear^.doStep := @doStepRope; |
|
73 |
end |
|
74 |
end; |
|
75 |
||
76 |
procedure RopeDeleteMe(Gear, HHGear: PGear); |
|
77 |
begin |
|
78 |
with HHGear^ do |
|
79 |
begin |
|
80 |
Message := Message and (not gmAttack); |
|
81 |
State := (State or gstMoving) and (not gstWinner); |
|
82 |
end; |
|
83 |
DeleteGear(Gear) |
|
84 |
end; |
|
85 |
||
86 |
procedure RopeWaitCollision(Gear, HHGear: PGear); |
|
87 |
begin |
|
88 |
with HHGear^ do |
|
89 |
begin |
|
90 |
Message := Message and (not gmAttack); |
|
91 |
State := State or gstMoving; |
|
92 |
end; |
|
93 |
RopePoints.Count := 0; |
|
94 |
Gear^.Elasticity := _0; |
|
95 |
Gear^.doStep := @doStepRopeAfterAttack |
|
96 |
end; |
|
97 |
||
98 |
procedure doStepRopeWork(Gear: PGear); |
|
99 |
var |
|
100 |
HHGear: PGear; |
|
101 |
len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat; |
|
102 |
lx, ly, cd: LongInt; |
|
103 |
haveCollision, |
|
104 |
haveDivided: boolean; |
|
105 |
||
106 |
begin |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
107 |
if GameTicks mod 8 <> 0 then exit; |
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
108 |
|
7592 | 109 |
HHGear := Gear^.Hedgehog^.Gear; |
110 |
||
111 |
if ((HHGear^.State and gstHHDriven) = 0) |
|
112 |
or (CheckGearDrowning(HHGear)) or (Gear^.PortalCounter <> 0) then |
|
113 |
begin |
|
114 |
PlaySound(sndRopeRelease); |
|
115 |
RopeDeleteMe(Gear, HHGear); |
|
116 |
exit |
|
117 |
end; |
|
118 |
||
119 |
if (Gear^.Message and gmLeft <> 0) and (not TestCollisionXwithGear(HHGear, -1)) then |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
120 |
HHGear^.dX := HHGear^.dX - _0_0128; |
7592 | 121 |
|
122 |
if (Gear^.Message and gmRight <> 0) and (not TestCollisionXwithGear(HHGear, 1)) then |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
123 |
HHGear^.dX := HHGear^.dX + _0_0128; |
7592 | 124 |
|
125 |
// vector between hedgehog and rope attaching point |
|
126 |
ropeDx := HHGear^.X - Gear^.X; |
|
127 |
ropeDy := HHGear^.Y - Gear^.Y; |
|
128 |
||
129 |
if TestCollisionYwithGear(HHGear, 1) = 0 then |
|
130 |
begin |
|
131 |
||
132 |
// depending on the rope vector we know which X-side to check for collision |
|
133 |
// in order to find out if the hog can still be moved by gravity |
|
134 |
if ropeDx.isNegative = RopeDy.IsNegative then |
|
135 |
cd:= -1 |
|
136 |
else |
|
137 |
cd:= 1; |
|
138 |
||
139 |
// apply gravity if there is no obstacle |
|
140 |
if not TestCollisionXwithGear(HHGear, cd) then |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
141 |
HHGear^.dY := HHGear^.dY + cGravity * 64; |
7592 | 142 |
|
143 |
if (GameFlags and gfMoreWind) <> 0 then |
|
144 |
// apply wind if there's no obstacle |
|
145 |
if not TestCollisionXwithGear(HHGear, hwSign(cWindSpeed)) then |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
146 |
HHGear^.dX := HHGear^.dX + cWindSpeed * 64 / HHGear^.Density; |
7592 | 147 |
end; |
148 |
||
149 |
mdX := ropeDx + HHGear^.dX; |
|
150 |
mdY := ropeDy + HHGear^.dY; |
|
151 |
len := _1 / Distance(mdX, mdY); |
|
152 |
// rope vector plus hedgehog direction vector normalized |
|
153 |
mdX := mdX * len; |
|
154 |
mdY := mdY * len; |
|
155 |
||
156 |
// for visual purposes only |
|
157 |
Gear^.dX := mdX; |
|
158 |
Gear^.dY := mdY; |
|
159 |
||
160 |
///// |
|
161 |
tx := HHGear^.X; |
|
162 |
ty := HHGear^.Y; |
|
163 |
||
164 |
if ((Gear^.Message and gmDown) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
|
165 |
if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) |
|
166 |
or (TestCollisionYwithGear(HHGear, hwSign(ropeDy)) <> 0)) then |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
167 |
Gear^.Elasticity := Gear^.Elasticity + _2_4; |
7592 | 168 |
|
169 |
if ((Gear^.Message and gmUp) <> 0) and (Gear^.Elasticity > _30) then |
|
170 |
if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) |
|
171 |
or (TestCollisionYwithGear(HHGear, -hwSign(ropeDy)) <> 0)) then |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
172 |
Gear^.Elasticity := Gear^.Elasticity - _2_4; |
7592 | 173 |
|
174 |
HHGear^.X := Gear^.X + mdX * Gear^.Elasticity; |
|
175 |
HHGear^.Y := Gear^.Y + mdY * Gear^.Elasticity; |
|
176 |
||
177 |
HHGear^.dX := HHGear^.X - tx; |
|
178 |
HHGear^.dY := HHGear^.Y - ty; |
|
179 |
//// |
|
180 |
||
181 |
||
182 |
haveDivided := false; |
|
183 |
// check whether rope needs dividing |
|
184 |
||
185 |
len := Gear^.Elasticity - _5; |
|
186 |
nx := Gear^.X + mdX * len; |
|
187 |
ny := Gear^.Y + mdY * len; |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
188 |
tx := mdX * _2_4; // should be the same as increase step |
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
189 |
ty := mdY * _2_4; |
7592 | 190 |
|
191 |
while len > _3 do |
|
192 |
begin |
|
193 |
lx := hwRound(nx); |
|
194 |
ly := hwRound(ny); |
|
195 |
if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and ((Land[ly, lx] and $FF00) <> 0) then |
|
196 |
begin |
|
197 |
ny := _1 / Distance(ropeDx, ropeDy); |
|
198 |
// old rope pos |
|
199 |
nx := ropeDx * ny; |
|
200 |
ny := ropeDy * ny; |
|
201 |
||
202 |
with RopePoints.ar[RopePoints.Count] do |
|
203 |
begin |
|
204 |
X := Gear^.X; |
|
205 |
Y := Gear^.Y; |
|
206 |
if RopePoints.Count = 0 then |
|
207 |
RopePoints.HookAngle := DxDy2Angle(Gear^.dY, Gear^.dX); |
|
208 |
b := (nx * HHGear^.dY) > (ny * HHGear^.dX); |
|
209 |
dLen := len |
|
210 |
end; |
|
211 |
||
212 |
with RopePoints.rounded[RopePoints.Count] do |
|
213 |
begin |
|
214 |
X := hwRound(Gear^.X); |
|
215 |
Y := hwRound(Gear^.Y); |
|
216 |
end; |
|
217 |
||
218 |
Gear^.X := Gear^.X + nx * len; |
|
219 |
Gear^.Y := Gear^.Y + ny * len; |
|
220 |
inc(RopePoints.Count); |
|
221 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
|
222 |
Gear^.Elasticity := Gear^.Elasticity - len; |
|
223 |
Gear^.Friction := Gear^.Friction - len; |
|
224 |
haveDivided := true; |
|
225 |
break |
|
226 |
end; |
|
227 |
nx := nx - tx; |
|
228 |
ny := ny - ty; |
|
229 |
||
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
230 |
// len := len - _2_4 // should be the same as increase step |
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
231 |
len.QWordValue := len.QWordValue - _2_4.QWordValue; |
7592 | 232 |
end; |
233 |
||
234 |
if not haveDivided then |
|
235 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
236 |
begin |
|
237 |
tx := RopePoints.ar[Pred(RopePoints.Count)].X; |
|
238 |
ty := RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
239 |
mdX := tx - Gear^.X; |
|
240 |
mdY := ty - Gear^.Y; |
|
241 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor (mdX * (ty - HHGear^.Y) > (tx - HHGear^.X) * mdY) then |
|
242 |
begin |
|
243 |
dec(RopePoints.Count); |
|
244 |
Gear^.X := RopePoints.ar[RopePoints.Count].X; |
|
245 |
Gear^.Y := RopePoints.ar[RopePoints.Count].Y; |
|
246 |
Gear^.Elasticity := Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
247 |
Gear^.Friction := Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen; |
|
248 |
||
249 |
// restore hog position |
|
250 |
len := _1 / Distance(mdX, mdY); |
|
251 |
mdX := mdX * len; |
|
252 |
mdY := mdY * len; |
|
253 |
||
254 |
HHGear^.X := Gear^.X - mdX * Gear^.Elasticity; |
|
255 |
HHGear^.Y := Gear^.Y - mdY * Gear^.Elasticity; |
|
256 |
end |
|
257 |
end; |
|
258 |
||
259 |
haveCollision := false; |
|
260 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
|
261 |
begin |
|
262 |
HHGear^.dX := -_0_6 * HHGear^.dX; |
|
263 |
haveCollision := true |
|
264 |
end; |
|
265 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) <> 0 then |
|
266 |
begin |
|
267 |
HHGear^.dY := -_0_6 * HHGear^.dY; |
|
268 |
haveCollision := true |
|
269 |
end; |
|
270 |
||
271 |
if haveCollision and (Gear^.Message and (gmLeft or gmRight) <> 0) and (Gear^.Message and (gmUp or gmDown) <> 0) then |
|
272 |
begin |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
273 |
HHGear^.dX := SignAs(hwAbs(HHGear^.dX) + _1_6, HHGear^.dX); |
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
274 |
HHGear^.dY := SignAs(hwAbs(HHGear^.dY) + _1_6, HHGear^.dY) |
7592 | 275 |
end; |
276 |
||
277 |
len := hwSqr(HHGear^.dX) + hwSqr(HHGear^.dY); |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
278 |
if len > _49 then |
7592 | 279 |
begin |
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
280 |
len := _7 / hwSqrt(len); |
7592 | 281 |
HHGear^.dX := HHGear^.dX * len; |
282 |
HHGear^.dY := HHGear^.dY * len; |
|
283 |
end; |
|
284 |
||
285 |
haveCollision:= ((hwRound(Gear^.Y) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(Gear^.Y), hwRound(Gear^.X)]) <> 0); |
|
286 |
||
287 |
if not haveCollision then |
|
288 |
begin |
|
289 |
// backup gear location |
|
290 |
tx:= Gear^.X; |
|
291 |
ty:= Gear^.Y; |
|
292 |
||
293 |
if RopePoints.Count > 0 then |
|
294 |
begin |
|
295 |
// set gear location to the remote end of the rope, the attachment point |
|
296 |
Gear^.X:= RopePoints.ar[0].X; |
|
297 |
Gear^.Y:= RopePoints.ar[0].Y; |
|
298 |
end; |
|
299 |
||
300 |
CheckCollision(Gear); |
|
301 |
// if we haven't found any collision yet then check the other side too |
|
302 |
if (Gear^.State and gstCollision) = 0 then |
|
303 |
begin |
|
304 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
305 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
306 |
CheckCollision(Gear); |
|
307 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
308 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
309 |
end; |
|
310 |
||
311 |
haveCollision:= (Gear^.State and gstCollision) <> 0; |
|
312 |
||
313 |
// restore gear location |
|
314 |
Gear^.X:= tx; |
|
315 |
Gear^.Y:= ty; |
|
316 |
end; |
|
317 |
||
318 |
// if the attack key is pressed, lose rope contact as well |
|
319 |
if (Gear^.Message and gmAttack) <> 0 then |
|
320 |
haveCollision:= false; |
|
321 |
||
322 |
if not haveCollision then |
|
323 |
begin |
|
324 |
if (Gear^.State and gsttmpFlag) <> 0 then |
|
325 |
begin |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
326 |
HHGear^.dX.QWordValue:= HHGear^.dX.QWordValue shr 3; |
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
327 |
HHGear^.dY.QWordValue:= HHGear^.dY.QWordValue shr 3; |
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
328 |
|
7592 | 329 |
PlaySound(sndRopeRelease); |
330 |
if Gear^.Hedgehog^.CurAmmoType <> amParachute then |
|
331 |
RopeWaitCollision(Gear, HHGear) |
|
332 |
else |
|
333 |
RopeDeleteMe(Gear, HHGear) |
|
334 |
end |
|
335 |
end |
|
336 |
else |
|
337 |
if (Gear^.State and gsttmpFlag) = 0 then |
|
338 |
Gear^.State := Gear^.State or gsttmpFlag; |
|
339 |
end; |
|
340 |
||
341 |
procedure RopeRemoveFromAmmo(Gear, HHGear: PGear); |
|
342 |
begin |
|
343 |
if (Gear^.State and gstAttacked) = 0 then |
|
344 |
begin |
|
345 |
OnUsedAmmo(HHGear^.Hedgehog^); |
|
346 |
Gear^.State := Gear^.State or gstAttacked |
|
347 |
end; |
|
348 |
ApplyAmmoChanges(HHGear^.Hedgehog^) |
|
349 |
end; |
|
350 |
||
351 |
procedure doStepRopeAttach(Gear: PGear); |
|
352 |
var |
|
353 |
HHGear: PGear; |
|
354 |
tx, ty, tt: hwFloat; |
|
355 |
begin |
|
356 |
Gear^.X := Gear^.X - Gear^.dX; |
|
357 |
Gear^.Y := Gear^.Y - Gear^.dY; |
|
358 |
Gear^.Elasticity := Gear^.Elasticity + _1; |
|
359 |
||
360 |
HHGear := Gear^.Hedgehog^.Gear; |
|
361 |
DeleteCI(HHGear); |
|
362 |
||
363 |
if (HHGear^.State and gstMoving) <> 0 then |
|
364 |
begin |
|
365 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
|
366 |
SetLittle(HHGear^.dX); |
|
367 |
if HHGear^.dY.isNegative and (TestCollisionYwithGear(HHGear, -1) <> 0) then |
|
368 |
HHGear^.dY := _0; |
|
369 |
||
370 |
HHGear^.X := HHGear^.X + HHGear^.dX; |
|
371 |
Gear^.X := Gear^.X + HHGear^.dX; |
|
372 |
||
373 |
if TestCollisionYwithGear(HHGear, 1) <> 0 then |
|
374 |
begin |
|
375 |
CheckHHDamage(HHGear); |
|
376 |
HHGear^.dY := _0 |
|
377 |
//HHGear^.State:= HHGear^.State and (not (gstHHJumping or gstHHHJump)); |
|
378 |
end |
|
379 |
else |
|
380 |
begin |
|
381 |
HHGear^.Y := HHGear^.Y + HHGear^.dY; |
|
382 |
Gear^.Y := Gear^.Y + HHGear^.dY; |
|
383 |
HHGear^.dY := HHGear^.dY + cGravity; |
|
384 |
if (GameFlags and gfMoreWind) <> 0 then |
|
385 |
HHGear^.dX := HHGear^.dX + cWindSpeed / HHGear^.Density |
|
386 |
end; |
|
387 |
||
388 |
tt := Gear^.Elasticity; |
|
389 |
tx := _0; |
|
390 |
ty := _0; |
|
391 |
while tt > _20 do |
|
392 |
begin |
|
393 |
if ((hwRound(Gear^.Y+ty) and LAND_HEIGHT_MASK) = 0) and ((hwRound(Gear^.X+tx) and LAND_WIDTH_MASK) = 0) and ((Land[hwRound(Gear^.Y+ty), hwRound(Gear^.X+tx)] and $FF00) <> 0) then |
|
394 |
begin |
|
395 |
Gear^.X := Gear^.X + tx; |
|
396 |
Gear^.Y := Gear^.Y + ty; |
|
397 |
Gear^.Elasticity := tt; |
|
398 |
Gear^.doStep := @doStepRopeWork; |
|
399 |
PlaySound(sndRopeAttach); |
|
400 |
with HHGear^ do |
|
401 |
begin |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
402 |
dX.QWordValue:= dX.QWordValue shl 3; |
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
403 |
dY.QWordValue:= dY.QWordValue shl 3; |
7592 | 404 |
State := State and (not (gstAttacking or gstHHJumping or gstHHHJump)); |
405 |
Message := Message and (not gmAttack) |
|
406 |
end; |
|
407 |
||
408 |
RopeRemoveFromAmmo(Gear, HHGear); |
|
409 |
||
410 |
tt := _0; |
|
411 |
exit |
|
412 |
end; |
|
413 |
tx := tx + Gear^.dX + Gear^.dX; |
|
414 |
ty := ty + Gear^.dY + Gear^.dY; |
|
415 |
tt := tt - _2; |
|
416 |
end; |
|
417 |
end; |
|
418 |
||
419 |
CheckCollision(Gear); |
|
420 |
||
421 |
if (Gear^.State and gstCollision) <> 0 then |
|
422 |
if Gear^.Elasticity < _10 then |
|
423 |
Gear^.Elasticity := _10000 |
|
424 |
else |
|
425 |
begin |
|
426 |
Gear^.doStep := @doStepRopeWork; |
|
427 |
PlaySound(sndRopeAttach); |
|
428 |
with HHGear^ do |
|
429 |
begin |
|
7593
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
430 |
dX.QWordValue:= dX.QWordValue shl 3; |
b966e2d833f2
An attempt to run main rope code only every 8th tick:
unc0rr
parents:
7592
diff
changeset
|
431 |
dY.QWordValue:= dY.QWordValue shl 3; |
7592 | 432 |
State := State and (not (gstAttacking or gstHHJumping or gstHHHJump)); |
433 |
Message := Message and (not gmAttack) |
|
434 |
end; |
|
435 |
||
436 |
RopeRemoveFromAmmo(Gear, HHGear); |
|
437 |
||
438 |
exit |
|
439 |
end; |
|
440 |
||
441 |
if (Gear^.Elasticity > Gear^.Friction) |
|
442 |
or ((Gear^.Message and gmAttack) = 0) |
|
443 |
or ((HHGear^.State and gstHHDriven) = 0) |
|
444 |
or (HHGear^.Damage > 0) then |
|
445 |
begin |
|
446 |
with Gear^.Hedgehog^.Gear^ do |
|
447 |
begin |
|
448 |
State := State and (not gstAttacking); |
|
449 |
Message := Message and (not gmAttack) |
|
450 |
end; |
|
451 |
DeleteGear(Gear); |
|
452 |
exit; |
|
453 |
end; |
|
454 |
if CheckGearDrowning(HHGear) then DeleteGear(Gear) |
|
455 |
end; |
|
456 |
||
457 |
procedure doStepRope(Gear: PGear); |
|
458 |
begin |
|
459 |
Gear^.dX := - Gear^.dX; |
|
460 |
Gear^.dY := - Gear^.dY; |
|
461 |
Gear^.doStep := @doStepRopeAttach; |
|
462 |
PlaySound(sndRopeShot) |
|
463 |
end; |
|
464 |
||
465 |
end. |