hedgewars/uWorld.pas
changeset 10917 97f9a25024e6
parent 10871 570af168cc74
child 10939 55ed72ad3a57
equal deleted inserted replaced
10916:2df1c53b30ea 10917:97f9a25024e6
  1704 end;
  1704 end;
  1705 
  1705 
  1706 var PrevSentPointTime: LongWord = 0;
  1706 var PrevSentPointTime: LongWord = 0;
  1707 
  1707 
  1708 procedure MoveCamera;
  1708 procedure MoveCamera;
  1709 var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY, cameraJump: LongInt;
  1709 var EdgesDist, wdy, shs,z, amNumOffsetX, amNumOffsetY, cameraJump, dstX: LongInt;
  1710     inbtwnTrgtAttks: Boolean;
  1710     inbtwnTrgtAttks: Boolean;
  1711 begin
  1711 begin
  1712 {$IFNDEF MOBILE}
  1712 {$IFNDEF MOBILE}
  1713 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) and cHasFocus and (GameState <> gsConfirm) then
  1713 if (not (CurrentTeam^.ExtDriven and isCursorVisible and (not bShowAmmoMenu) and autoCameraOn)) and cHasFocus and (GameState <> gsConfirm) then
  1714     uCursor.updatePosition();
  1714     uCursor.updatePosition();
  1722         prevPoint:= CursorPoint;
  1722         prevPoint:= CursorPoint;
  1723         exit
  1723         exit
  1724         end
  1724         end
  1725     else
  1725     else
  1726         begin
  1726         begin
  1727         if (WorldEdge = weWrap) then
  1727             dstX:= hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * z + WorldDx;
  1728             cameraJump:= LongInt(playWidth) div 2 + 50
  1728 
  1729         else
  1729             if (WorldEdge = weWrap) then
  1730             cameraJump:= LongInt(rightX) - leftX - 100;
  1730                 begin
  1731 
  1731                     if dstX - prevPoint.X < (LongInt(leftX) - rightX) div 2 then
  1732         if abs(prevPoint.X - WorldDx - hwRound(FollowGear^.X)) > cameraJump then
  1732                         CursorPoint.X:= (prevPoint.X * 7 + dstX - (leftX - rightX)) div 8
  1733             begin
  1733                     else if dstX - prevPoint.X > (LongInt(rightX) - leftX) div 2 then
  1734             if prevPoint.X - WorldDx < LongInt(playWidth div 2) then
  1734                         CursorPoint.X:= (prevPoint.X * 7 + dstX - (rightX - leftX)) div 8
  1735                 cameraJump:= LongInt(playWidth)
  1735                     else
  1736             else
  1736                         CursorPoint.X:= (prevPoint.X * 7 + dstX) div 8;
  1737                 cameraJump:= -LongInt(playWidth);
  1737                 end
  1738             WorldDx:= WorldDx - cameraJump;
  1738             else // usual camera movement routine
  1739             end;
  1739                 begin
  1740 
  1740                     CursorPoint.X:= (prevPoint.X * 7 + dstX) div 8;
  1741         CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * z + WorldDx) div 8;
  1741                 end;
  1742 
  1742 
  1743         if isPhone() or (cScreenHeight < 600) or ((hwSign(FollowGear^.dY) * z) < 10)  then
  1743         if isPhone() or (cScreenHeight < 600) or ((FollowGear^.dY * z).Round < 10) then
  1744             CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8
  1744             CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8
  1745         else
  1745         else
  1746             CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + hwSign(FollowGear^.dY) * z + WorldDy)) div 8;
  1746             CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + hwSign(FollowGear^.dY) * z + WorldDy)) div 8;
  1747         end;
  1747         end;
       
  1748 
       
  1749 if (WorldEdge = weWrap) then
       
  1750     begin
       
  1751         if -WorldDx < leftX then
       
  1752             WorldDx:= WorldDx - LongInt(rightX) + leftX
       
  1753         else if -WorldDx > rightX then
       
  1754             WorldDx:= WorldDx + LongInt(rightX) - leftX;
       
  1755     end;
  1748 
  1756 
  1749 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater;
  1757 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater;
  1750 if WorldDy < wdy then
  1758 if WorldDy < wdy then
  1751     WorldDy:= wdy;
  1759     WorldDy:= wdy;
  1752 
  1760