-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpause.lua
More file actions
42 lines (32 loc) · 702 Bytes
/
Copy pathpause.lua
File metadata and controls
42 lines (32 loc) · 702 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
require "screen"
pause = {}
pause.paused = false
function pause.focus(focused)
pause.setpaused(not focused)
end
function pause.setpaused(paused)
if paused ~= pause.paused and not paused then
screen.centercursor()
end
pause.paused = paused
end
local keyevent = {}
function keyevent.escape()
pause.setpaused(true)
love.mouse.setVisible(true)
return true
end
function pause.keypressed(key)
return keyevent[key] and keyevent[key]()
end
local mouseevent = {}
mouseevent[1] = function(x, y)
if pause.paused then
pause.setpaused(false)
screen.centercursor()
return true
end
end
function pause.mousepressed(x, y, button)
return mouseevent[button] and mouseevent[button](x, y)
end