Browse Source

Platforms; Smaller pigeon; Disable spears for now;

bjorn 10 years ago
parent
commit
f2b27c39e1
7 changed files with 51 additions and 9 deletions
  1. 1 1
      caveman.lua
  2. 3 4
      data/animation/pigeon.lua
  3. 1 0
      deps/util.lua
  4. 31 1
      dinoland.lua
  5. 1 1
      game.lua
  6. 13 1
      map.lua
  7. 1 1
      pigeon.lua

+ 1 - 1
caveman.lua

@@ -65,7 +65,7 @@ function Caveman.attack:update()
   if self:inRange() then
   if self:inRange() then
     if self.walkTimer == 0 and self.reloadTimer == 0 then
     if self.walkTimer == 0 and self.reloadTimer == 0 then
       self.reloadTimer = lume.random(unpack(self.reloadRange))
       self.reloadTimer = lume.random(unpack(self.reloadRange))
-      ctx.projectiles:add(Spear, {x = self.body:getX(), y = self.body:getY() - self.h, direction = self.direction})
+      --ctx.projectiles:add(Spear, {x = self.body:getX(), y = self.body:getY() - self.h, direction = self.direction})
     end
     end
   else
   else
     if self.walkTimer == 0 then
     if self.walkTimer == 0 then

+ 3 - 4
data/animation/pigeon.lua

@@ -1,6 +1,6 @@
 local Pigeon = extend(Animation)
 local Pigeon = extend(Animation)
 
 
-Pigeon.scale = .7
+Pigeon.scale = .4
 Pigeon.default = 'idle'
 Pigeon.default = 'idle'
 Pigeon.states = {}
 Pigeon.states = {}
 
 
