Log In  

I copied the dev kit mouse into my code, how to I get the variables that the mouse outputs?

function _init()
    poke(0x5f2d, 1)
end

function _draw()
    cls()
    spr(16,stat(32)-1,stat(33)-1)
    print(stat(34))
end
P#42656 2017-07-20 14:59 ( Edited 2017-07-20 19:59)

:: enargy
mouse_x = stat(32)
mouse_y = stat(33)
mouse_buttons = stat(34)

Those give you the x and y coordinates of the mouse. If you didn't see a sprite show up in your example, the reason was probably that you don't have a sprite #16 in your cart.

You can use band() on the mouse_buttons value to see which buttons are being held:

if band(stat(34),1)==1 then
  left_mouse_button=true
else
  left_mouse_button=false
end
if band(stat(34),2)==2 then
  right_mouse_button=true
else
  right_mouse_button=false
end
if band(stat(34),4)==4 then
  middle_mouse_button=true
else
  middle_mouse_button=false
end

Here's an example cart:

Cart #42658 | 2017-07-20 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

P#42659 2017-07-20 15:59 ( Edited 2017-07-20 19:59)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-02-29 14:14 | 0.017s | 2097k | Q:23