Bläddra i källkod

R to restart;

bjorn 10 år sedan
förälder
incheckning
53ee36ac45
3 ändrade filer med 9 tillägg och 4 borttagningar
  1. 2 2
      building.lua
  2. 5 0
      game.lua
  3. 2 2
      pigeon.lua

+ 2 - 2
building.lua

@@ -99,7 +99,7 @@ function Building:collideWith(other)
   return true
 end
 
-function Building:destroy()
+function Building:destroy(cause)
   if self.destroyed then return end
   self.destroyed = true
   self.justDestroyed = true
@@ -108,7 +108,7 @@ function Building:destroy()
   self.fixture:setFriction(0.25)
   self.body:applyLinearImpulse(-400 + love.math.random() * 600, -2000 + love.math.random() * -2000)
   self.body:setAngularVelocity(-20 + love.math.random() * 40)
-  ctx.hud:addScore(50, 'building')
+  ctx.hud:addScore(50, 'building', cause)
   ctx.sound:play('wood', function(sound)
     sound:setVolume(1)
   end)

+ 5 - 0
game.lua

@@ -105,6 +105,11 @@ function Game:keypressed(key)
     ctx.sound:mute()
   elseif key == 'p' then
     self.paused = not self.paused
+  elseif key == 'r' and ctx.hud.win.active then
+    Context:remove(ctx)
+    local world = (ctx.map.name == 'dinoland') and 'Dinoland' or 'Kingdumb'
+    local index = ctx.map.index
+    Context:add(Game, world, index)
   elseif ctx.hud.win.active and (key == 'return' or key == ' ') then
     if self.backgroundSound then self.backgroundSound:stop() end
     Context:remove(ctx)

+ 2 - 2
pigeon.lua

@@ -276,9 +276,9 @@ function Pigeon:collideWith(other, myFixture)
       other:changeState('dead', 'jump')
     end
   elseif isa(other, Building) and not other.destroyed and self.state == self.peck and (myFixture == self.beak.top.fixture or myFixture == self.beak.bottom.fixture) then
-    other:destroy()
+    other:destroy('peck')
   elseif isa(other, Building) and not other.destroyed and self.crushGrace > 0 and (myFixture == self.feet.left.fixture or myFixture == self.feet.right.fixture) then
-    other:destroy()
+    other:destroy('step')
   end
 
   if isa(other, Building) then return false end