-
Notifications
You must be signed in to change notification settings - Fork 0
/
keybinds.lua
40 lines (33 loc) · 832 Bytes
/
keybinds.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local Keybind = {}
Keybind.__index = Keybind
function Keybind.new(...)
local self = setmetatable({}, Keybind)
self.keys = {...}
return self
end
function Keybind:isDown()
for _, key in ipairs(self.keys) do
if love.keyboard.isDown(key) then
return true
end
end
return false
end
function Keybind:hasKey(pressedKey)
for _, key in ipairs(self.keys) do
if pressedKey == key then
return true
end
end
return false
end
local keybinds = {
moveLeft = Keybind.new('left'),
moveRight = Keybind.new('right'),
rotateClockwise = Keybind.new('up', 'x'),
rotateCounterClockwise = Keybind.new('z', 'lctrl'),
softDrop = Keybind.new('down'),
hardDrop = Keybind.new('space'),
hold = Keybind.new('c', 'lshift')
}
return keybinds