Merge pull request 'remapped debug controls and made them changeable' (#4) from bizcochito/Mothback:master into master

Reviewed-on: https://git.fai.su/lustlion/Mothback/pulls/4
This commit is contained in:
commit 87e77afaf2
2 changed files with 49 additions and 42 deletions

View File

@ -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

View File

@ -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()