-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
120 lines (89 loc) · 2.02 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
local input, viewport
function love.load()
local bg = {7, 54, 66}
love.graphics.setBackgroundColor(bg)
require('dependencies')()
math.randomseed(3)
lg.setLineWidth(1)
lg.setLineStyle('smooth')
local id = Identity()
client = ClientManager()
client.id = id
input = InputManager()
manager = ObjectManager(client)
viewport = ViewportManager(manager)
local graph = Graph()
input:register(viewport, 'input', 'keyboard')
input:register(client, 'keyboard')
paused = false
end
function love.update(dt)
input:update(dt)
if not paused then
manager:update(dt)
end
viewport:update(dt)
end
function love.draw()
viewport:draw()
end
function love.mousepressed(x, y, button)
if not love.touch then
input:mousepressed(x, y, button)
end
end
function love.mousereleased(x, y, button)
if not love.touch then
input:mousereleased(x, y, button)
end
end
function love.touchpressed(id, x, y, pressure)
input:touchpressed(id, x, y, pressure)
end
function love.touchreleased(id, x, y, pressure)
input:touchreleased(id, x, y, pressure)
end
function love.keypressed(key, code)
input:keypressed(key, code)
if key == 'escape' then
le.quit()
end
if key == '=' then
local cat = Cat()
end
if key == '-' then
manager:pop()
end
if key == ' ' then
paused = not paused
end
-- emulate left and right mouse buttons
if key == 'lgui' then
local x, y = lm.getPosition()
love.mousepressed(x, y, 'r')
end
if key == 'lalt' then
local x, y = lm.getPosition()
love.mousepressed(x, y, 'l')
end
end
function love.keyreleased(key, code)
input:keyreleased(key, code)
if key == 'lgui' then
local x, y = lm.getPosition()
love.mousereleased(x, y, 'r')
end
if key == 'lalt' then
local x, y = lm.getPosition()
love.mousereleased(x, y, 'l')
end
if key == 'r' then
love.load()
end
end
function love.resize(w, h)
viewport:resize()
end
function love.threaderror(thread, message)
print(message)
end