I am making a frogger game and I am trying to emulate joystick movement on the mouse. The reason for this is I am trying to make the basic 4 directional control work with head tracking software for people who aren't capable of using traditional control devices.
Here is what sort of works (without any sensitivity control added). Basically I am checking the current speed of X and Y and fidning out which is greater (to eliminate moving the joystick in 2 directions at once), then I am just checking to see if the mouse has moved in a direction. I reset all previous directions set before I do the new test. This works but needs sensitivity controls and if the mouse pointer hits the edge of the screen then it stops the control from working:
; check mouse
cur_mouse_x = MouseXSpeed()
cur_mouse_y = MouseYSpeed()
;reset previous directions
mouse_left = 0
mouse_right = 0
mouse_up = 0
mouse_down = 0
;check if up/down or side movement is greater
If Abs(cur_mouse_x) > Abs(cur_mouse_y)
If cur_mouse_x < -1 Then mouse_left = 1
If cur_mouse_x > 1 Then mouse_right = 1
Else
If cur_mouse_y < -1 Then mouse_up = 1
If cur_mouse_y > 1 Then mouse_down = 1
End If
Here is what sort of works (without any sensitivity control added). Basically I am checking the current speed of X and Y and fidning out which is greater (to eliminate moving the joystick in 2 directions at once), then I am just checking to see if the mouse has moved in a direction. I reset all previous directions set before I do the new test. This works but needs sensitivity controls and if the mouse pointer hits the edge of the screen then it stops the control from working:
; check mouse
cur_mouse_x = MouseXSpeed()
cur_mouse_y = MouseYSpeed()
;reset previous directions
mouse_left = 0
mouse_right = 0
mouse_up = 0
mouse_down = 0
;check if up/down or side movement is greater
If Abs(cur_mouse_x) > Abs(cur_mouse_y)
If cur_mouse_x < -1 Then mouse_left = 1
If cur_mouse_x > 1 Then mouse_right = 1
Else
If cur_mouse_y < -1 Then mouse_up = 1
If cur_mouse_y > 1 Then mouse_down = 1
End If