-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
74 lines (66 loc) · 1.74 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
local Controller = require 'controller'
local SharedState = require 'sharedstate'
G_VIEWPORT_BUFFER = 800
function love.load()
_loadFont()
_reset()
end
function love.draw()
love.graphics.push()
-- transform to viewport coords
love.graphics.translate(SharedState.screen.width * 0.5, SharedState.screen.height * 0.5)
love.graphics.translate(SharedState.viewport.x, SharedState.viewport.y)
Controller:draw()
_drawViewportBorder()
love.graphics.pop()
end
function love.update(dt)
Controller:update(dt)
end
function _reset()
SharedState:reset()
Controller:reset()
end
function _drawViewportBorder()
love.graphics.setColor(1, 1, 1, 1)
love.graphics.rectangle(
'line',
0, 0,
SharedState.viewport.width, SharedState.viewport.height
)
love.graphics.setColor(0, 0, 0, 1)
love.graphics.rectangle(
'fill',
-G_VIEWPORT_BUFFER, 0,
G_VIEWPORT_BUFFER, SharedState.viewport.height
)
love.graphics.rectangle(
'fill',
SharedState.viewport.width, 0,
G_VIEWPORT_BUFFER, SharedState.viewport.height
)
love.graphics.rectangle(
'fill',
-G_VIEWPORT_BUFFER, -G_VIEWPORT_BUFFER,
SharedState.viewport.width + 2.0 * G_VIEWPORT_BUFFER, G_VIEWPORT_BUFFER
)
love.graphics.rectangle(
'fill',
-G_VIEWPORT_BUFFER, SharedState.viewport.height,
SharedState.viewport.width + 2.0 * G_VIEWPORT_BUFFER, G_VIEWPORT_BUFFER
)
end
function love.keypressed(...)
Controller:keypressed(...)
end
function _loadFont()
SharedState.font = {}
local fontSizes = {
small = 16,
medium = 24,
big = 72,
}
for name, size in pairs(fontSizes) do
SharedState.font[name] = love.graphics.newFont("x14y24pxHeadUpDaisy.ttf", size)
end
end