Browse Source

Fix laser;

bjorn 10 years ago
parent
commit
59ae1b2fd8
2 changed files with 6 additions and 10 deletions
  1. 1 1
      data/animation/pigeon.lua
  2. 5 9
      pigeon.lua

+ 1 - 1
data/animation/pigeon.lua

@@ -18,7 +18,7 @@ Pigeon.states.walk = {
 
 Pigeon.states.peck = {
   loop = false,
-  speed = 1.5
+  speed = 1
 }
 
 Pigeon.states.jump = {

+ 5 - 9
pigeon.lua

@@ -12,7 +12,6 @@ Pigeon.maxFlySpeed = 300
 Pigeon.maxFuel = 50
 Pigeon.laserTurnSpeed = .35
 Pigeon.laserChargeDuration = 2
-Pigeon.laserDuration = 1
 
 ----------------
 -- Core
@@ -43,6 +42,9 @@ function Pigeon:init()
       self:changeState('idle')
     elseif event.state.name == 'laserStart' then
       self.animation:set('laserCharge')
+    elseif event.state.name == 'laserEnd' then
+      self:changeState('idle')
+      self.laser.active = false
     end
   end)
 
@@ -74,7 +76,6 @@ function Pigeon:init()
       self:jump()
     elseif name == 'laser' then
       self.laser.active = true
-      self.laser.charge = self.laserDuration
     elseif name == 'peck' and self.state == self.peck then
       self.peck.impact(self)
     end
@@ -456,9 +457,8 @@ end
 function Pigeon.laser:update()
   if not self.laser.active then
     if not love.keyboard.isDown(' ') then
-      if self.animation.state.name == 'laserCharge' then
-        self.laser.charge = self.laserDuration
-        --self.animation:set('laserEnd')
+      if self.animation.state.name == 'laserCharge' or self.animation.state.name == 'laserEnd' then
+        self.animation:set('laserEnd')
       else
         self:changeState('idle')
       end
@@ -479,10 +479,6 @@ function Pigeon.laser:update()
     elseif love.keyboard.isDown('down', 'left') then
       self.laser.direction = self.laser.direction + self.laserTurnSpeed * ls.tickrate
     end
-
-    self.laser.charge = timer.rot(self.laser.charge, function()
-      self:changeState('idle')
-    end)
   end
 end