|
@@ -23,7 +23,10 @@ function Menu:load()
|
|
|
|
|
|
joystick = #love.joystick.getJoysticks() > 0 and love.joystick.getJoysticks()[1]
|
|
joystick = #love.joystick.getJoysticks() > 0 and love.joystick.getJoysticks()[1]
|
|
|
|
|
|
- self.selectedButton = 'play'
|
|
|
|
|
|
+ self.selectedIndex = 1
|
|
|
|
+
|
|
|
|
+ self.selectedWorld = 'dinoland'
|
|
|
|
+ self.selectedIndex = 1
|
|
end
|
|
end
|
|
|
|
|
|
function Menu:update()
|
|
function Menu:update()
|
|
@@ -38,6 +41,7 @@ end
|
|
|
|
|
|
function Menu:draw()
|
|
function Menu:draw()
|
|
local g = love.graphics
|
|
local g = love.graphics
|
|
|
|
+ local gw, gh = love.graphics.getDimensions()
|
|
g.push()
|
|
g.push()
|
|
g.translate(0, -300)
|
|
g.translate(0, -300)
|
|
self.map:draw()
|
|
self.map:draw()
|
|
@@ -49,21 +53,88 @@ function Menu:draw()
|
|
g.setColor(0, 0, 0, 100)
|
|
g.setColor(0, 0, 0, 100)
|
|
g.rectangle('fill', 0, 0, g.getDimensions())
|
|
g.rectangle('fill', 0, 0, g.getDimensions())
|
|
|
|
|
|
|
|
+ g.setFont('media/fonts/handDrawnShapes.ttf', 100)
|
|
|
|
+ local str = 'FOWL PLAY'
|
|
|
|
+ g.setColor(0, 0, 0)
|
|
|
|
+ g.print(str, g.getWidth() / 2 - g.getFont():getWidth(str) / 2 + 2, 100 + 2)
|
|
|
|
+ g.setColor(255, 255, 255)
|
|
|
|
+ g.print(str, g.getWidth() / 2 - g.getFont():getWidth(str) / 2, 100)
|
|
|
|
+
|
|
|
|
+ g.setColor(255, 255, 255)
|
|
|
|
+
|
|
|
|
+ local font = g.setFont('media/fonts/handDrawnShapes.ttf', 60)
|
|
|
|
+
|
|
|
|
+ --
|
|
|
|
+ local str = 'Play'
|
|
|
|
+ local sw = font:getWidth(str)
|
|
|
|
+ local sh = font:getHeight()
|
|
|
|
+ if self.selectedIndex == 1 then
|
|
|
|
+ g.rectangle('line', gw / 2 - sw / 2 - 10, 250 - 10, sw + 20, sh + 20)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ g.setColor(0, 0, 0)
|
|
|
|
+ g.print(str, gw / 2 - g.getFont():getWidth(str) / 2 + 2, 250 + 2)
|
|
|
|
+ g.setColor(255, 255, 255)
|
|
|
|
+ g.print(str, gw / 2 - g.getFont():getWidth(str) / 2, 250)
|
|
|
|
+
|
|
|
|
+ --
|
|
|
|
+ local str = self.worldIndex .. '-' .. self.levelIndex
|
|
|
|
+ local sw = font:getWidth(str)
|
|
|
|
+ local sh = font:getHeight()
|
|
|
|
+ if self.selectedIndex == 2 then
|
|
|
|
+ g.rectangle('line', gw / 2 - sw / 2 - 10, 350 - 10, sw + 20, sh + 20)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ g.setColor(0, 0, 0)
|
|
|
|
+ g.print(str, gw / 2 - sw / 2 + 2, 350 + 2)
|
|
g.setColor(255, 255, 255)
|
|
g.setColor(255, 255, 255)
|
|
- g.print('FOWL PLAY\npress space', g.getWidth() / 2 - g.getFont():getWidth('PIGEON') / 2, 200)
|
|
|
|
|
|
+ g.print(str, gw / 2 - sw / 2, 350)
|
|
|
|
+
|
|
|
|
+ --
|
|
|
|
+ local str = 'Quit'
|
|
|
|
+ local sw = font:getWidth(str)
|
|
|
|
+ local sh = font:getHeight()
|
|
|
|
+ if self.selectedIndex == 3 then
|
|
|
|
+ g.rectangle('line', gw / 2 - sw / 2 - 10, 450 - 10, sw + 20, sh + 20)
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ g.setColor(0, 0, 0)
|
|
|
|
+ g.print(str, gw / 2 - sw / 2 + 2, 450 + 2)
|
|
|
|
+ g.setColor(255, 255, 255)
|
|
|
|
+ g.print(str, gw / 2 - sw / 2, 450)
|
|
end
|
|
end
|
|
|
|
|
|
function Menu:keypressed(key)
|
|
function Menu:keypressed(key)
|
|
if key == 'escape' then love.event.quit() end
|
|
if key == 'escape' then love.event.quit() end
|
|
|
|
|
|
- if key == 'left' then
|
|
|
|
-
|
|
|
|
|
|
+ if key == 'up' then
|
|
|
|
+ self.selectedIndex = self.selectedIndex - 1
|
|
|
|
+ if self.selectedIndex <= 0 then self.selectedIndex = 3 end
|
|
|
|
+ elseif key == 'down' then
|
|
|
|
+ self.selectedIndex = self.selectedIndex + 1
|
|
|
|
+ if self.selectedIndex > 3 then self.selectedIndex = 1 end
|
|
|
|
+ elseif key == ' ' or key == 'return' then
|
|
|
|
+ if self.selectedIndex == 1 then
|
|
|
|
+ local world = ({'Dinoland', 'Kingdumb'})[self.worldIndex]
|
|
|
|
+ Context:remove(ctx)
|
|
|
|
+ Context:add(Game, world, self.levelIndex)
|
|
|
|
+ return
|
|
|
|
+ elseif self.selectedIndex == 2 then
|
|
|
|
+ love.event.quit()
|
|
|
|
+ end
|
|
|
|
+ elseif key == 'left' then
|
|
|
|
+ self.levelIndex = self.levelIndex - 1
|
|
|
|
+ if self.levelIndex <= 0 then
|
|
|
|
+ self.levelIndex = 3
|
|
|
|
+ if self.worldIndex == 1 then self.worldIndex = 2
|
|
|
|
+ else self.worldIndex = 1 end
|
|
|
|
+ end
|
|
elseif key == 'right' then
|
|
elseif key == 'right' then
|
|
-
|
|
|
|
- elseif key == ' ' then
|
|
|
|
- local world = ({'Dinoland', 'Kingdumb'})[self.worldIndex]
|
|
|
|
- Context:remove(ctx)
|
|
|
|
- Context:add(Game, world, self.levelIndex)
|
|
|
|
- return
|
|
|
|
|
|
+ self.levelIndex = self.levelIndex + 1
|
|
|
|
+ if self.levelIndex > 3 then
|
|
|
|
+ self.levelIndex = 1
|
|
|
|
+ if self.worldIndex == 1 then self.worldIndex = 2
|
|
|
|
+ else self.worldIndex = 1 end
|
|
|
|
+ end
|
|
end
|
|
end
|
|
end
|
|
end
|