Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mouse
#6
(02-22-2024, 11:12 AM)johnno56 Wrote: ... I now know how to "hide" and "position" the mouse... Cool

Have you tried to change the mouse pointer into your avatar ?
Try this one  Big Grin

Code:
'========================================
'              WHAT A MOUSE
'
' Reference : Naalaa's examples folder
'
'========================================

'----------------
' INITIALIZATION
'----------------
set window "set mouse", 640, 480
set redraw off

load image 1,"img/avatar.png"
set image grid 1,4,1

cGray       = [50,50,50]
cWhite      = [255,255,255]

'initial value
top         = 50                   
bottom      = height(primary)-100  
timer       = 0                      
textOffset  = 0 
text2       = "Mouse ON"           
avatar      = 0    
i           = 0  'counter image cell

'--------------
' MAIN PROGRAM
'--------------
while not keydown(KEY_ESCAPE, true)

    set color cGray; cls 'clear screen
    set color cWhite
   
    'Boundary lines
    draw line 0,top,width(primary),top             
    draw line 0,bottom,width(primary),bottom   

    'Text near to top boundary line 
    if mousebutton(1)  then     'right mouse
        timer = clock() + 1000
        text  = "Right button"
    elseif mousebutton(0) then  'left mouse
        timer = clock() + 1000
        text = "Left button"
    elseif mousebutton(2) then  'mouse wheel
        timer = clock() + 1000
        text = "Mouse wheel"
    endif
    set caret 20,15;wln "Mouse button : "; if timer > clock() then wln text 'display 1 second
    set caret width(primary)-250,15;wln "Mouse position : "+mousex()+", "+mousey()
    set caret width(primary)-250,30;wln text2

    'Text near to bottom boundary line
    set caret width(primary)/2, (height(primary)-80)
        center "s = show, h = hide, c = center, j = avatar"
        center "Try using the mouse buttons and wheel!"
        center
        center "Press Esc to quit ..."
           
    if keydown(KEY_S, true)  then
        set mouse on
        text2 = "Mouse ON"
        avatar = 0
    elseif keydown(KEY_H,true) then
        set mouse off   
        text2 = "Mouse OFF"
        avatar = 0
    elseif keydown(KEY_J,true) then
        set mouse off
        text2 = "The Avatar"
        avatar = 1
    endif
    if keydown(KEY_C, true)  then
        set mouse width(primary)/2, height(primary)/2
        posX = width(primary)/2
        posY = height(primary)/2
        textOffset = 0
    else
        textOffset = textOffset + 10*mousebutton(2, true)
        posX = width(primary)/2
        posY = height(primary)/2 + textOffset
        if posY < top     then posY = top+10       
        if posY > bottom  then posY = bottom-10                
    endif

    'Text between top and bottom boundary lines  
    set caret posX, posY; center "Mouse Experiment" 

    if avatar = 1 then
        if i%2=0 then i=0
        draw image 1,mousex()-70/2,mousey()-100/2,i
        i=i+1
    endif
           
    redraw
    fwait 10

wend

Edit : You may test your mouse : left click, right click, wheel, position, hide, show, change mouse pointer


Attached Files
.zip   Mouse.zip (Size: 2.62 KB / Downloads: 5)
Reply


Messages In This Thread
Mouse - by johnno56 - 02-21-2024, 08:34 PM
RE: Mouse - by Tomaaz - 02-21-2024, 11:45 PM
RE: Mouse - by johnno56 - 02-22-2024, 12:41 AM
RE: Mouse - by Tomaaz - 02-22-2024, 07:26 AM
RE: Mouse - by Marcus - 02-23-2024, 06:12 AM
RE: Mouse - by johnno56 - 02-22-2024, 11:12 AM
RE: Mouse - by 1micha.elok - 02-22-2024, 02:55 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)