Browse Source

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

Sophia 10 years ago
parent
commit
f3658952be
6 changed files with 105 additions and 62 deletions
  1. 1 1
      deps/view.lua
  2. 15 0
      game.lua
  3. 72 51
      kingdumb.lua
  4. 1 1
      main.lua
  5. 15 8
      map.lua
  6. 1 1
      pigeon.lua

+ 1 - 1
deps/view.lua

@@ -120,7 +120,7 @@ function View:draw()
   g.setColor(255, 255, 255)
   love.math.setRandomSeed(ls.tick * 100)
   if ctx.pigeon.rainbowShitTimer > 0 then
-    self.effect:set('radius', math.abs(math.sin(ls.tick / 20)) * 20)
+    self.effect:set('radius', math.abs(math.sin(ls.tick / 4)) * 12)
     self.effect:set('angle', ls.tick / 15)
   else
     self.effect:set('radius', 0)

+ 15 - 0
game.lua

@@ -86,6 +86,21 @@ function Game:keypressed(key)
     ctx.sound:mute()
   elseif key == 'p' then
     self.paused = not self.paused
+  elseif key == 'return' and ctx.hud.win.active then
+    Context:remove(ctx)
+    local world
+    local index
+    if ctx.map.name == 'kingdumb' and ctx.map.index == 3 then
+      -- Menu
+      return
+    elseif ctx.map.name == 'dinoland' and ctx.map.index == 3 then
+      world = 'Kingdumb'
+      index = 1
+    else
+      world = (ctx.map.name == 'dinoland') and 'Dinoland' or 'Kingdumb'
+      index = ctx.map.index + 1
+    end
+    Context:add(Game, world, index)
   end
 
   self.pigeon:keypressed(key)

+ 72 - 51
kingdumb.lua

@@ -38,17 +38,31 @@ function Kingdumb:init(index)
     makeObstacle(4300, 0, 200, 100)
     makeObstacle(4100, 0, 200, 200)
   elseif self.index == 2 then
-    self.width = 5800
+    self.width = 5600
     self.height = 900
 
     makeObstacle(1700, 0, 400, 300)
     makeObstacle(1500, 0, 100, 200)
     makeObstacle(1500, 0, 600, 100)
+
+    makeObstacle(3200, 0, 300, 200)
+    makeObstacle(3200, 0, 600, 100)
+
+    makeObstacle(4000, 0, 100, 300)
+    makeObstacle(4000, 0, 300, 100)
   elseif self.index == 3 then
-    self.width = 6000
+    self.width = 6400
     self.height = 900
 
-    makeObstacle(4200, 0, 600, 100)
+    makeObstacle(1400, 200, 400, 100)
+    makeObstacle(1400, 100, 400, 100)
+    makeObstacle(1400, 0, 400, 100)
+
+    makeObstacle(3300, 0, 200, 200)
+    makeObstacle(3000, 0, 800, 100)
+
+    makeObstacle(4200, 0, 200, 350)
+    makeObstacle(4500, 0, 600, 100)
   end
 
   Map.init(self)
@@ -95,81 +109,88 @@ function Kingdumb:spawnHuts()
       ctx.enemies:add(Peasant, {x = 3900 + love.math.random() * 600, y = self.height - self.ground.height})
     end
   elseif self.index == 2 then
-    makeBuilding(1050, 100)
-    makeBuilding(1350, 0)
-    makeBuilding(1200, 100)
-
-    makeBuilding(2000, 300)
-
-    makeBuilding(2650, 0)
-
-    makeBuilding(3250, 100)
-    makeBuilding(3350, 0)
-    makeBuilding(3450, 100)
-    makeBuilding(3550, 0)
-    makeBuilding(3650, 100)
+    makeBuilding(900, 0)
+    makeBuilding(1100, 0)
+    makeBuilding(1300, 100)
+    makeBuilding(1400, 100)
+    makeBuilding(1500, 0)
+    makeBuilding(1800, 200)
+    makeBuilding(1950, 0)
+    makeBuilding(2100, 0)
+    makeBuilding(2250, 0)
 
-    makeBuilding(4000, 100)
-    makeBuilding(4400, 200)
-    makeBuilding(4800, 100)
+    makeBuilding(3200, 0)
+    makeBuilding(3200, 200)
 
