1744 * From the depths (same as from sky, but from sea, with submersible flag set) |
1744 * From the depths (same as from sky, but from sea, with submersible flag set) |
1745 |
1745 |
1746 Trying to make the checks a little broader than on first pass to catch things that don't move normally. |
1746 Trying to make the checks a little broader than on first pass to catch things that don't move normally. |
1747 *) |
1747 *) |
1748 function WorldWrap(var Gear: PGear): boolean; |
1748 function WorldWrap(var Gear: PGear): boolean; |
1749 //var tdx: hwFloat; |
1749 var bounced: boolean; |
1750 begin |
1750 begin |
1751 WorldWrap:= false; |
1751 WorldWrap:= false; |
1752 if WorldEdge = weNone then exit(false); |
1752 if WorldEdge = weNone then exit(false); |
1753 if (hwRound(Gear^.X) < leftX) or |
1753 if (hwRound(Gear^.X) < leftX) or |
1754 (hwRound(Gear^.X) > rightX) then |
1754 (hwRound(Gear^.X) > rightX) then |
1761 LeftImpactTimer:= 150; |
1761 LeftImpactTimer:= 150; |
1762 RightImpactTimer:= 150 |
1762 RightImpactTimer:= 150 |
1763 end |
1763 end |
1764 else if WorldEdge = weBounce then |
1764 else if WorldEdge = weBounce then |
1765 begin |
1765 begin |
1766 if (hwRound(Gear^.X) - Gear^.Radius < leftX) then |
1766 bounced:= false; |
|
1767 if (hwRound(Gear^.X) - Gear^.Radius < leftX) and (hwSign(Gear^.dX) = -1) and (not isZero(Gear^.dX)) then |
1767 begin |
1768 begin |
1768 LeftImpactTimer:= 333; |
1769 LeftImpactTimer:= 333; |
1769 Gear^.dX.isNegative:= false; |
1770 Gear^.dX.isNegative:= false; |
1770 Gear^.X:= int2hwfloat(leftX + Gear^.Radius) |
1771 Gear^.X:= int2hwfloat(leftX + Gear^.Radius); |
|
1772 bounced:= true; |
1771 end |
1773 end |
1772 else |
1774 else if (hwRound(Gear^.X) - Gear^.Radius > rightX) and (hwSign(Gear^.dX) = 1) and (not isZero(Gear^.dX)) then |
1773 begin |
1775 begin |
1774 RightImpactTimer:= 333; |
1776 RightImpactTimer:= 333; |
1775 Gear^.dX.isNegative:= true; |
1777 Gear^.dX.isNegative:= true; |
1776 Gear^.X:= int2hwfloat(rightX-Gear^.Radius) |
1778 Gear^.X:= int2hwfloat(rightX-Gear^.Radius); |
|
1779 bounced:= true; |
1777 end; |
1780 end; |
1778 if (Gear^.Radius > 2) and (Gear^.dX.QWordValue > _0_001.QWordValue) then |
1781 if (bounced) and (Gear^.Radius > 2) and (Gear^.dX.QWordValue > _0_001.QWordValue) then |
1779 AddBounceEffectForGear(Gear); |
1782 AddBounceEffectForGear(Gear); |
1780 end{ |
1783 end{ |
1781 else if WorldEdge = weSea then |
1784 else if WorldEdge = weSea then |
1782 begin |
1785 begin |
1783 if (hwRound(Gear^.Y) > cWaterLine) and (Gear^.State and gstSubmersible <> 0) then |
1786 if (hwRound(Gear^.Y) > cWaterLine) and (Gear^.State and gstSubmersible <> 0) then |