-
-
Save microloop/a4da0d0a442e016707796adc897870f0 to your computer and use it in GitHub Desktop.
Mouse Handler Object (PICO-8, Lua)
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
| Mouse = {} | |
| function Mouse:new(o) | |
| o = o or {} | |
| o.posx = o.posx or 10 | |
| o.posy = o.posy or 20 | |
| o.mapx = flr(o.posx / 8) | |
| o.mapy = flr(o.posy / 8) | |
| o.busy_hand = false | |
| o.sprite = 8 | |
| o.sprite_pressed = 9 | |
| o.btnpressed = 0 | |
| o.mouseover = 0 | |
| o.grabbed_item = 0 | |
| o.reload = function () end | |
| o.modes = { | |
| pointer = function(mouse) mouse:pointer() end, | |
| ground = function(mouse) mouse:ground() end, | |
| rubber = function(mouse) mouse:rubber() end | |
| } | |
| o.drawing = { | |
| pointer = function(mouse) mouse:pointer_draw() end, | |
| ground = function(mouse) mouse:ground_draw() end, | |
| rubber = function(mouse) mouse:rubber_draw() end | |
| } | |
| o.current_draw = o.drawing.pointer | |
| o.previous_mode = o.modes.pointer | |
| o.current_mode = o.modes.pointer | |
| o.animation_player = nil | |
| o.last_click_x = 0 | |
| o.last_click_y = 0 | |
| setmetatable(o, {__index = self}) | |
| return o | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment