hedgewars/uGearsUtils.pas
changeset 15223 32678e65b25e
parent 15220 ceb289e8a582
child 15227 263b9850c16d
equal deleted inserted replaced
15222:deaa316af414 15223:32678e65b25e
  1805         WorldWrap:= true;
  1805         WorldWrap:= true;
  1806         end
  1806         end
  1807     else if WorldEdge = weBounce then
  1807     else if WorldEdge = weBounce then
  1808         begin
  1808         begin
  1809         bounced:= false;
  1809         bounced:= false;
       
  1810         // Bounce left
  1810         if (hwRound(Gear^.X) - Gear^.Radius < leftX) and (((hwSign(Gear^.dX) = -1) and (not isZero(Gear^.dX))) or (Gear^.Kind = gtHedgehog)) then
  1811         if (hwRound(Gear^.X) - Gear^.Radius < leftX) and (((hwSign(Gear^.dX) = -1) and (not isZero(Gear^.dX))) or (Gear^.Kind = gtHedgehog)) then
  1811             begin
  1812             begin
  1812             LeftImpactTimer:= 333;
  1813             LeftImpactTimer:= 333;
       
  1814             // Set X coordinate to bounce edge, unless the gear spawned inside the bounce edge before
       
  1815             if (Gear^.State and gstInBounceEdge) = 0 then
       
  1816                 Gear^.X:= int2hwfloat(leftX + Gear^.Radius);
       
  1817             // Invert horizontal speed
  1813             Gear^.dX.isNegative:= false;
  1818             Gear^.dX.isNegative:= false;
  1814             Gear^.X:= int2hwfloat(leftX + Gear^.Radius);
       
  1815             bounced:= true;
  1819             bounced:= true;
  1816             end
  1820             end
       
  1821         // Bounce right
  1817         else if (hwRound(Gear^.X) + Gear^.Radius > rightX) and (((hwSign(Gear^.dX) = 1) and (not isZero(Gear^.dX))) or (Gear^.Kind = gtHedgehog)) then
  1822         else if (hwRound(Gear^.X) + Gear^.Radius > rightX) and (((hwSign(Gear^.dX) = 1) and (not isZero(Gear^.dX))) or (Gear^.Kind = gtHedgehog)) then
  1818             begin
  1823             begin
  1819             RightImpactTimer:= 333;
  1824             RightImpactTimer:= 333;
       
  1825             // Set X coordinate to bounce edge, unless the gear spawned inside the bounce edge before
       
  1826             if (Gear^.State and gstInBounceEdge) = 0 then
       
  1827                 Gear^.X:= int2hwfloat(rightX - Gear^.Radius);
       
  1828             // Invert horizontal speed
  1820             Gear^.dX.isNegative:= true;
  1829             Gear^.dX.isNegative:= true;
  1821             Gear^.X:= int2hwfloat(rightX-Gear^.Radius);
       
  1822             bounced:= true;
  1830             bounced:= true;
  1823             end;
  1831             end;
       
  1832         // Clear gstInBounceEdge when gear is no longer inside a bounce edge area
       
  1833         if ((Gear^.State and gstInBounceEdge) <> 0) and (hwRound(Gear^.X) - Gear^.Radius >= leftX) and (hwRound(Gear^.X) + Gear^.Radius <= rightX) then
       
  1834             Gear^.State:= Gear^.State and (not gstInBounceEdge);
  1824         if (bounced) then
  1835         if (bounced) then
  1825             begin
  1836             begin
  1826             WorldWrap:= true;
  1837             WorldWrap:= true;
  1827             if (Gear^.dX.QWordValue > _0_001.QWordValue) then
  1838             if (Gear^.dX.QWordValue > _0_001.QWordValue) then
  1828                AddBounceEffectForGear(Gear);
  1839                AddBounceEffectForGear(Gear);