'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Left, Right, Up, Down As Int
Up = 0 : Right = 1 : Down = 2 : Left = 3
End Sub
Sub GetDirection(TouchMap As Map, G As Gestures, p() As Point) As Point()
Dim px, py As Int
Dim direction As Float
For i = 0 To TouchMap.Size - 1
p(i) = TouchMap.GetValueAt(i)
Next
px = G.GetX(0)
py = G.GetY(0)
If p(0).prevX - px > 2 AND Abs(px - p(0).origX) > 5 Then
direction = Left
Return p
Else If px - p(0).prevX > 2 AND Abs(px - p(0).origX) > 5 Then
direction = Right
Return p
Else If py - p(0).prevY > 2 AND Abs(py - p(0).origY) > 5 Then
direction = Down
Return p
Else If p(0).prevY - py > 2 AND Abs(py - p(0).origY) > 5 Then
direction = Up
Return p
End If
End Sub