Browse Source

Start with start;

bjorn 10 years ago
parent
commit
ca0526ceb4
2 changed files with 10 additions and 5 deletions
  1. 6 0
      menu.lua
  2. 4 5
      pigeon.lua

+ 6 - 0
menu.lua

@@ -21,6 +21,8 @@ function Menu:load()
     ctx.enemies:add(Caveman, {x = 0 + love.math.random() * love.graphics.getWidth(), y = self.map.height - self.map.ground.height})
     ctx.enemies:add(Caveman, {x = 0 + love.math.random() * love.graphics.getWidth(), y = self.map.height - self.map.ground.height})
   end
   end
 
 
+  joystick = #love.joystick.getJoysticks() > 0 and love.joystick.getJoysticks()[1]
+
   self.selectedButton = 'play'
   self.selectedButton = 'play'
 end
 end
 
 
@@ -28,6 +30,10 @@ function Menu:update()
   self.map:update()
   self.map:update()
   self.enemies:update()
   self.enemies:update()
   self.world:update(ls.tickrate)
   self.world:update(ls.tickrate)
+
+  if joystick and joystick:isGamepadDown('start') then
+    self:keypressed(' ')
+  end
 end
 end
 
 
 function Menu:draw()
 function Menu:draw()

+ 4 - 5
pigeon.lua

@@ -154,7 +154,6 @@ function Pigeon:init()
 
 
   self.rainbowShitTimer = 0
   self.rainbowShitTimer = 0
 
 
-  self.joystick = #love.joystick.getJoysticks() > 0 and love.joystick.getJoysticks()[1]
 
 
   ctx.event:emit('view.register', {object = self, depth = -10})
   ctx.event:emit('view.register', {object = self, depth = -10})
 end
 end
@@ -173,7 +172,7 @@ function Pigeon:update()
     flux.to(self.animation, .2, {scale = .7}, 'elasticout')
     flux.to(self.animation, .2, {scale = .7}, 'elasticout')
   end)
   end)
 
 
-  if love.keyboard.isDown('down', 's') or (self.joystick and (self.joystick:getGamepadAxis('lefty') > .5) or (self.joystick:isGamepadDown('dpdown'))) then
+  if love.keyboard.isDown('down', 's') or (joystick and (joystick:getGamepadAxis('lefty') > .5 or (joystick:isGamepadDown('dpdown')))) then
     self.downDirty = timer.rot(self.downDirty)
     self.downDirty = timer.rot(self.downDirty)
   else
   else
     self.downDirty = .1
     self.downDirty = .1
@@ -510,9 +509,9 @@ function Pigeon.walk:update()
 
 
   self:recoverFuel()
   self:recoverFuel()
 
 
-  if love.keyboard.isDown('up', 'w', 'z') or (self.joystick and (self.joystick:getGamepadAxis('lefty') < -.5 or self.joystick:isGamepadDown('a', 'dpup'))) then
+  if love.keyboard.isDown('up', 'w', 'z') or (joystick and (joystick:getGamepadAxis('lefty') < -.5 or joystick:isGamepadDown('a', 'dpup'))) then
     return self:changeState('air')
     return self:changeState('air')
-  elseif (love.keyboard.isDown(' ', 'down', 's', 'x') or (self.joystick and (self.joystick:isGamepadDown('b', 'x', 'y')))) and not self.peckDirty then
+  elseif (love.keyboard.isDown(' ', 'down', 's', 'x') or (joystick and (joystick:isGamepadDown('b', 'x', 'y')))) and not self.peckDirty then
     self:changeState('peck')
     self:changeState('peck')
   end
   end
 
 
@@ -532,7 +531,7 @@ function Pigeon.air:enter()
     self.rightWhirr:stop()
     self.rightWhirr:stop()
   end
   end
   self.jumped = false
   self.jumped = false
-  if love.keyboard.isDown('up', 'w', 'z') or (self.joystick and (self.joystick:getGamepadAxis('lefty') < -.5 or self.joystick:isGamepadDown('a', 'dpup'))) then
+  if love.keyboard.isDown('up', 'w', 'z') or (joystick and (joystick:getGamepadAxis('lefty') < -.5 or joystick:isGamepadDown('a', 'dpup'))) then
     self.animation:set('jump')
     self.animation:set('jump')
   end
   end
   self.jumps = self.jumps + 1
   self.jumps = self.jumps + 1