Last active
November 30, 2022 11:21
-
-
Save mika76/46897c2cef856c36b1e4faca07449903 to your computer and use it in GitHub Desktop.
pico-8 - Mouse class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--from https://www.lexaloffle.com/bbs/?tid=3549 | |
mouse = { | |
init = function() | |
poke(0x5f2d, 1) | |
end, | |
-- return int:x, int:y, onscreen:bool | |
pos = function() | |
local x,y = stat(32)-1,stat(33)-1 | |
return stat(32)-1,stat(33)-1 | |
end, | |
-- return int:button [0..4] | |
-- 0 .. no button | |
-- 1 .. left | |
-- 2 .. right | |
-- 4 .. middle | |
button = function() | |
return stat(34) | |
end, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include mouse.lua | |
function _init() | |
mouse.init() | |
end | |
function _draw() | |
cls() | |
local x,y = mouse.pos() | |
local b = mouse.button() | |
print("x:"..x.." y:"..y.." b:"..b) | |
spr(0,x,y) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment