-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.lua
75 lines (63 loc) · 1.87 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
local bill = require("demo.bill")
local lonk = require("demo.lonk")
local luigini = require("demo.luigini")
local currentDemo = lonk
local showHelp = false
function love.keypressed(key, scan, isRepeat)
local handled = false
if not isRepeat then
if key == "1" then
currentDemo = lonk
handled = true
elseif key == "2" then
currentDemo = luigini
handled = true
elseif key == "3" then
currentDemo = bill
handled = true
elseif key == "f1" then
showHelp = not showHelp
end
end
if not handled and currentDemo.keypressed then
currentDemo.keypressed(key, scan, isRepeat)
end
end
function love.mousemoved(...)
if currentDemo.mousemoved then
currentDemo.mousemoved(...)
end
end
function love.update(deltaTime)
if not showHelp then
currentDemo.update(deltaTime)
end
end
local help = [[
slick demo
- press f1 to close help
global controls
- 1: legend of lönk top-down "RPG" demo
- 2: luigini brothers platformer demo
- 3: bill c. triangulation demo
]]
function love.draw()
love.graphics.push("all")
if showHelp then
love.graphics.print(help, 8, 8)
local _, lines = love.graphics.getFont():getWrap(help, love.graphics.getWidth())
love.graphics.translate(0, (#lines + 1) * love.graphics.getFont():getHeight())
if currentDemo.help then
currentDemo.help()
end
else
love.graphics.push("all")
currentDemo.draw()
love.graphics.pop()
love.graphics.setColor(0, 0, 0, 1)
love.graphics.printf("press f1 for help", 1, 9, love.graphics.getWidth(), "center")
love.graphics.setColor(1, 0, 1, 1)
love.graphics.printf("press f1 for help", 0, 8, love.graphics.getWidth(), "center")
end
love.graphics.pop()
end