Browse Source

Press down to drop;

bjorn 10 years ago
parent
commit
0e14f5e8c8
2 changed files with 9 additions and 6 deletions
  1. 1 1
      map.lua
  2. 8 5
      pigeon.lua

+ 1 - 1
map.lua

@@ -21,7 +21,7 @@ function Map:update()
   ctx.view.xmax = self:getMaxX()
   ctx.view.xmax = self:getMaxX()
 
 
   table.each(self.obstacles, function(obstacle)
   table.each(self.obstacles, function(obstacle)
-    if ctx.pigeon.body:getY() + ctx.pigeon.shapeSize / 2 > obstacle.body:getY() - obstacle.height / 2 then
+    if (love.keyboard.isDown('down') and ctx.pigeon.downDirty > 0) or ctx.pigeon.body:getY() + ctx.pigeon.shapeSize / 2 > obstacle.body:getY() - obstacle.height / 2 then
       obstacle.fixture:setCategory(ctx.categories.oneWayPlatform)
       obstacle.fixture:setCategory(ctx.categories.oneWayPlatform)
     else
     else
       obstacle.fixture:setCategory(ctx.categories.ground)
       obstacle.fixture:setCategory(ctx.categories.ground)

+ 8 - 5
pigeon.lua

@@ -90,6 +90,7 @@ function Pigeon:init()
   }
   }
 
 
   self.drop = nil
   self.drop = nil
+  self.downDirty = 0
 
 
   self:initBeak()
   self:initBeak()
   self:initFeet()
   self:initFeet()
@@ -106,6 +107,12 @@ function Pigeon:update()
 
 
   self.animation.speed = love.keyboard.isDown('s') and 2 or 1
   self.animation.speed = love.keyboard.isDown('s') and 2 or 1
 
 
+  if love.keyboard.isDown('down') then
+    self.downDirty = timer.rot(self.downDirty)
+  else
+    self.downDirty = .1
+  end
+
   self:updateBeak()
   self:updateBeak()
   self:updateFeet()
   self:updateFeet()
 end
 end
@@ -407,16 +414,12 @@ function Pigeon.walk:update()
 
 
   if love.keyboard.isDown('up') then
   if love.keyboard.isDown('up') then
     return self:changeState('air')
     return self:changeState('air')
-  elseif love.keyboard.isDown('down') then
+  elseif love.keyboard.isDown(' ') then
     self:changeState('peck')
     self:changeState('peck')
   end
   end
 
 
   if left or right then
   if left or right then
     self:move()
     self:move()
-  elseif love.keyboard.isDown(' ') then
-    self:changeState('laser')
-  else
-    return self:changeState('idle').update(self)
   end
   end
 end
 end