2022-01-18 19:47:55 +00:00
|
|
|
Keybind = {}
|
|
|
|
Keybind.move = {}
|
|
|
|
Keybind.menu = {}
|
2022-01-19 12:28:09 +00:00
|
|
|
Keybing.debug = {}
|
2022-01-17 23:14:54 +00:00
|
|
|
|
2022-01-18 19:47:55 +00:00
|
|
|
function Keybind:Check(action)
|
|
|
|
for _, keyname in pairs(action) do
|
2022-01-18 15:49:49 +00:00
|
|
|
if type(keyname) == "string" then
|
|
|
|
if love.keyboard.isDown(keyname) then return true end
|
|
|
|
else
|
|
|
|
if love.mouse.isDown(keyname) then return true end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2022-01-18 19:47:55 +00:00
|
|
|
function Keybind:Colision(cat, key)
|
|
|
|
for _, action in pairs(cat) do
|
|
|
|
for _, keyname in pairs(action) do
|
|
|
|
if key == keyname then return true end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
function Keybind:Add(action, key)
|
|
|
|
table.insert(action, key)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Keybind:Change(action, position, key)
|
|
|
|
action[position] = key
|
|
|
|
end
|
|
|
|
|
|
|
|
function Keybind:Remove(action)
|
|
|
|
action = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
function Keybind:Default()
|
2022-01-19 12:28:09 +00:00
|
|
|
--Menu
|
|
|
|
Keybind.menu.menu = {"escape"}
|
|
|
|
--Move
|
2022-01-18 19:47:55 +00:00
|
|
|
Keybind.move.left = {"left", "a"}
|
|
|
|
Keybind.move.right = {"right", "d"}
|
|
|
|
Keybind.move.up = {"up", "w"}
|
|
|
|
Keybind.move.down = {"down", "s"}
|
|
|
|
Keybind.move.jump = {"z", "space"}
|
|
|
|
Keybind.move.attack = {"x", 1}
|
|
|
|
Keybind.move.dash = {"c", 2}
|
2022-01-19 12:28:09 +00:00
|
|
|
--Debug
|
|
|
|
Keybind.debug.debug = {"f1"}
|
|
|
|
Keybind.debug.reposition = {"f2"}
|
|
|
|
Keybind.debug.reload = {"f3"}
|
|
|
|
Keybind.debug.editor = {"f4"}
|
2022-01-18 19:47:55 +00:00
|
|
|
end
|
2022-01-18 15:49:49 +00:00
|
|
|
|
2022-01-18 19:47:55 +00:00
|
|
|
-- Set default values at start
|
|
|
|
Keybind:Default()
|