-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.lua
More file actions
51 lines (42 loc) · 946 Bytes
/
Copy pathinput.lua
File metadata and controls
51 lines (42 loc) · 946 Bytes
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
41
42
43
44
45
46
47
48
49
50
51
local input = {}
local lastKey = {}
local lastButton = {}
function love.mousepressed(x, y, button, istouch)
lastButton = button
end
function love.keypressed(key)
lastKey = key
end
function input.getMouse()
return love.mouse.getX(), love.mouse.getY()
end
function input.mouseOver(rect)
local x, y = input.getMouse()
if
x > rect.xPos and x < rect.xPos + rect.width and y > rect.yPos and
y < rect.yPos + rect.height
then
return true
end
return false
end
function input.getLeftClick()
if lastButton == 1 then
lastButton = nil
return true
end
end
function input.getMenuInput()
local lastMenu = lastKey
lastKey = nil
if lastMenu == "up" or lastMenu == "down" or lastMenu == "return" then
return lastMenu
end
end
function input.getEsc()
if lastKey == "escape" then
lastKey = nil
return true
end
end
return input