equal
deleted
inserted
replaced
52 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline; |
52 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): Word; inline; |
53 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word; |
53 function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word; |
54 |
54 |
55 function TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean; |
55 function TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean; |
56 |
56 |
57 // returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45° = _0_5) |
57 // returns: negative sign if going downhill to left, value is steepness (noslope/error = _0, 45 = _0_5) |
58 function CalcSlopeBelowGear(Gear: PGear): hwFloat; |
58 function CalcSlopeBelowGear(Gear: PGear): hwFloat; |
59 function CalcSlopeNearGear(Gear: PGear; dirX, dirY: LongInt): hwFloat; |
59 function CalcSlopeNearGear(Gear: PGear; dirX, dirY: LongInt): hwFloat; |
60 function CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean; |
60 function CalcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): boolean; |
61 |
61 |
62 implementation |
62 implementation |
90 inc(Count); |
90 inc(Count); |
91 // mines are the easiest way to overflow collision |
91 // mines are the easiest way to overflow collision |
92 if (Count > (MAXRECTSINDEX-20)) then |
92 if (Count > (MAXRECTSINDEX-20)) then |
93 begin |
93 begin |
94 t:= GearsList; |
94 t:= GearsList; |
95 while (t <> nil) and (t^.Kind <> gtMine) do |
95 while (t <> nil) and (t^.Kind <> gtMine) do |
96 t:= t^.NextGear; |
96 t:= t^.NextGear; |
97 if (t <> nil) then |
97 if (t <> nil) then |
98 t^.State:= t^.State or gmDelete |
98 t^.State:= t^.State or gmDelete |
99 end; |
99 end; |
100 end; |
100 end; |
232 mx:= hwRound(Gear^.X); |
232 mx:= hwRound(Gear^.X); |
233 my:= hwRound(Gear^.Y); |
233 my:= hwRound(Gear^.Y); |
234 |
234 |
235 for i:= 0 to Pred(Count) do |
235 for i:= 0 to Pred(Count) do |
236 with cinfos[i] do |
236 with cinfos[i] do |
237 if (Gear <> cGear) and |
237 if (Gear <> cGear) and |
238 ((mx > x) xor (Dir > 0)) and |
238 ((mx > x) xor (Dir > 0)) and |
239 ( |
239 ( |
240 ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or |
240 ((cGear^.Kind in [gtHedgehog, gtMine, gtKnife]) and ((Gear^.State and gstNotKickable) = 0)) or |
241 // only apply X kick if the barrel is knocked over |
241 // only apply X kick if the barrel is knocked over |
242 ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0)) |
242 ((cGear^.Kind = gtExplosives) and ((cGear^.State and gsttmpflag) <> 0)) |
298 for i:= 0 to Pred(Count) do |
298 for i:= 0 to Pred(Count) do |
299 with cinfos[i] do |
299 with cinfos[i] do |
300 if (Gear <> cGear) and |
300 if (Gear <> cGear) and |
301 ((myr > y) xor (Dir > 0)) and |
301 ((myr > y) xor (Dir > 0)) and |
302 (Gear^.State and gstNotKickable = 0) and |
302 (Gear^.State and gstNotKickable = 0) and |
303 (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and |
303 (cGear^.Kind in [gtHedgehog, gtMine, gtKnife, gtExplosives]) and |
304 (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then |
304 (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius + 2)) then |
305 begin |
305 begin |
306 with cGear^ do |
306 with cGear^ do |
307 begin |
307 begin |
308 if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then |
308 if (Kind <> gtExplosives) or ((State and gsttmpflag) <> 0) then |
325 |
325 |
326 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word; |
326 function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt; withGear: boolean): Word; |
327 begin |
327 begin |
328 Gear^.X:= Gear^.X + ShiftX; |
328 Gear^.X:= Gear^.X + ShiftX; |
329 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY); |
329 Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY); |
330 if withGear then |
330 if withGear then |
331 TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir) |
331 TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir) |
332 else TestCollisionXwithXYShift:= TestCollisionX(Gear, Dir); |
332 else TestCollisionXwithXYShift:= TestCollisionX(Gear, Dir); |
333 Gear^.X:= Gear^.X - ShiftX; |
333 Gear^.X:= Gear^.X - ShiftX; |
334 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) |
334 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) |
335 end; |
335 end; |
392 |
392 |
393 if withGear then |
393 if withGear then |
394 TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir) |
394 TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir) |
395 else |
395 else |
396 TestCollisionYwithXYShift:= TestCollisionY(Gear, Dir); |
396 TestCollisionYwithXYShift:= TestCollisionY(Gear, Dir); |
397 |
397 |
398 Gear^.X:= Gear^.X - int2hwFloat(ShiftX); |
398 Gear^.X:= Gear^.X - int2hwFloat(ShiftX); |
399 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) |
399 Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY) |
400 end; |
400 end; |
401 |
401 |
402 function TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean; |
402 function TestRectancleForObstacle(x1, y1, x2, y2: LongInt; landOnly: boolean): boolean; |
581 var dx, dy: hwFloat; |
581 var dx, dy: hwFloat; |
582 collX, collY, i, y, x, gx, gy, sdx, sdy: LongInt; |
582 collX, collY, i, y, x, gx, gy, sdx, sdy: LongInt; |
583 isColl, bSucc: Boolean; |
583 isColl, bSucc: Boolean; |
584 begin |
584 begin |
585 |
585 |
586 if dirY <> 0 then |
586 if dirY <> 0 then |
587 begin |
587 begin |
588 y:= hwRound(Gear^.Y) + Gear^.Radius * dirY; |
588 y:= hwRound(Gear^.Y) + Gear^.Radius * dirY; |
589 gx:= hwRound(Gear^.X); |
589 gx:= hwRound(Gear^.X); |
590 collX := gx; |
590 collX := gx; |
591 isColl:= false; |
591 isColl:= false; |