--- a/hedgewars/uGearsRender.pas Fri Aug 19 22:31:59 2011 +0200
+++ b/hedgewars/uGearsRender.pas Fri Aug 19 22:40:13 2011 +0200
@@ -188,7 +188,7 @@
procedure DrawHH(Gear: PGear; ox, oy: LongInt);
var i, t: LongInt;
amt: TAmmoType;
- sign, hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt; // hedgehog, crosshair, temp, sprite, direction
+ sign, hx, hy, tx, ty, sx, sy, m: LongInt; // hedgehog, crosshair, temp, sprite, direction
dx, dy, ax, ay, aAngle, dAngle, hAngle, lx, ly: real; // laser, change
defaultPos, HatVisible: boolean;
HH: PHedgehog;
@@ -326,10 +326,12 @@
end;
end;
// draw crosshair
- cx:= Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
- cy:= Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
+ CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
+ CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
+
+
DrawRotatedTex(HH^.Team^.CrosshairTex,
- 12, 12, cx + WorldDx, cy + WorldDy, 0,
+ 12, 12, CrosshairX + WorldDx, CrosshairY + WorldDy, 0,
sign * (Gear^.Angle * 180.0) / cMaxAngle);
end;
hx:= ox + 8 * sign;
--- a/hedgewars/uTouch.pas Fri Aug 19 22:31:59 2011 +0200
+++ b/hedgewars/uTouch.pas Fri Aug 19 22:40:13 2011 +0200
@@ -28,6 +28,7 @@
function findFinger(id: SDL_FingerId): Touch_Finger;
procedure aim(finger: Touch_Finger);
+function isOnCrosshair(finger: Touch_Finger): boolean;
function isOnCurrentHog(finger: Touch_Finger): boolean;
function isOnFireButton(finger: Touch_Finger): boolean;
procedure convertToWorldCoord(var x,y: hwFloat; finger: Touch_Finger);
@@ -87,7 +88,7 @@
exit;
end;
- if isOnCurrentHog(finger) then
+ if isOnCrosshair(finger) then
begin
aiming:= true;
exit;
@@ -358,6 +359,17 @@
isOnFireButton:= (finger.x < 150) and (finger.y > 390);
end;
+function isOnCrosshair(finger: Touch_Finger): boolean;
+var
+ x,y,fingerX, fingerY : hwFloat;
+begin
+ x := int2hwFloat(CrosshairX);
+ y := int2hwFloat(CrosshairY);
+
+ convertToWorldCoord(fingerX, fingerY, finger);
+ isOnCrosshair:= Distance(fingerX-x, fingerY-y) < _20;
+end;
+
function isOnCurrentHog(finger: Touch_Finger): boolean;
var
x,y, fingerX, fingerY : hwFloat;
--- a/hedgewars/uVariables.pas Fri Aug 19 22:31:59 2011 +0200
+++ b/hedgewars/uVariables.pas Fri Aug 19 22:40:13 2011 +0200
@@ -128,6 +128,8 @@
bWaterRising : boolean;
//ShowCrosshair : boolean; This variable is inconvenient to set. Easier to decide when rendering
+ CrosshairX : LongInt;
+ CrosshairY : LongInt;
CursorMovementX : LongInt;
CursorMovementY : LongInt;
cDrownSpeed : hwFloat;