hedgewars/uUtils.pas
changeset 12789 28782e03b8f0
parent 12744 058a5d373e4a
child 12805 6023a4f06013
equal deleted inserted replaced
12788:8aa82e350b8e 12789:28782e03b8f0
   598 // radius is a radius (gear radius) tolerance for an appropriate distance from bouncy world edges.
   598 // radius is a radius (gear radius) tolerance for an appropriate distance from bouncy world edges.
   599 // Set radius to 0 if you don't care.
   599 // Set radius to 0 if you don't care.
   600 function CalcWorldWrap(X, radius: LongInt): LongInt;
   600 function CalcWorldWrap(X, radius: LongInt): LongInt;
   601 begin
   601 begin
   602     if WorldEdge = weWrap then
   602     if WorldEdge = weWrap then
   603         if X < LongInt(leftX) then
   603         begin
   604              X:= X + (LongInt(rightX) - LongInt(leftX))
   604         if X < leftX then
   605         else if X > LongInt(rightX) then
   605              X:= X + (rightX - leftX)
   606              X:= X - (LongInt(rightX) - LongInt(leftX))
   606         else if X > rightX then
       
   607              X:= X - (rightX - leftX);
       
   608         end
   607     else if WorldEdge = weBounce then
   609     else if WorldEdge = weBounce then
   608         if X - radius < LongInt(leftX) then
   610         begin
   609             X:= LongInt(leftX) + radius
   611         if (X + radius) < leftX then
   610         else if X + radius > LongInt(rightX) then
   612             X:= leftX + radius
   611             X:= LongInt(rightX) - radius;
   613         else if (X - radius) > rightX then
       
   614             X:= rightX - radius;
       
   615         end;
   612     CalcWorldWrap:= X;
   616     CalcWorldWrap:= X;
   613 end;
   617 end;
   614 
   618 
   615 function CheckNoTeamOrHH: boolean;
   619 function CheckNoTeamOrHH: boolean;
   616 begin
   620 begin