isOnCurrentHog and isOnCrosshair now look at the distance relative to the screen rather than world coords, this means that zooming out doesn't make it harder to touch the hog or crosshair hedgeroid
authorXeli
Fri, 16 Sep 2011 20:39:14 +0200
branchhedgeroid
changeset 5938 c186c454779d
parent 5936 849f01d63538
child 5941 db4751cb4f53
isOnCurrentHog and isOnCrosshair now look at the distance relative to the screen rather than world coords, this means that zooming out doesn't make it harder to touch the hog or crosshair
hedgewars/uTouch.pas
--- a/hedgewars/uTouch.pas	Fri Sep 16 20:38:23 2011 +0200
+++ b/hedgewars/uTouch.pas	Fri Sep 16 20:39:14 2011 +0200
@@ -51,6 +51,7 @@
 function isOnCurrentHog(finger: Touch_Finger): boolean;
 function isOnFireButton(finger: Touch_Finger): boolean;
 procedure convertToWorldCoord(var x,y: hwFloat; finger: Touch_Finger);
+procedure convertToFingerCoord(var x,y: hwFloat; oldX, oldY: hwFloat);
 function fingerHasMoved(finger: Touch_Finger): boolean;
 function calculateDelta(finger1, finger2: Touch_Finger): hwFloat;
 function getSecondFinger(finger: Touch_Finger): PTouch_Finger;
@@ -417,24 +418,24 @@
 
 function isOnCrosshair(finger: Touch_Finger): boolean;
 var
-    x,y,fingerX, fingerY : hwFloat;
+    x,y : hwFloat;
 begin
-    x := int2hwFloat(CrosshairX);
-    y := int2hwFloat(CrosshairY);
-
-    convertToWorldCoord(fingerX, fingerY, finger);
-    isOnCrosshair:= Distance(fingerX-x, fingerY-y) < _20;
+    convertToFingerCoord(x, y, int2hwFloat(CrosshairX), int2hwFloat(CrosshairY));
+    isOnCrosshair:= Distance(int2hwFloat(finger.x)-x, int2hwFloat(finger.y)-y) < _50;
 end;
 
 function isOnCurrentHog(finger: Touch_Finger): boolean;
 var
-    x,y, fingerX, fingerY : hwFloat;
+    x,y : hwFloat;
 begin
-    x := CurrentHedgehog^.Gear^.X;
-    y := CurrentHedgehog^.Gear^.Y;
+    convertToFingerCoord(x, y, CurrentHedgehog^.Gear^.X, CurrentHedgehog^.Gear^.Y);
+    isOnCurrentHog := Distance(int2hwFloat(finger.X)-x, int2hwFloat(finger.Y)-y) < _50;
+end;
 
-    convertToWorldCoord(fingerX, fingerY, finger);
-    isOnCurrentHog := Distance(fingerX-x, fingerY-y) < _20;
+procedure convertToFingerCoord(var x,y : hwFloat; oldX, oldY: hwFloat);
+begin
+    x := oldX + int2hwFloat(WorldDx + (cScreenWidth div 2));
+    y := oldY + int2hwFloat(WorldDy);
 end;
 
 procedure convertToWorldCoord(var x,y: hwFloat; finger: Touch_Finger);