From 9c89a970edbb23f673bd23c3b96a0965dc837875 Mon Sep 17 00:00:00 2001 From: bizcochito Date: Wed, 19 Jan 2022 13:28:09 +0100 Subject: [PATCH] remapped debug controls and made them changeable --- data/scripts/keybind.lua | 9 +++++ main.lua | 82 ++++++++++++++++++++-------------------- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/data/scripts/keybind.lua b/data/scripts/keybind.lua index 4f2a349..6682024 100644 --- a/data/scripts/keybind.lua +++ b/data/scripts/keybind.lua @@ -1,6 +1,7 @@ Keybind = {} Keybind.move = {} Keybind.menu = {} +Keybing.debug = {} function Keybind:Check(action) for _, keyname in pairs(action) do @@ -35,6 +36,9 @@ function Keybind:Remove(action) end function Keybind:Default() + --Menu + Keybind.menu.menu = {"escape"} + --Move Keybind.move.left = {"left", "a"} Keybind.move.right = {"right", "d"} Keybind.move.up = {"up", "w"} @@ -42,6 +46,11 @@ function Keybind:Default() Keybind.move.jump = {"z", "space"} Keybind.move.attack = {"x", 1} Keybind.move.dash = {"c", 2} + --Debug + Keybind.debug.debug = {"f1"} + Keybind.debug.reposition = {"f2"} + Keybind.debug.reload = {"f3"} + Keybind.debug.editor = {"f4"} end -- Set default values at start diff --git a/main.lua b/main.lua index 50d0f25..1a0a51e 100644 --- a/main.lua +++ b/main.lua @@ -65,6 +65,46 @@ function love.update(dt) current_dt = dt + --keypressed + if Keybind:Check(Keybind.menu.pause) then + if do_pause then + do_pause = false + else + pausepage = 1 + do_pause = true + end + end + + if Keybind:Check(Keybind.debug.debug) then + if debug then + debug = false + debug_collision = true + elseif debug_collision then + debug_collision = false + else + debug = true + end + end + + if Keybind:Check(Keybind.debug.reposition) then + if not editor_mode then + main_Player.pos.x, main_Player.pos.y = 16,-10 + end + end + + if Keybind:Check(Keybind.debug.reload) then + LoadLevel() + end + + if Keybind:Check(Keybind.debug.editor) then + if editor_mode then + editor_mode = false + else + editor_mode = true + end + end + + --editor if editor_mode then stepEditor() else @@ -84,48 +124,6 @@ function love.wheelmoved(_, y) end end -function love.keypressed(key) - if key == "escape" then - if do_pause then - do_pause = false - else - pausepage = 1 - do_pause = true - end - end - - if key == "f1" then - if debug then - debug = false - debug_collision = true - elseif debug_collision then - debug_collision = false - else - debug = true - end - end - - if key == "f2" then - if editor_mode then - - else - main_Player.pos.x, main_Player.pos.y = 16,-10 - end - end - - if key == "f3" then - LoadLevel() - end - - if key == "f4" then - if editor_mode then - editor_mode = false - else - editor_mode = true - end - end -end - function love.draw() if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then game.width = love.graphics.getWidth()