File: highscore_list.lua

package info (click to toggle)
mrrescue 1.02e-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 13,228 kB
  • sloc: makefile: 9; sh: 1
file content (76 lines) | stat: -rw-r--r-- 1,825 bytes parent folder | download
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.draw(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/255,118/255,115/255,1)
				lg.print(scores[i].name,   48, 14+i*16)
				lg.print(scores[i].score, 105, 14+i*16)
				lg.setColor(1,1,1,1)
			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