Author Topic: Mousehit events  (Read 2981 times)

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5036
  • O Rly?
    • View Profile
Mousehit events
« on: 2010-Feb-14 »
Code: (glbasic) [Select]
FUNCTION InitMousehit: SYSTEM_POINTER = FALSE // Init Mousehits, please call before the While-Wend !
SYSTEMPOINTER SYSTEM_POINTER
GLOBAL __mx, __my, __b1, __b2
GLOBAL __Mhit[]
DIM __Mhit[2][1]
ENDFUNCTION

FUNCTION Mousehit_left: //returns status: 0 = unpressed, 1 = Hit, 2 = Down, -1 = release

IF __Mhit[0][0] = 0 AND MOUSEAXIS(3)
__Mhit[0][0] = 1
ENDIF

RETURN __Mhit[0][0]
ENDFUNCTION

FUNCTION Mousehit_right: //returns status: 0 = unpressed, 1 = Hit, 2 = Down, -1 = release

IF __Mhit[1][0] = 0 AND MOUSEAXIS(4)
__Mhit[1][0] = 1
ENDIF

RETURN __Mhit[1][0]
ENDFUNCTION


FUNCTION MouseX:
RETURN __mx
ENDFUNCTION

FUNCTION MouseY:
RETURN __my
ENDFUNCTION

FUNCTION UpdateMousehit: // Update Mousehits, call befor SHOWSCREEN


MOUSESTATE __mx, __my, __b1, __b2

FOR i = 0 TO 1
IF __Mhit[i][0] = 1 AND MOUSEAXIS(3+i)
__Mhit[i][0] = 2
ENDIF
IF __Mhit[i][0] = -1
__Mhit[i][0] = 0
ENDIF
IF __Mhit[i][0] = 2 AND MOUSEAXIS(3+i) = 0
__Mhit[i][0] = -1
ENDIF
NEXT

ENDFUNCTION
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1786
    • View Profile
    • Homepage
Re: Mousehit events
« Reply #1 on: 2010-Feb-14 »
Nice, the keyhit return codes are slightly different though, mabe make them a bit normalized? :-)
//  0 = not pressed
//  2 = just pressed (hit)
//  1 = pressed (down)
// -1 = release event

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5036
  • O Rly?
    • View Profile
Re: Mousehit events
« Reply #2 on: 2010-Feb-14 »
Nice, the keyhit return codes are slightly different though, mabe make them a bit normalized? :-)
//  0 = not pressed
//  2 = just pressed (hit)
//  1 = pressed (down)
// -1 = release event


you can change it however you want :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 1700 @3.9GHz, 16GB HyperX Fury 3000MHz Ram, ASUS ROG GTX 1060 STRIX 6GB, Windows 10 Pro 64Bit, MSi Tomahawk B350 Mainboard