-    for i = 1, 20 do
-      ctx.enemies:add(Peasant, {x = 1500 + love.math.random() * 300, y = self.height - self.ground.height})
-    end
+    makeBuilding(4000, 300)
+    makeBuilding(4400, 300)
+    makeBuilding(4600, 300)
 
-    for i = 1, 10 do
-      ctx.enemies:add(Peasant, {x = 1900 + love.math.random() * 200, y = self.height - self.ground.height - 100})
+    for i = 1, 5 do
+      ctx.enemies:add(Peasant, {x = 3150 + love.math.random() * 100, y = self.height - self.ground.height - 100})
     end
 
-    for i = 1, 20 do
-      ctx.enemies:add(Peasant, {x = 2650 + love.math.random() * 400, y = self.height - self.ground.height})
+    for i = 1, 15 do
+      ctx.enemies:add(Peasant, {x = 1600 + love.math.random() * 300, y = self.height - self.ground.height - 200})
     end
 
-    for i = 1, 20 do
-      ctx.enemies:add(Peasant, {x = 4100 + love.math.random() * 600, y = self.height - self.ground.height})
+    for i = 1, 35 do
+      ctx.enemies:add(Peasant, {x = 2300 + love.math.random() * 600, y = self.height - self.ground.height - 200})
     end
 
-    for i = 1, 20 do
-      ctx.enemies:add(Peasant, {x = 4100 + love.math.random() * 600, y = self.height - self.ground.height - 200})
+    for i = 1, 35 do
+      ctx.enemies:add(Peasant, {x = 4000 + love.math.random() * 800, y = self.height - self.ground.height})
     end
   elseif self.index == 3 then
-    makeBuilding(900, 0)
+    for i = 1, 25 do
+      ctx.enemies:add(Peasant, {x = 700 + love.math.random() * 400, y = self.height - self.ground.height})
+    end
+
+    makeBuilding(1300, 0)
+    makeBuilding(1400, 0)
     makeBuilding(1500, 0)
-    makeBuilding(2100, 0)
 
-    for i = 1, 15 do
-      ctx.enemies:add(Peasant, {x = 1000 + love.math.random() * 400, y = self.height - self.ground.height})
+    makeBuilding(1400, 100)
+
+    makeBuilding(1350, 200)
+    makeBuilding(1450, 200)
+
+    makeBuilding(1400, 300)
+
+    makeBuilding(1700, 0)
+    makeBuilding(1850, 0)
+
+    for i = 1, 25 do
+      ctx.enemies:add(Peasant, {x = 2000 + love.math.random() * 500, y = self.height - self.ground.height})
     end
 
-    for i = 1, 15 do
-      ctx.enemies:add(Peasant, {x = 1600 + love.math.random() * 400, y = self.height - self.ground.height})
+    for i = 1, 25 do
+      ctx.enemies:add(Peasant, {x = 2700 + love.math.random() * 400, y = self.height - self.ground.height - 100})
     end
 
-    makeBuilding(2500, 100)
-    makeBuilding(2900, 300)
-    makeBuilding(3000, 0)
-    makeBuilding(3150, 100)
+    makeBuilding(2900, 0)
     makeBuilding(3300, 200)
 
     for i = 1, 20 do
-      ctx.enemies:add(Peasant, {x = 2600 + love.math.random() * 800, y = self.height - self.ground.height - 200})
-    end
-
-    for i = 1, 8 do
-      ctx.enemies:add(Peasant, {x = 3000 + love.math.random() * 300, y = self.height - self.ground.height})
+      ctx.enemies:add(Peasant, {x = 3700 + love.math.random() * 400, y = self.height - self.ground.height - 350})
     end
 
-    makeBuilding(3950, 100)
-    makeBuilding(4450, 100)
+    makeBuilding(3600, 0)
+    makeBuilding(3800, 0)
 
-    for i = 1, 10 do
-      ctx.enemies:add(Peasant, {x = 4175 + love.math.random() * 50, y = self.height - self.ground.height - 400})
+    for i = 1, 5 do
+      ctx.enemies:add(Peasant, {x = 4100 + love.math.random() * 100, y = self.height - self.ground.height - 350})
     end
 
