Focus camera on moving current hog (probably more important to player). Should make tumbler, sine gun play, attacking off rope and saucer more playable. Also fix a typo in prior offset, and compensate for zoom.
authornemo
Sun, 11 Sep 2011 09:46:22 -0400
changeset 5851 e6151aca2d7c
parent 5850 f07e2a5e6ad0
child 5852 fe010d3a4330
Focus camera on moving current hog (probably more important to player). Should make tumbler, sine gun play, attacking off rope and saucer more playable. Also fix a typo in prior offset, and compensate for zoom.
hedgewars/HHHandlers.inc
hedgewars/uWorld.pas
--- a/hedgewars/HHHandlers.inc	Sun Sep 11 15:38:45 2011 +0200
+++ b/hedgewars/HHHandlers.inc	Sun Sep 11 09:46:22 2011 -0400
@@ -774,6 +774,11 @@
    begin
    if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then Gear^.dY:= _0;
    Gear^.State:= Gear^.State or gstMoving;
+   if (CurrentHedgehog^.Gear = Gear)
+        and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then 
+        begin
+        FollowGear:= Gear;
+        end;
    if isUnderwater then Gear^.dY:= Gear^.dY + cGravity / _2
    else
        begin
--- a/hedgewars/uWorld.pas	Sun Sep 11 15:38:45 2011 +0200
+++ b/hedgewars/uWorld.pas	Sun Sep 11 09:46:22 2011 -0400
@@ -1178,16 +1178,16 @@
 end;
 
 procedure MoveCamera;
-var EdgesDist, wdy, shs: LongInt;
+var EdgesDist, wdy, shs,z: LongInt;
     PrevSentPointTime: LongWord = 0;
 begin
 {$IFNDEF IPHONEOS}
 if (not (CurrentTeam^.ExtDriven and isCursorVisible and not bShowAmmoMenu)) and cHasFocus and (GameState <> gsConfirm) then
     uCursor.updatePosition();
 {$ENDIF}
-
+z:= round(2/zoom);
 if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then
-    if (not autoCameraOn) or (abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4) then
+    if (not autoCameraOn) or ((abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y)) > 4) then
     begin
         FollowGear:= nil;
         prevPoint:= CursorPoint;
@@ -1195,8 +1195,8 @@
     end
     else
     begin
-        CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100 + WorldDx) div 8;
-        CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y)+ hwSign(FollowGear^.dX) * 100 + WorldDy)) div 8;
+        CursorPoint.X:= (prevPoint.X * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100*z + WorldDx) div 8;
+        CursorPoint.Y:= (prevPoint.Y * 7 + cScreenHeight - (hwRound(FollowGear^.Y)+ hwSign(FollowGear^.dY) * 100*z + WorldDy)) div 8;
     end;
 
 wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater;