make camera in wrap mode a bit smarter
authorsheepluva
Thu, 11 Dec 2014 22:22:40 +0100
changeset 10662 e0d7d499c851
parent 10661 0da243c01bde
child 10663 9bbb29d2bd68
make camera in wrap mode a bit smarter
hedgewars/uWorld.pas
--- a/hedgewars/uWorld.pas	Thu Dec 11 20:46:45 2014 +0100
+++ b/hedgewars/uWorld.pas	Thu Dec 11 22:22:40 2014 +0100
@@ -1867,12 +1867,17 @@
         end
     else
         begin
-        if abs(prevPoint.X - WorldDx - hwRound(FollowGear^.X)) > LongInt(rightX) - leftX - 100 then
+        if (WorldEdge = weWrap) then
+            cameraJump:= LongInt(playWidth) div 2 + 50
+        else
+            cameraJump:= LongInt(rightX) - leftX - 100;
+
+        if abs(prevPoint.X - WorldDx - hwRound(FollowGear^.X)) > cameraJump then
             begin
-            if (prevPoint.X - WorldDx) * 2 < LongInt((rightX + leftX)) then
-                cameraJump:= LongInt(rightX) - leftX
-                else
-                cameraJump:= LongInt(leftX) - rightX;
+            if prevPoint.X - WorldDx < LongInt(playWidth div 2) then
+                cameraJump:= LongInt(playWidth)
+            else
+                cameraJump:= -LongInt(playWidth);
             WorldDx:= WorldDx - cameraJump;
             end;