@@ -32,12 +32,11 @@ Pigeon.states.fly = {
 
 
 Pigeon.states.laserStart = {
 Pigeon.states.laserStart = {
   loop = false,
   loop = false,
-  speed = .5
+  speed = 1
 }
 }
 
 
 Pigeon.states.laserCharge = {
 Pigeon.states.laserCharge = {
-  loop = true,
-  speed = .5
+  loop = true
 }
 }
 
 
 Pigeon.states.laserEnd = {
 Pigeon.states.laserEnd = {

+ 1 - 0
deps/util.lua

@@ -1,4 +1,5 @@
 function isa(object, thing)
 function isa(object, thing)
+  if not getmetatable(object) then return false end
   repeat
   repeat
     local meta = getmetatable(object).__index
     local meta = getmetatable(object).__index
     if meta == thing then return true end
     if meta == thing then return true end

+ 31 - 1
dinoland.lua

@@ -1,9 +1,39 @@
 Dinoland = extend(Map)
 Dinoland = extend(Map)
 Dinoland.width = 2400
 Dinoland.width = 2400
-Dinoland.height = 1200
+Dinoland.height = 600
+Dinoland.groundHeight = 100
 
 
 function Dinoland:init()
 function Dinoland:init()
   self.zones = {}
   self.zones = {}
 
 
+  self.obstacles = {}
+
+  local obstacle = {}
+  obstacle.width, obstacle.height = 500, 100
+  obstacle.body = love.physics.newBody(ctx.world, 800, self.height - self.groundHeight - obstacle.height / 2)
+  obstacle.shape = love.physics.newRectangleShape(obstacle.width, obstacle.height)
+  obstacle.fixture = love.physics.newFixture(obstacle.body, obstacle.shape)
+  obstacle.fixture:setCategory(ctx.categories.oneWayPlatform)
+
+  table.insert(self.obstacles, obstacle)
+
+  obstacle = {}
+  obstacle.width, obstacle.height = 300, 200
+  obstacle.body = love.physics.newBody(ctx.world, 1200, self.height - self.groundHeight - obstacle.height / 2)
+  obstacle.shape = love.physics.newRectangleShape(obstacle.width, obstacle.height)
+  obstacle.fixture = love.physics.newFixture(obstacle.body, obstacle.shape)
+  obstacle.fixture:setCategory(ctx.categories.oneWayPlatform)
+
+  table.insert(self.obstacles, obstacle)
+
+  obstacle = {}
+  obstacle.width, obstacle.height = 550, 300
+  obstacle.body = love.physics.newBody(ctx.world, 550 / 2, self.height - self.groundHeight - obstacle.height / 2)
+  obstacle.shape = love.physics.newRectangleShape(obstacle.width, obstacle.height)
+  obstacle.fixture = love.physics.newFixture(obstacle.body, obstacle.shape)
+  obstacle.fixture:setCategory(ctx.categories.oneWayPlatform)
+
+  table.insert(self.obstacles, obstacle)
+
   return Map.init(self)
   return Map.init(self)
 end
 end

+ 1 - 1
game.lua

@@ -22,7 +22,7 @@ function Game:load()
   self.goal = Goal()
   self.goal = Goal()
 
 
   for i = 1, 50 do
   for i = 1, 50 do
-    self.enemies:add(Caveman, {x = 300 + love.math.random() * 1500, y = self.map.height - self.map.ground.height})
+    self.enemies:add(Caveman, {x = 300 + love.math.random() * 1500, y = self.map.height - self.map.ground.height - 400})
   end
   end
 
 
   --self.buildings:add(Building, {x = 300, width = 200, height = 80})
   --self.buildings:add(Building, {x = 300, width = 200, height = 80})

+ 13 - 1
map.lua

@@ -2,7 +2,7 @@ Map = class()
 
 
 function Map:init()
 function Map:init()
   self.ground = {}
   self.ground = {}
-  self.ground.height = 100
+  self.ground.height = self.groundHeight
   self.ground.body = love.physics.newBody(ctx.world, self.width / 2, self.height - self.ground.height / 2, 'static')
   self.ground.body = love.physics.newBody(ctx.world, self.width / 2, self.height - self.ground.height / 2, 'static')
   self.ground.shape = love.physics.newRectangleShape(self.width, self.ground.height)
   self.ground.shape = love.physics.newRectangleShape(self.width, self.ground.height)
 
 
@@ -18,6 +18,14 @@ end
 
 
 function Map:update()
 function Map:update()
   ctx.view.xmax = self:getMaxX()
   ctx.view.xmax = self:getMaxX()
+
+  table.each(self.obstacles, function(obstacle)
+    if ctx.pigeon.body:getY() + ctx.pigeon.shapeSize / 2 > obstacle.body:getY() - obstacle.height / 2 then
+      obstacle.fixture:setCategory(ctx.categories.oneWayPlatform)
+    else
+      obstacle.fixture:setCategory(ctx.categories.ground)
+    end
+  end)
 end
 end
 
 
 function Map:draw()
 function Map:draw()
@@ -32,6 +40,10 @@ function Map:draw()
 
 
   g.setColor(136, 87, 44)
   g.setColor(136, 87, 44)
   physics.draw('fill', self.ground)
   physics.draw('fill', self.ground)
+
+  table.each(self.obstacles, function(obstacle)
+    physics.draw('fill', obstacle)
+  end)
 end
 end
 
 
 function Map:getMaxX()
 function Map:getMaxX()

+ 1 - 1
pigeon.lua

@@ -9,7 +9,7 @@ Pigeon.jumpForce = 3000
 Pigeon.flySpeed = 500
 Pigeon.flySpeed = 500
 Pigeon.rocketForce = 500
 Pigeon.rocketForce = 500
 Pigeon.maxFlySpeed = 300
 Pigeon.maxFlySpeed = 300
-Pigeon.maxFuel = 50
+Pigeon.maxFuel = 25
 Pigeon.laserTurnSpeed = .35
 Pigeon.laserTurnSpeed = .35
 Pigeon.laserChargeDuration = 2
 Pigeon.laserChargeDuration = 2