浏览代码

Allow space to start/next level;

bjorn 10 年之前
父节点
当前提交
dc8d54741e
共有 2 个文件被更改,包括 9 次插入3 次删除
  1. 1 1
      game.lua
  2. 8 2
      pigeon.lua

+ 1 - 1
game.lua

@@ -86,7 +86,7 @@ function Game:keypressed(key)
     ctx.sound:mute()
   elseif key == 'p' then
     self.paused = not self.paused
-  elseif key == 'return' and ctx.hud.win.active then
+  elseif (key == 'return' or key == ' ') and ctx.hud.win.active then
     Context:remove(ctx)
     local world
     local index

+ 8 - 2
pigeon.lua

@@ -145,6 +145,8 @@ function Pigeon:init()
   self.jumps = 0
   self.pecks = 0
 
+  self.peckDirty = false
+
   self:initBeak()
   self:initFeet()
 
@@ -185,6 +187,9 @@ function Pigeon:update()
   skeleton.flipY = false
 
   self.crushGrace = timer.rot(self.crushGrace)
+  if not love.keyboard.isDown(' ') then
+    self.peckDirty = false
+  end
 
   self:updateBeak()
   self:updateFeet()
@@ -252,7 +257,8 @@ function Pigeon:draw()
 end
 
 function Pigeon:keypressed(key)
-  if key == 'return' and self.state == self.idle then
+  if (key == 'return' or key == ' ') and self.state == self.idle then
+    self.peckDirty = key == ' '
     self:changeState('walk')
   end
 end
@@ -507,7 +513,7 @@ function Pigeon.walk:update()
 
   if love.keyboard.isDown('up') then
     return self:changeState('air')
-  elseif love.keyboard.isDown(' ') then
+  elseif love.keyboard.isDown(' ') and not self.peckDirty then
     self:changeState('peck')
   end