summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/main.lua b/main.lua
index 6d3fadc..2540c01 100644
--- a/main.lua
+++ b/main.lua
@@ -36,6 +36,7 @@ end
local to_draw
local events = {}
+local handlers = {}
local function event(name)
love[name] = function(...)
@@ -46,6 +47,11 @@ end
function love.update(dt)
to_draw = {}
physics.world:update(dt, 20, 20)
+ for _, e in ipairs(events) do
+ if handlers[e.type] then
+ handlers[e.type](unpack(e))
+ end
+ end
for o in pairs(game.all_objects) do
for _, e in ipairs(events) do
if o[e.type] then
@@ -74,3 +80,14 @@ event "mousepressed"
event "mousereleased"
event "keypressed"
event "keyreleased"
+
+function handlers.keypressed(key)
+ if key == 'tab' and
+ (love.keyboard.isDown 'ralt' or love.keyboard.isDown 'lalt') then
+ love.mouse.setRelativeMode(false)
+ end
+end
+
+function handlers.mousepressed()
+ love.mouse.setRelativeMode(true)
+end