Skip to content

Instantly share code, notes, and snippets.

@mika76
Last active November 30, 2022 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mika76/46897c2cef856c36b1e4faca07449903 to your computer and use it in GitHub Desktop.
Save mika76/46897c2cef856c36b1e4faca07449903 to your computer and use it in GitHub Desktop.
pico-8 - Mouse class
--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,
}
#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