-    makeBuilding(5000, 200)
+    makeBuilding(4400, 100)
+    makeBuilding(4600, 100)
 
     for i = 1, 35 do
-      ctx.enemies:add(Peasant, {x = 4500 + love.math.random() * 600, y = self.height - self.ground.height})
+      ctx.enemies:add(Peasant, {x = 4900 + love.math.random() * 600, y = self.height - self.ground.height - 350})
     end
+
+    makeBuilding(5100, 0)
+    makeBuilding(5300, 0)
+    makeBuilding(5500, 0)
   end
 end

+ 1 - 1
main.lua

@@ -2,5 +2,5 @@ require 'require'
 
 function love.load()
   data.load()
-  Context:bind(Game, 'Kingdumb', 1)
+  Context:bind(Game, 'Dinoland', 1)
 end

+ 15 - 8
map.lua

@@ -36,20 +36,20 @@ function Map:draw()
     local x, y = obstacle.body:getPosition()
     local padding = 5
     local x1, x2 = x - obstacle.width / 2 - padding, x + obstacle.width / 2 + padding
-    local image = data.media.graphics.dinoland.grassLeft
+    local image = data.media.graphics[ctx.map.name].grassLeft
     local scale = 32 / image:getHeight()
     local xx = x1 + image:getWidth() * scale
     g.setColor(255, 255, 255)
     while xx < x2 do
-      local image = data.media.graphics.dinoland['grassMid' .. love.math.random(1, 2)]
+      local image = data.media.graphics[ctx.map.name]['grassMid' .. love.math.random(1, 2)]
       g.draw(image, math.min(xx, x2 - image:getWidth() * scale * 2), y - obstacle.height / 2 - padding, 0, scale, scale)
       xx = xx + image:getWidth() * scale
     end
-    local image = data.media.graphics.dinoland.grassLeft
+    local image = data.media.graphics[ctx.map.name].grassLeft
     local scale = 32 / image:getHeight()
     g.setColor(255, 255, 255)
     g.draw(image, x1, y - obstacle.height / 2 - padding, 0, scale, scale)
-    local image = data.media.graphics.dinoland.grassRight
+    local image = data.media.graphics[ctx.map.name].grassRight
     g.draw(image, x2, y - obstacle.height / 2 - padding, 0, scale, scale, image:getWidth())
   end
 
@@ -65,14 +65,21 @@ function Map:draw()
   local inc = image:getWidth() * scale
   for n = 4, 1, -1 do
     for x = -500, self.width, inc * 2 do
-      image = data.media.graphics.dinoland.background['leftBg' .. n]
+      image = data.media.graphics[ctx.map.name].background.left
       g.draw(image, x + ctx.pigeon.body:getX() / 2, self.height, 0, scale, scale, 0, image:getHeight())
-      image = data.media.graphics.dinoland.background['rightBg' .. n]
+      image = data.media.graphics[ctx.map.name].background.right
       g.draw(image, x + inc + ctx.pigeon.body:getX() / 2, self.height, 0, scale, scale, 0, image:getHeight())
     end
   end
 
-  g.setColor(136, 87, 44)
+  local groundColor
+  if ctx.map.name == 'dinoland' then
+    groundColor = {136, 87, 44}
+  else
+    groundColor = {136, 87, 44}
+  end
+
+  g.setColor(groundColor)
   physics.draw('fill', self.ground)
 
   love.math.setRandomSeed(1)
@@ -81,7 +88,7 @@ function Map:draw()
   for i = 1, #self.obstacles do
     local obstacle = self.obstacles[i]
     love.math.setRandomSeed(obstacle.body:getX() + obstacle.width)
-    g.setColor(obstacle.color or {136, 87, 44})
+    g.setColor(groundColor)
     physics.draw('fill', obstacle)
 
     drawGrass(obstacle)

+ 1 - 1
pigeon.lua

@@ -541,7 +541,7 @@ end
 
 function Pigeon.air:exit()
   if self.air.lastVelocity > 800 then
-    ctx.view:screenshake(15 + (self.air.lastVelocity / 100))
+    ctx.view:screenshake(15 + (self.air.lastVelocity / 50))
     local skeleton = self.animation.spine.skeleton
     local x = skeleton.x
     local y = skeleton.y