bjorn 10 년 전
부모
커밋
e94ec93d5b
3개의 변경된 파일106개의 추가작업 그리고 13개의 파일을 삭제
  1. 17 2
      game.lua
  2. 8 1
      hud.lua
  3. 81 10
      menu.lua

+ 17 - 2
game.lua

@@ -74,6 +74,20 @@ function Game:update()
 
   ls.timescale = love.keyboard.isDown('r') and 5 or 1
 
+  if joystick then
+    if ctx.hud.win.active and joystick:isGamepadDown('a') then
+      self:keypressed('return')
+    elseif joystick:isGamepadDown('back') then
+      self:keypressed('escape')
+    elseif joystick:isGamepadDown('start') then
+      if ctx.hud.win.active then
+        ctx.hud:share()
+      else
+        self:keypressed('p')
+      end
+    end
+  end
+
   lurker.update()
 end
 
@@ -85,12 +99,13 @@ end
 
 function Game:keypressed(key)
   if key == 'escape' then
-    love.event.quit()
+    Context:remove(ctx)
+    Context:add(Menu)
   elseif key == 'm' then
     ctx.sound:mute()
   elseif key == 'p' then
     self.paused = not self.paused
-  elseif (key == 'return' or key == ' ') and ctx.hud.win.active then
+  elseif ctx.hud.win.active and (key == 'return' or key == ' ') then
     if self.backgroundSound then self.backgroundSound:stop() end
     Context:remove(ctx)
     local world

+ 8 - 1
hud.lua

@@ -395,7 +395,7 @@ function Hud:gui()
     end
 
     local alpha = math.abs(math.sin((ls.tick + ls.accum / ls.tickrate) / 25))
-    local str = 'Press space to continue'
+    local str = 'Press ' .. (joystick and 'A' or 'space') .. ' to continue'
     g.setFont('media/fonts/handDrawnShapes.ttf', 30)
     g.setColor(0, 0, 0, alpha * 255)
     g.print(str, x - g.getFont():getWidth(str) / 2 + 2, gh - 55 + 2)
@@ -480,3 +480,10 @@ function Hud:activateWin()
   end)
   self.scoreDisplay = 0
 end
+
+function Hud:share()
+  local level = ctx.map.name == 'dinoland' and 1 or 2
+  level = tostring(level) .. '-' .. tostring(ctx.map.index)
+  local url = 'http://twitter.com/intent/tweet?text=I%20got%20a%20new%20highscore%20of%20' .. math.round(self.scoreDisplay) .. '%20points%20on%20level%20' .. level .. '%20of%20%23FowlPlay!%20%20%23RobotPigeon'
+  love.system.openURL(url)
+end

+ 81 - 10
menu.lua

@@ -23,7 +23,10 @@ function Menu:load()
 
   joystick = #love.joystick.getJoysticks() > 0 and love.joystick.getJoysticks()[1]
 
-  self.selectedButton = 'play'
+  self.selectedIndex = 1
+
+  self.selectedWorld = 'dinoland'
+  self.selectedIndex = 1
 end
 
 function Menu:update()
@@ -38,6 +41,7 @@ end
 
 function Menu:draw()
   local g = love.graphics
+  local gw, gh = love.graphics.getDimensions()
   g.push()
   g.translate(0, -300)
   self.map:draw()
@@ -49,21 +53,88 @@ function Menu:draw()
   g.setColor(0, 0, 0, 100)
   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.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
 
 function Menu:keypressed(key)
   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 == ' ' 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