Browse Source

Cool camera zoom effect; Tweak height of level;

bjorn 10 years ago
parent
commit
17b3f3289a
5 changed files with 31 additions and 16 deletions
  1. 3 3
      data/animation/pigeon.lua
  2. 7 1
      deps/view.lua
  3. 7 7
      dinoland.lua
  4. 5 1
      map.lua
  5. 9 4
      pigeon.lua

+ 3 - 3
data/animation/pigeon.lua

@@ -1,6 +1,6 @@
 local Pigeon = extend(Animation)
 
-Pigeon.scale = .4
+Pigeon.scale = .7
 Pigeon.default = 'idle'
 Pigeon.states = {}
 
@@ -10,7 +10,7 @@ Pigeon.states.idle = {
 
 Pigeon.states.walk = {
   loop = true,
-  speed = .85,
+  speed = .65,
   mix = {
     walk = .2
   }
@@ -18,7 +18,7 @@ Pigeon.states.walk = {
 
 Pigeon.states.peck = {
   loop = false,
-  speed = 1
+  speed = .75
 }
 
 Pigeon.states.jump = {

+ 7 - 1
deps/view.lua

@@ -32,6 +32,7 @@ function View:init()
 
   self.prevx = 0
   self.prevy = 0
+  self.prevwidth = self.width
   self.prevscale = self.scale
 
   self.shake = 0
@@ -48,6 +49,7 @@ end
 function View:update()
   self.prevx = self.x
   self.prevy = self.y
+  self.prevwidth = self.width
   self.prevscale = self.scale
 
   self.x = self.x + self.vx * ls.tickrate
@@ -195,8 +197,12 @@ function View:follow()
   local x, y = ctx.pigeon.body:getPosition()
   local margin = 0.5
 
+  self.height = math.lerp(self.height, math.clamp(1350 - y, 600, ctx.map.height), 10 * ls.tickrate)
+  self.width = self.height * (16 / 9)
+
   self.x = x - self.width * margin
-  self.y = y - self.height * .75
+  self.y = ctx.map.height - self.height
+  self.scale = self.frame.height / self.height
 end
 
 function View:contain()

+ 7 - 7
dinoland.lua

@@ -1,6 +1,6 @@
 Dinoland = extend(Map)
-Dinoland.width = 2400
-Dinoland.height = 600
+Dinoland.width = 4800
+Dinoland.height = 900
 Dinoland.groundHeight = 100
 
 function Dinoland:init()
@@ -10,7 +10,7 @@ function Dinoland:init()
 
   local obstacle = {}
   obstacle.width, obstacle.height = 500, 100
-  obstacle.body = love.physics.newBody(ctx.world, 800, self.height - self.groundHeight - obstacle.height / 2)
+  obstacle.body = love.physics.newBody(ctx.world, 1600, 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)
@@ -20,8 +20,8 @@ function Dinoland:init()
   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.width, obstacle.height = 500, 200
+  obstacle.body = love.physics.newBody(ctx.world, 2100, 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)
@@ -32,7 +32,7 @@ function Dinoland:init()
 
   Map.init(self)
 
-  self.decorations = {}
+  --[[self.decorations = {}
   for i = 1, 10 do
     local obstacle
     if love.math.random() < .75 then
@@ -42,7 +42,7 @@ function Dinoland:init()
     end
 
     table.insert(self.decorations, {image = data.media.graphics.dinoland['shrub' .. love.math.random(1, 4)], x = obstacle.body:getX() - obstacle.width / 2 + love.math.random() * obstacle.width, y = obstacle.body:getY() - obstacle.height / 2, height = 50 + love.math.random() * 60, direction = love.math.random() > .5 and -1 or 1})
-  end
+  end]]
 end
 
 function Dinoland:spawnHuts()

+ 5 - 1
map.lua

@@ -52,9 +52,13 @@ function Map:draw()
     g.draw(image, x2, y - obstacle.height / 2, 0, scale, scale, image:getWidth())
   end
 
+  -- Fake yellow sky
+  g.setColor(254, 255, 113)
+  g.rectangle('fill', 0, 0, self.width, self.height)
+
   g.setColor(255, 255, 255)
   local image = data.media.graphics.dinoland.dinolandBackground1
-  local scale = self.height / image:getHeight()
+  local scale = (600) / image:getHeight()
   for x = 1, self.width, image:getWidth() * scale * 2 do
     image = data.media.graphics.dinoland.dinolandBackground1
     g.draw(image, x, self.height, 0, scale, scale, 0, image:getHeight())

+ 9 - 4
pigeon.lua

@@ -18,7 +18,7 @@ Pigeon.laserChargeDuration = 2
 ----------------
 function Pigeon:init()
   self.shapeSize = 50
-  self.body = love.physics.newBody(ctx.world, 100, ctx.map.height - ctx.map.ground.height - self.shapeSize / 2, 'dynamic')
+  self.body = love.physics.newBody(ctx.world, ctx.view.width / 2, ctx.map.height - ctx.map.ground.height - self.shapeSize / 2, 'dynamic')
   self.shape = love.physics.newRectangleShape(self.shapeSize, self.shapeSize)
   self.fixture = love.physics.newFixture(self.body, self.shape)
 
@@ -104,6 +104,8 @@ function Pigeon:update()
   f.exe(self.state.update, self)
   self:contain()
 
+  self.animation.speed = love.keyboard.isDown('s') and 2 or 1
+
   self:updateBeak()
   self:updateFeet()
 end
@@ -317,12 +319,13 @@ end
 ----------------
 function Pigeon:move()
   local left, right = love.keyboard.isDown('left'), love.keyboard.isDown('right')
+  right = true
 
   if left then
     self.animation.flipped = true
 
     if self.state == self.walk and self.slide then
-      self.body:setX(self.body:getX() - self.slideSpeeds[self.slide] * ls.tickrate * (self.animation.state.speed or 1) * self.animation.scale)
+      self.body:setX(self.body:getX() - self.slideSpeeds[self.slide] * ls.tickrate * (self.animation.state.speed or 1) * self.animation.scale * self.animation.speed)
     elseif not self.grounded then
       self.body:applyLinearImpulse(-self.flySpeed, 0)
     end
@@ -330,7 +333,7 @@ function Pigeon:move()
     self.animation.flipped = false
 
     if self.state == self.walk and self.slide then
-      self.body:setX(self.body:getX() + self.slideSpeeds[self.slide] * ls.tickrate * (self.animation.state.speed or 1) * self.animation.scale)
+      self.body:setX(self.body:getX() + self.slideSpeeds[self.slide] * ls.tickrate * (self.animation.state.speed or 1) * self.animation.scale * self.animation.speed)
     elseif not self.grounded then
       self.body:applyLinearImpulse(self.flySpeed, 0)
     end
@@ -365,7 +368,7 @@ function Pigeon.idle:update()
   self:recoverFuel()
   self.animation:set('idle')
 
-  if love.keyboard.isDown('left', 'right') then
+  if love.keyboard.isDown('left', 'right') or true then
     return self:changeState('walk').update(self)
   end
 
@@ -388,6 +391,7 @@ end
 
 function Pigeon.walk:update()
   local left, right = love.keyboard.isDown('left'), love.keyboard.isDown('right')
+  right = true
   self.animation:set('walk')
 
   self:recoverFuel()
@@ -422,6 +426,7 @@ end
 
 function Pigeon.air:update()
   local left, right = love.keyboard.isDown('left'), love.keyboard.isDown('right')
+  right = true
   local vx, vy = self.body:getLinearVelocity()
 
   if self.jumped and self.grounded and vy >= 0 then