68 if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
68 if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
69 end; |
69 end; |
70 |
70 |
71 //////////////////////////////////////////////////////////////////////////////// |
71 //////////////////////////////////////////////////////////////////////////////// |
72 procedure doStepFallingGear(Gear: PGear); |
72 procedure doStepFallingGear(Gear: PGear); |
|
73 var isFalling: boolean; |
73 begin |
74 begin |
74 Gear^.State:= Gear^.State and not gstCollision; |
75 Gear^.State:= Gear^.State and not gstCollision; |
75 |
76 |
76 if Gear^.dY.isNegative then |
77 if Gear^.dY.isNegative then |
77 begin |
78 begin |
78 Gear^.State:= Gear^.State or gstFalling; |
79 isFalling:= true; |
79 if TestCollisionYwithGear(Gear, -1) then |
80 if TestCollisionYwithGear(Gear, -1) then |
80 begin |
81 begin |
81 Gear^.dX:= Gear^.dX * Gear^.Friction; |
82 Gear^.dX:= Gear^.dX * Gear^.Friction; |
82 Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
83 Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
83 Gear^.State:= Gear^.State or gstCollision |
84 Gear^.State:= Gear^.State or gstCollision |
84 end |
85 end |
85 end else |
86 end else |
86 if TestCollisionYwithGear(Gear, 1) then |
87 if TestCollisionYwithGear(Gear, 1) then |
87 begin |
88 begin |
88 Gear^.State:= Gear^.State and not gstFalling; |
89 isFalling:= false; |
89 Gear^.dX:= Gear^.dX * Gear^.Friction; |
90 Gear^.dX:= Gear^.dX * Gear^.Friction; |
90 Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
91 Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
91 Gear^.State:= Gear^.State or gstCollision |
92 Gear^.State:= Gear^.State or gstCollision |
92 end else Gear^.State:= Gear^.State or gstFalling; |
93 end else isFalling:= true; |
93 |
94 |
94 if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
95 if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
95 begin |
96 begin |
96 Gear^.dX:= - Gear^.dX * Gear^.Elasticity; |
97 Gear^.dX:= - Gear^.dX * Gear^.Elasticity; |
97 Gear^.State:= Gear^.State or gstCollision |
98 Gear^.State:= Gear^.State or gstCollision |
98 end; |
99 end; |
99 |
100 |
100 if (Gear^.State and gstFalling) <> 0 then Gear^.dY:= Gear^.dY + cGravity; |
101 if isFalling then Gear^.dY:= Gear^.dY + cGravity; |
101 |
102 |
102 Gear^.X:= Gear^.X + Gear^.dX; |
103 Gear^.X:= Gear^.X + Gear^.dX; |
103 Gear^.Y:= Gear^.Y + Gear^.dY; |
104 Gear^.Y:= Gear^.Y + Gear^.dY; |
104 CheckGearDrowning(Gear); |
105 CheckGearDrowning(Gear); |
105 if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
106 if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
106 ((Gear^.State and gstFalling) = 0) then Gear^.State:= Gear^.State and not gstMoving |
107 (not isFalling) then Gear^.State:= Gear^.State and not gstMoving |
107 else Gear^.State:= Gear^.State or gstMoving |
108 else Gear^.State:= Gear^.State or gstMoving |
108 end; |
109 end; |
109 |
110 |
110 //////////////////////////////////////////////////////////////////////////////// |
111 //////////////////////////////////////////////////////////////////////////////// |
111 procedure doStepCloud(Gear: PGear); |
112 procedure doStepCloud(Gear: PGear); |
112 begin |
113 begin |
503 HHGear^.State:= HHGear^.State or gstNoDamage; |
504 HHGear^.State:= HHGear^.State or gstNoDamage; |
504 AmmoShove(Gear, 2, 14); |
505 AmmoShove(Gear, 2, 14); |
505 HHGear^.State:= HHGear^.State and not gstNoDamage |
506 HHGear^.State:= HHGear^.State and not gstNoDamage |
506 end; |
507 end; |
507 |
508 |
508 if (HHGear^.State and gstFalling) <> 0 then Gear^.Timer:= 0 |
509 if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0 |
509 end; |
510 end; |
510 |
511 |
511 if b then |
512 if b then |
512 DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
513 DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
513 Gear^.dX, Gear^.dY, |
514 Gear^.dX, Gear^.dY, |
662 Gear^.X:= Gear^.X - Gear^.dX; |
663 Gear^.X:= Gear^.X - Gear^.dX; |
663 Gear^.Y:= Gear^.Y - Gear^.dY; |
664 Gear^.Y:= Gear^.Y - Gear^.dY; |
664 Gear^.Elasticity:= Gear^.Elasticity + _1; |
665 Gear^.Elasticity:= Gear^.Elasticity + _1; |
665 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
666 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
666 DeleteCI(HHGear); |
667 DeleteCI(HHGear); |
667 if (HHGear^.State and gstFalling) <> 0 then |
668 if (HHGear^.State and gstMoving) <> 0 then |
668 if TestCollisionYwithGear(HHGear, 1) then |
669 if TestCollisionYwithGear(HHGear, 1) then |
669 begin |
670 begin |
670 HHGear^.dY:= _0; |
671 HHGear^.dY:= _0; |
671 CheckHHDamage(HHGear); |
672 CheckHHDamage(HHGear); |
672 HHGear^.State:= HHGear^.State and not (gstFalling or gstHHJumping); |
673 HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
673 end else |
674 end else |
674 begin |
675 begin |
675 if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
676 if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
676 HHGear^.X:= HHGear^.X + HHGear^.dX; |
677 HHGear^.X:= HHGear^.X + HHGear^.dX; |
677 HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
678 HHGear^.Y:= HHGear^.Y + HHGear^.dY; |