File: mainmenu.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 (84 lines) | stat: -rw-r--r-- 1,687 bytes parent folder | download | duplicates (2)
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
77
78
79
80
81
82
83
84
mainmenu = {}

local MENU_STRINGS = {
	"START GAME", "HOW TO PLAY", "HIGHSCORES", "OPTIONS", "HISTORY", "EXIT"
}

lg = love.graphics

function mainmenu.enter()
	state = STATE_MAINMENU
	selection = 1
end

function mainmenu.update(dt)
	updateKeys()
end

function mainmenu.draw()
	lg.push()
	lg.scale(config.scale)

	lg.draw(img.splash, quad.screen, 0,0)
	lg.setFont(font.bold)
	for i=1,6 do
		if i == selection then
			lg.print(">", 144, 86+i*13)
		end
		lg.print(MENU_STRINGS[i], 152, 86+i*13)
	end

	lg.pop()
end

function mainmenu.keypressed(k, uni)
	if k == "down" then
		selection = wrap(selection + 1, 1,6)
		playSound("blip")
	elseif k == "up" then
		selection = wrap(selection - 1, 1,6)
		playSound("blip")
	elseif k == "return" or k == " " then
		if selection == 1 then
			levelselection.enter()
		elseif selection == 2 then
			howto.enter()
		elseif selection == 3 then
			highscore_list.enter()
		elseif selection == 4 then
			options.enter()
		elseif selection == 5 then
			history.enter()
		elseif selection == 6 then
			love.event.quit()
		end
		playSound("confirm")
	elseif k == "escape" then
		love.event.quit()
	end
end

function mainmenu.action(k)
	if k == "down" then
		selection = wrap(selection + 1, 1,6)
		playSound("blip")
	elseif k == "up" then
		selection = wrap(selection - 1, 1,6)
		playSound("blip")
	elseif k == "jump" then
		if selection == 1 then
			levelselection.enter()
		elseif selection == 2 then
			howto.enter()
		elseif selection == 3 then
			highscore_list.enter()
		elseif selection == 4 then
			options.enter()
		elseif selection == 5 then
			history.enter()
		elseif selection == 6 then
			love.event.quit()
		end
		playSound("confirm")
	end
end