bjorn 10 years ago
parent
commit
4df8f4daae
6 changed files with 44 additions and 1 deletions
  1. 4 0
      building.lua
  2. 13 0
      game.lua
  3. 12 0
      hud.lua
  4. 4 0
      person.lua
  5. 5 1
      pigeon.lua
  6. 6 0
      spear.lua

+ 4 - 0
building.lua

@@ -104,3 +104,7 @@ function Building:destroy()
     sound:setVolume(1)
   end)
 end
+
+function Building:paused()
+  self.phlerp:update()
+end

+ 13 - 0
game.lua

@@ -22,6 +22,7 @@ function Game:load()
   self.goal = Goal()
   self.particles = Particles()
   self.sound = Sound()
+  self.paused = false
 
   self.map:spawnHuts()
 
@@ -41,6 +42,16 @@ end
 function Game:update()
   self.debug = love.keyboard.isDown('`')
 
+  if self.paused then
+    self.pigeon:paused()
+    self.view:update()
+    self.buildings:paused()
+    self.enemies:paused()
+    self.projectiles:paused()
+    self.hud:paused()
+    return
+  end
+
   self.pigeon:update()
   self.enemies:update()
   self.buildings:update()
@@ -64,6 +75,8 @@ function Game:keypressed(key)
     love.event.quit()
   elseif key == 'm' then
     ctx.sound:mute()
+  elseif key == 'p' then
+    self.paused = not self.paused
   end
 
   self.pigeon:keypressed(key)

+ 12 - 0
hud.lua

@@ -153,6 +153,18 @@ function Hud:gui()
   end
 end
 
+function Hud:paused()
+  self.prevRainbowShitDisplay = self.rainbowShitDisplay
+
+  self.bubble.prevy = self.bubble.y
+  self.bubble.prevScale = self.bubble.scale
+  self.bubble.prevTimer = self.bubble.timer
+
+  if self.win.active then
+    self.win.prevx = self.win.x
+  end
+end
+
 function Hud:resetBubble()
   self.bubble.active = false
   self.bubble.amount = 0

+ 4 - 0
person.lua

@@ -58,6 +58,10 @@ function Person:draw()
   self.phlerp:delerp()
 end
 
+function Person:paused()
+  self.phlerp:update()
+end
+
 function Person:collideWith(other)
   if other.tag == 'building' and not other.destroyed then
     return false

+ 5 - 1
pigeon.lua

@@ -200,7 +200,7 @@ function Pigeon:draw()
   g.setColor(255, 255, 255)
 
   local x, y = self.body:getPosition()
-  self.animation:draw(x, y + self.shapeSize / 2)
+  self.animation:draw(x, y + self.shapeSize / 2, {noupdate = ctx.paused})
 
   local x1, y1, x2, y2 = self:getGroundRaycastPoints()
   g.setColor(self.grounded and {0, 255, 0} or {255, 0, 0})
@@ -244,6 +244,10 @@ function Pigeon:keypressed(key)
   end
 end
 
+function Pigeon:paused()
+  self.phlerp:update()
+end
+
 function Pigeon:collideWith(other, myFixture)
   if isa(other, Person) and other.state ~= other.dead and other.invincible == 0 then
     if self.state == self.peck and (myFixture == self.beak.top.fixture or myFixture == self.beak.bottom.fixture) then

+ 6 - 0
spear.lua

@@ -46,6 +46,11 @@ function Spear:draw()
   g.draw(image, x, y, angle, self.scale / 2, self.scale, image:getWidth(), image:getHeight() / 2)
 end
 
+function Spear:paused()
+  self.prevx = self.body:getX()
+  self.prevy = self.body:getY()
+end
+
 function Spear:collideWith(other)
   if isa(other, Map) then
     self.deathTimer = .05
@@ -54,3 +59,4 @@ function Spear:collideWith(other)
 
   return false
 end
+