2022-01-18 19:47:55 +00:00
|
|
|
Keybind = {}
|
|
|
|
Keybind.move = {}
|
|
|
|
Keybind.menu = {}
|
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()
|
|
|
|
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}
|
|
|
|
end
|
2022-01-18 15:49:49 +00:00
|
|
|
|
2022-01-18 19:47:55 +00:00
|
|
|
-- Set default values at start
|
|
|
|
Keybind:Default()
|