hedgewars/uTouch.pas
author Xeli
Fri, 19 Aug 2011 03:32:07 +0200
branchhedgeroid
changeset 5605 31bd6e30df02
parent 5599 2e4b90f33a83
child 5609 9d66611e4d0a
permissions -rw-r--r--
Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events Users can no walk left, right, jump up, aim, fire and are limited in zooming
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
     1
{$INCLUDE "options.inc"}
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
     2
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
     3
unit uTouch;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
     4
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
     5
interface
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
     6
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
     7
uses sysutils, math, uConsole, uVariables, SDLh, uTypes, uFloat, uConsts, uIO, uCommands, GLUnit, uCommandHandlers;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
     8
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
     9
procedure initModule;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    10
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    11
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    12
procedure ProcessTouch;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    13
procedure onTouchDown(x,y: Longword; pointerId: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    14
procedure onTouchMotion(x,y: Longword; dx,dy: LongInt; pointerId: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    15
procedure onTouchUp(x,y: Longword; pointerId: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    16
function convertToCursor(scale: LongInt; xy: LongInt): LongInt;
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
    17
procedure addFinger(x,y: Longword; id: SDL_FingerId);
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    18
procedure deleteFinger(id: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    19
procedure onTouchClick(x,y: Longword; pointerId: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    20
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    21
procedure aim(id: SDL_FingerId);
5595
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
    22
function isOnCurrentHog(id: SDL_FingerId): boolean;
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    23
function isOnFireButton(id: SDL_FingerId): boolean;
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    24
procedure convertToWorldCoord(var x,y: hwFloat; id: SDL_FingerId);
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
    25
function fingerHasMoved(id: SDL_FingerId): boolean;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    26
function calculateDelta(id1, id2: SDL_FingerId): hwFloat;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    27
function getSecondPointer(id: SDL_FingerId): SDL_FingerId;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    28
implementation
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    29
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    30
const
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    31
    clicktime = 200;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    32
var
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    33
    leftButtonBoundary  : LongInt;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    34
    rightButtonBoundary : LongInt;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    35
    topButtonBoundary   : LongInt;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    36
    
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    37
    pointerCount : Longword;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    38
    xyCoord : array of LongInt;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    39
    pointerIds : array of SDL_FingerId;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    40
    timeSinceDown: array of Longword;
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
    41
    historicalXY : array of LongInt;
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    42
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    43
    moveCursor : boolean;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    44
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    45
    //Pinch to zoom 
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    46
    pinchSize : hwFloat;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    47
    baseZoomValue: GLFloat;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    48
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
    49
    invertCursor : boolean;
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
    50
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    51
    //aiming
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    52
    aiming, movingCrosshair: boolean; 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    53
    crosshairCommand: ShortString;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    54
    aimingPointerId: SDL_FingerId;
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    55
    targetAngle: LongInt;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    56
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    57
    stopFiring: boolean;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    58
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    59
    //moving
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    60
    stopLeft, stopRight, walkingLeft, walkingRight :  boolean;
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    61
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    62
procedure onTouchDown(x,y: Longword; pointerId: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    63
begin
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
    64
    addFinger(x,y,pointerId);
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    65
    xyCoord[pointerId*2] := convertToCursor(cScreenWidth,x);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    66
    xyCoord[pointerId*2+1] := convertToCursor(cScreenHeight,y);
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    67
    
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    68
   
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
    69
    case pointerCount of
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
    70
        1:
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    71
        begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    72
            moveCursor:= false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    73
            if bShowAmmoMenu then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    74
            begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    75
                moveCursor := true;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    76
                exit;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    77
            end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    78
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    79
            if isOnCurrentHog(pointerId) then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    80
            begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    81
                aiming:= true;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    82
                exit;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    83
            end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    84
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    85
            if isOnFireButton(pointerId) then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    86
            begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    87
                stopFiring:= false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    88
                ParseCommand('+attack', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    89
                exit;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    90
            end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    91
            if xyCoord[pointerId*2] < leftButtonBoundary then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    92
            begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    93
                ParseCommand('+left', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    94
                walkingLeft := true;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    95
                exit;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    96
            end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    97
            if xyCoord[pointerId*2] > rightButtonBoundary then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    98
            begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
    99
                ParseCommand('+right', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   100
                walkingRight:= true;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   101
                exit;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   102
            end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   103
            WriteToConsole(Format('%d, %d', [xyCoord[pointerId*2+1], topButtonBoundary]));    
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   104
            if xyCoord[pointerId*2+1] < topButtonBoundary then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   105
            begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   106
                ParseCommand('hjump', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   107
                exit;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   108
            end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   109
            moveCursor:= true; 
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   110
        end;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   111
        2:
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   112
        begin
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   113
            aiming:= false;
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   114
            stopFiring:= true;
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   115
            
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   116
            pinchSize := calculateDelta(pointerId, getSecondPointer(pointerId));
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   117
            baseZoomValue := ZoomValue
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   118
        end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   119
    end;//end case pointerCount of
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   120
end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   121
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   122
procedure onTouchMotion(x,y: Longword;dx,dy: LongInt; pointerId: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   123
var
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   124
    secondId : SDL_FingerId;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   125
    currentPinchDelta, zoom : hwFloat;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   126
begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   127
    xyCoord[pointerId*2] := convertToCursor(cScreenWidth, x);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   128
    xyCoord[pointerId*2+1] := convertToCursor(cScreenHeight, y);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   129
    
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   130
    case pointerCount of
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   131
       1:
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   132
           begin
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   133
               if aiming then 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   134
               begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   135
                   aim(pointerId);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   136
                   exit
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   137
               end;
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   138
               if moveCursor then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   139
                   if invertCursor then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   140
                   begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   141
                       CursorPoint.X := CursorPoint.X - convertToCursor(cScreenWidth,dx);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   142
                       CursorPoint.Y := CursorPoint.Y + convertToCursor(cScreenWidth,dy);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   143
                   end
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   144
                   else
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   145
                   begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   146
                       CursorPoint.X := CursorPoint.X + convertToCursor(cScreenWidth,dx);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   147
                       CursorPoint.Y := CursorPoint.Y - convertToCursor(cScreenWidth,dy);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   148
                   end;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   149
           end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   150
       2:
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   151
           begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   152
               secondId := getSecondPointer(pointerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   153
               currentPinchDelta := calculateDelta(pointerId, secondId) - pinchSize;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   154
               zoom := currentPinchDelta/cScreenWidth;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   155
               ZoomValue := baseZoomValue - ((hwFloat2Float(zoom) * cMinMaxZoomLevelDelta));
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   156
               if ZoomValue < cMaxZoomLevel then ZoomValue := cMaxZoomLevel;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   157
               if ZoomValue > cMinZoomLevel then ZoomValue := cMinZoomLevel;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   158
            end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   159
    end; //end case pointerCount of
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   160
end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   161
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   162
procedure onTouchUp(x,y: Longword; pointerId: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   163
begin
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   164
    aiming:= false;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   165
    pointerCount := pointerCount-1;
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   166
    stopFiring:= true;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   167
    deleteFinger(pointerId);
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   168
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   169
    if walkingLeft then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   170
    begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   171
        ParseCommand('-left', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   172
        walkingLeft := false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   173
    end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   174
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   175
    if walkingRight then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   176
    begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   177
        ParseCommand('-right', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   178
        walkingRight := false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   179
    end;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   180
end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   181
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   182
procedure onTouchClick(x,y: Longword; pointerId: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   183
begin
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   184
    if bShowAmmoMenu then 
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   185
    begin
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   186
        doPut(CursorPoint.X, CursorPoint.Y, false); 
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   187
        exit
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   188
    end;
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   189
5595
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   190
    if isOnCurrentHog(pointerId) then
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   191
    begin
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   192
        bShowAmmoMenu := true;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   193
        exit;
5595
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   194
    end;
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   195
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   196
    if xyCoord[pointerId*2+1] < topButtonBoundary then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   197
    begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   198
        ParseCommand('hjump', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   199
        exit;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   200
    end;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   201
end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   202
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   203
procedure addFinger(x,y: Longword; id: SDL_FingerId);
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   204
var 
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   205
    index, tmp: Longword;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   206
begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   207
    pointerCount := pointerCount + 1;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   208
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   209
    //Check array sizes
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   210
    if length(pointerIds) < pointerCount then setLength(pointerIds, length(pointerIds)*2);
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   211
    if length(xyCoord) < id*2+1 then 
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   212
    begin 
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   213
        setLength(xyCoord, id*2+1);
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   214
        setLength(historicalXY, id*2+1);
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   215
    end;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   216
    if length(timeSinceDown) < id then setLength(timeSinceDown, id); 
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   217
    for index := 0 to pointerCount do //place the pointer ids as far back to the left as possible
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   218
    begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   219
        if pointerIds[index] = -1 then 
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   220
           begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   221
               pointerIds[index] := id;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   222
               break;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   223
           end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   224
    end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   225
    //set timestamp
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   226
    timeSinceDown[id] := SDL_GetTicks;
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   227
    historicalXY[id*2] := convertToCursor(cScreenWidth,x);
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   228
    historicalXY[id*2+1] := convertToCursor(cScreenHeight,y);
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   229
end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   230
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   231
procedure deleteFinger(id: SDL_FingerId);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   232
var
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   233
    index, i : Longint;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   234
begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   235
    index := 0;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   236
    for index := 0 to pointerCount do
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   237
    begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   238
         if pointerIds[index] = id then
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   239
         begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   240
             pointerIds[index] := -1;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   241
             break;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   242
         end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   243
    end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   244
    //put the last pointerId into the stop of the id to be removed, so that all pointerIds are to the far left
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   245
    for i := pointerCount downto index do
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   246
    begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   247
        if pointerIds[i] <> -1 then
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   248
        begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   249
            pointerIds[index] := pointerIds[i];
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   250
            break;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   251
        end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   252
    end;
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   253
    if ((SDL_GetTicks - timeSinceDown[id]) < clickTime) AND  not(fingerHasMoved(id)) then onTouchClick(xyCoord[id*2], xyCoord[id*2+1], id);
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   254
end;
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   255
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   256
procedure ProcessTouch;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   257
var
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   258
    deltaAngle: LongInt;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   259
begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   260
    invertCursor := not(bShowAmmoMenu);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   261
    if aiming then
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   262
    begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   263
        if CurrentHedgehog^.Gear <> nil then
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   264
        begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   265
            deltaAngle:= CurrentHedgehog^.Gear^.Angle - targetAngle;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   266
            if (deltaAngle <> 0) and not(movingCrosshair) then 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   267
            begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   268
                ParseCommand('+' + crosshairCommand, true);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   269
                movingCrosshair := true;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   270
            end
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   271
            else 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   272
                if movingCrosshair then 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   273
                begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   274
                    ParseCommand('-' + crosshairCommand, true);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   275
                    movingCrosshair:= false;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   276
                end;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   277
        end;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   278
    end
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   279
    else if movingCrosshair then 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   280
    begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   281
        ParseCommand('-' + crosshairCommand, true);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   282
        movingCrosshair := false;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   283
    end;
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   284
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   285
    if stopFiring then 
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   286
    begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   287
        ParseCommand('-attack', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   288
        stopFiring:= false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   289
    end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   290
    
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   291
    if stopRight then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   292
    begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   293
        stopRight := false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   294
        ParseCommand('-right', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   295
    end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   296
 
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   297
    if stopLeft then
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   298
    begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   299
        stopLeft := false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   300
        ParseCommand('-left', true);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   301
    end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   302
    
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   303
end;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   304
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   305
procedure aim(id: SDL_FingerId);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   306
var 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   307
    hogX, hogY, touchX, touchY, deltaX, deltaY, tmpAngle: hwFloat;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   308
    tmp: ShortString;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   309
begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   310
    if CurrentHedgehog^.Gear <> nil then
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   311
    begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   312
        hogX := CurrentHedgehog^.Gear^.X;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   313
        hogY := CurrentHedgehog^.Gear^.Y;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   314
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   315
        convertToWorldCoord(touchX, touchY, id);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   316
        deltaX := hwAbs(TouchX-HogX);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   317
        deltaY := (TouchY-HogY);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   318
        
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   319
        tmpAngle:= DeltaY / Distance(deltaX, deltaY) *_2048;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   320
        targetAngle:= (hwRound(tmpAngle) + 2048) div 2;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   321
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   322
        tmp := crosshairCommand;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   323
        if CurrentHedgehog^.Gear^.Angle - targetAngle < 0 then crosshairCommand := 'down'
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   324
        else crosshairCommand:= 'up';
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   325
        if movingCrosshair and (tmp <> crosshairCommand) then 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   326
        begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   327
            ParseCommand('-' + tmp, true);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   328
            movingCrosshair := false;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   329
        end;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   330
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   331
    end; //if CurrentHedgehog^.Gear <> nil
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   332
end;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   333
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   334
function convertToCursor(scale: LongInt; xy: LongInt): LongInt;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   335
begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   336
    convertToCursor := round(xy/32768*scale)
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   337
end;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   338
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   339
function isOnFireButton(id: SDL_FingerId): boolean;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   340
begin
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   341
    isOnFireButton:= (xyCoord[id*2] < 150) and (xyCoord[id*2+1] > 390);
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   342
end;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   343
5595
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   344
function isOnCurrentHog(id: SDL_FingerId): boolean;
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   345
var
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   346
    x,y, fingerX, fingerY : hwFloat;
5595
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   347
begin
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   348
    x := CurrentHedgehog^.Gear^.X;
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   349
    y := CurrentHedgehog^.Gear^.Y;
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   350
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   351
    convertToWorldCoord(fingerX, fingerY, id);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   352
    isOnCurrentHog := Distance(fingerX-x, fingerY-y) < _20;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   353
end;
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   354
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   355
procedure convertToWorldCoord(var x,y: hwFloat; id: SDL_FingerId);
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   356
begin
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   357
//if x <> nil then 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   358
    x := int2hwFloat((xyCoord[id*2]-WorldDx) - (cScreenWidth div 2));
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   359
//if y <> nil then 
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   360
    y := int2hwFloat(xyCoord[id*2+1]-WorldDy);
5595
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   361
end;
480d451152a5 open ammo when clicking the current hog
Xeli
parents: 5589
diff changeset
   362
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   363
//Method to calculate the distance this finger has moved since the downEvent
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   364
function fingerHasMoved(id: SDL_FingerId): boolean;
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   365
begin
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   366
//    fingerHasMoved := hwAbs(DistanceI(xyCoord[id*2]-historicalXY[id*2], xyCoord[id*2+1]-historicalXY[id*2+1])) > int2hwFloat(2000); // is 1% movement
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   367
    fingerHasMoved := trunc(sqrt(Power(xyCoord[id*2]-historicalXY[id*2],2) + Power(xyCoord[id*2+1]-historicalXY[id*2+1], 2))) > 330;
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   368
end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   369
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   370
function calculateDelta(id1, id2: SDL_FingerId): hwFloat;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   371
begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   372
//    calculateDelta := Distance(xyCoord[id2*2] - xyCoord[id1*2], xyCoord[id2*2+1] - xyCoord[id1*2+1]);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   373
    calculateDelta := int2hwFloat(trunc(sqrt(Power(xyCoord[id2*2]-xyCoord[id1*2],2) + Power(xyCoord[id2*2+1]-xyCoord[id1*2+1], 2))));
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   374
end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   375
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   376
// Under the premise that all pointer ids in pointerIds:SDL_FingerId are pack to the far left.
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   377
// If the pointer to be ignored is not pointerIds[0] the second must be there
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   378
function getSecondPointer(id: SDL_FingerId): SDL_FingerId;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   379
begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   380
    if pointerIds[0] = id then getSecondPointer := pointerIds[1]
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   381
    else getSecondPointer := pointerIds[0];
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   382
end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   383
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   384
procedure initModule;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   385
var
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   386
    index: Longword;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   387
begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   388
    setLength(xyCoord, 10);
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   389
    setLength(pointerIds, 5);
5589
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   390
    setLength(timeSinceDown, 5);
b95d10c82f7f Now able to select a weapon
Xeli
parents: 5579
diff changeset
   391
    setLength(historicalXY, 10);    
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   392
    for index := Low(xyCoord) to High(xyCoord) do xyCoord[index] := -1;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   393
    for index := Low(pointerIds) to High(pointerIds) do pointerIds[index] := -1;
5599
2e4b90f33a83 aiming fixed, inverted cursor on ammo menu, added equal and isZero function to uFloat, changed the way ammo menu opens, you must now click on the hog rather than anywhere on the screen
Xeli
parents: 5595
diff changeset
   394
    movingCrosshair := false;
5605
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   395
    stopFiring:= false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   396
    walkingLeft := false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   397
    walkingRight := false;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   398
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   399
    leftButtonBoundary := cScreenWidth div 4;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   400
    rightButtonBoundary := cScreenWidth div 4*3;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   401
    topButtonBoundary := cScreenHeight div 6;
31bd6e30df02 Added a hook to uGame which now allows uTouch to take action outside of SDL_Finger* events
Xeli
parents: 5599
diff changeset
   402
   
5579
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   403
end;
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   404
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   405
begin
3176ee8a9d94 uTouch, has cursor move, zoom and click or tap to open the ammo menu
Xeli
parents:
diff changeset
   406
end.