2
0
Эх сурвалжийг харах

Merge branch 'master' of https://github.com/bjornswenson/pigeon

Sophia 10 жил өмнө
parent
commit
84a266cc36
2 өөрчлөгдсөн 18 нэмэгдсэн , 2 устгасан
  1. 10 0
      hud.lua
  2. 8 2
      pigeon.lua

+ 10 - 0
hud.lua

@@ -10,4 +10,14 @@ function Hud:gui()
   g.setColor(255, 255, 255)
   g.setFont(self.font)
   g.print(ctx.pigeon.fuel, 0, 0)
+
+  if ctx.pigeon.state == ctx.pigeon.laser then
+    local percent = math.min(ctx.pigeon.laser.charge / (ctx.pigeon.laser.active and ctx.pigeon.laserDuration or ctx.pigeon.laserChargeDuration), 1)
+    local x, y = ctx.view:screenPoint(ctx.pigeon.body:getX(), ctx.pigeon.body:getY() - 100)
+    local w, h = 80, 5
+    g.setColor(255, 255, 255, 80)
+    g.rectangle('fill', x - w / 2, y - h / 2, w * percent, h)
+    g.setColor(255, 255, 255)
+    g.rectangle('line', x - w / 2, y - h / 2, w, h)
+  end
 end

+ 8 - 2
pigeon.lua

@@ -10,9 +10,9 @@ Pigeon.flySpeed = 10000
 Pigeon.rocketForce = 500
 Pigeon.maxFlySpeed = 300
 Pigeon.maxFuel = 50
-Pigeon.laserTurnSpeed = 1
+Pigeon.laserTurnSpeed = .35
 Pigeon.laserChargeDuration = 2
-Pigeon.laserDuration = 2
+Pigeon.laserDuration = 1
 
 ----------------
 -- Core
@@ -284,6 +284,8 @@ function Pigeon.walk:update()
 
   if left or right then
     self:move()
+  elseif love.keyboard.isDown(' ') then
+    self:changeState('laser')
   else
     return self:changeState('idle').update(self)
   end
@@ -299,6 +301,8 @@ function Pigeon.air:update()
   local left, right = love.keyboard.isDown('left'), love.keyboard.isDown('right')
   local vx, vy = self.body:getLinearVelocity()
 
+  print(vy)
+
   if self.jumped and self.grounded and vy >= 0 then
     return self:changeState('idle').update(self)
   end
@@ -317,6 +321,8 @@ function Pigeon.air:update()
         local bonusBoost = vy > 0 and vy / 2 or 0
         self.body:applyLinearImpulse(0, -(self.rocketForce + bonusBoost))
       end
+
+      self.animation:set('fly')
     end
   end
 end