Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QuickMouse
#1
I was talking to someone on Discord earlier today, and they were looking for a simple little routine to add directional movement and pew-pews to a game, using a mouse.  They had a routine, but it was rather laggy and didn't work quite right for me, so I wrote this little demo for them and thought I'd share it here in case anyone else might need something really simple like this:

Code: (Select All)
Dim Shared As Long MB1, MB2, MMX, MMY
Const Drift = 5 'change the drift value for how lenient you want to be for your directional wandering of the mouse movement

_MouseHide
Do
quickmouse
If MMX < -Drift Then Print "LEFT"
If MMX > Drift Then Print "RIGHT"
If MMY < -Drift Then Print "UP"
If MMY > Drift Then Print "DOWN"
If MB1 Then Print "PEW PEW"
If MB2 Then Print "BYE BYE": System
_Limit 15
Loop

Sub quickmouse
Static omb1, omb2 'old mouse buttons
MB1 = _FALSE: MB2 = _FALSE 'mouse buttons
MMX = 0: MMY = 0
While _MouseInput
MMX = MMX + _MouseMovementX
MMY = MMY + _MouseMovementY
Wend
If _MouseButton(1) And Not omb1 Then MB1 = _TRUE
If _MouseButton(2) And Not omb2 Then MB2 = _TRUE
omb1 = _MouseButton(1): omb2 = _MouseButton(2)
End Sub
Reply




Users browsing this thread: 1 Guest(s)