forked from SimonLarsen/mrrescue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
highscore_list.lua
76 lines (67 loc) · 1.78 KB
/
highscore_list.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
highscore_list = {}
local lg = love.graphics
function highscore_list.enter(hllevel, hlpos)
state = STATE_HIGHSCORE_LIST
playMusic("happyfeerings")
highscore_list.level = hllevel or 1
highscore_list.hllevel = hllevel or 0
highscore_list.hlpos = hlpos or 0
end
function highscore_list.update(dt)
updateKeys()
end
function highscore_list.draw()
lg.push()
lg.scale(config.scale)
drawBox(12, 19, 233, 172)
lg.drawq(img.highscore_panes, quad.highscore_pane[highscore_list.level], 0, 9)
local scores = highscores[highscore_list.level]
for i=1, 10 do
if i < 10 then
lg.print(i..".", 31, 14+i*16)
else
lg.print(i..".", 23, 14+i*16)
end
if scores[i] then
if highscore_list.level == highscore_list.hllevel
and highscore_list.hlpos == i then
lg.setColor(25,118,115,255)
lg.print(scores[i].name, 48, 14+i*16)
lg.print(scores[i].score, 105, 14+i*16)
lg.setColor(255,255,255,255)
else
lg.print(scores[i].name, 48, 14+i*16)
lg.print(scores[i].score, 105, 14+i*16)
end
else
lg.print("---", 48, 14+i*16)
end
end
lg.pop()
end
function highscore_list.keypressed(k, uni)
if k == "right" then
highscore_list.level = wrap(highscore_list.level + 1, 1, 3)
playSound("blip")
elseif k == "left" then
highscore_list.level = wrap(highscore_list.level - 1, 1, 3)
playSound("blip")
elseif k == "return" or k == "escape" then
playSound("confirm")
playMusic("opening")
mainmenu.enter()
end
end
function highscore_list.action(k)
if k == "right" then
highscore_list.level = wrap(highscore_list.level + 1, 1, 3)
playSound("blip")
elseif k == "left" then
highscore_list.level = wrap(highscore_list.level - 1, 1, 3)
playSound("blip")
elseif k == "jump" or k == "action" then
playSound("confirm")
playMusic("opening")
mainmenu.enter()
end
end