Repository navigation
Expand file tree
/
Copy pathStartMenu.lua
More file actions
65 lines (54 loc) · 1.61 KB
/
Copy pathStartMenu.lua
File metadata and controls
65 lines (54 loc) · 1.61 KB
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
--Start menu
local StartMenu = {}
StartMenu.__index = StartMenu
StartMenu.background = love.graphics.newImage('Resources/Backgrounds/interaction.png')
StartMenu.menuOption = love.graphics.newImage('Resources/Images/menuOption.png')
StartMenu.selectedMenuOption = love.graphics.newImage('Resources/Images/selectedMenuOption.png')
function StartMenu:init()
self.image = love.graphics.newImage('Resources/Backgrounds/StartMenu.png')
self.options = {"New Game", "Continue Game"}
self.selected = 1
self.dirty = true
end
function StartMenu:draw()
if self.dirty then
love.graphics.draw(self.image, 0, 0)
for i=1, table.getn(self.options) do
self:drawOption(self.options[i], i, self.selected == i)
end
-- love.graphics.printf("Press any key to start", 0, 250, 800, 'center')
self.dirty = false
end
end
function StartMenu:drawOption(text, pos, isSelected)
if isSelected then
love.graphics.draw(StartMenu.selectedMenuOption, 224, 169 + pos * 65)
else
love.graphics.draw(StartMenu.menuOption, 224, 169 + pos * 65)
end
love.graphics.printf(text, 64, 169 + 15 + pos * 65, 672, 'center')
end
function StartMenu:newScreen()
self = nil
end
function StartMenu:reset()
end
function StartMenu:update(dt)
end
function StartMenu:keyreleased( key )
if key == "up" then
if (self.selected > 1) then
self.selected = self.selected - 1
end
elseif key == "down" then
if (self.selected < table.getn(self.options)) then
self.selected = self.selected + 1
end
elseif key == "space" or key == "return" then
return "Levels/TownGate"
end
self.dirty = true;
end
function StartMenu:keypressed(key)
end
return StartMenu