Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pressing mouse buttons
#1
Hi everyone

Making some mouse studies in NaaLaa. Glade to share this code. Feel free to improve it. I am a complete newbie [Image: smile.png]


Code:
import "Keycodes.lib"

constant:
  MOUSE_LEFT 0
  MOUSE_RIGHT 1
  SCREENWIDTH 640
  SCREENHEIGHT 480

hidden:

set window 0, 0, SCREENWIDTH, SCREENHEIGHT, false, 2
set redraw off
set color 0,0,0
cls

eventmouseleftbuttonpressed=0
eventmouserightbuttonpressed=0

do  
  if mousebutton(MOUSE_LEFT)
    eventmouseleftbuttonpressed=1
  else
    eventmouseleftbuttonpressed=0
  endif

  if mousebutton(MOUSE_RIGHT)
    eventmouserightbuttonpressed=1
  else
    eventmouserightbuttonpressed=0
  endif
 
  if eventmouseleftbuttonpressed=1 and eventmouserightbuttonpressed=0
    set color 0,0,0
    cls
    set color 0,255,0
    set caret 10,10
    wln "mouse left button: ON"
    set color 255,0,0
    set caret 10,20
    wln "mouse right button: OFF"
  endif

  if eventmouseleftbuttonpressed=0 and eventmouserightbuttonpressed=1
    set color 0,0,0
    cls
    set color 255,0,0
    set caret 10,10
    wln "mouse left button: OFF"
    set color 0,255,0
    set caret 10,20
    wln "mouse right button: ON"
  endif

  if eventmouseleftbuttonpressed=1 and eventmouserightbuttonpressed=1
    set color 0,0,0
    cls
    set color 0,255,0
    set caret 10,10
    wln "mouse left button: ON"
    set color 0,255,0
    set caret 10,20
    wln "mouse right button: ON"
  endif

  if eventmouseleftbuttonpressed=0 and eventmouserightbuttonpressed=0
    set color 0,0,0
    cls
    set color 255,0,0
    set caret 10,10
    wln "mouse left button: OFF"
    set color 255,0,0
    set caret 10,20
    wln "mouse right button: OFF"
  endif

  redraw
until keydown(VK_ESC) or not running()
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)