-
Notifications
You must be signed in to change notification settings - Fork 0
/
success.lua
64 lines (52 loc) · 1.38 KB
/
success.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
-- success.lua: Level complete overlay shown on level completion.
overlays.success = {}
local gui = {
back = {
type = "button",
x = 390, y = 540,
size = { x = 200, y = 96 },
label = S("Back"),
on_click = function()
switchOverlay(false)
switchState("selectlevel")
end
},
nextlevel = {
type = "button",
x = 620, y = 540,
size = { x = 270, y = 96 },
label = S("Next level"),
on_click = function()
-- Increment level and restart game scene, so next level is played.
game.level = game.level + 1
switchOverlay(false)
switchState("game")
end
}
}
function overlays.success.init()
sounds.success:clone():play()
-- If this is the latest level, unlock the next level.
if game.level == game.levelsUnlocked then
game.levelsUnlocked = game.levelsUnlocked + 1
savegame.set('levelsUnlocked', game.levelsUnlocked)
end
end
function overlays.success.update()
gtk.update(gui, true)
end
function overlays.success.draw()
love.graphics.setColor(64/255, 120/255, 161/255,0.9)
love.graphics.rectangle('fill', 380, 20, 520, 680)
love.graphics.setColor(1,1,1,1)
love.graphics.setFont(fonts.sans.bigger)
drawCenteredText(4, 64, base_resolution.x, 64, S("Level Complete!"))
local texts = {
S("Level: %s", game.level),
}
love.graphics.setFont(fonts.sans.medium)
for i = 1, #texts, 1 do
love.graphics.print(texts[i], 420, 4*32+(i*48))
end
gtk.draw(gui, true)
end