summaryrefslogtreecommitdiffhomepage
path: root/camera.lua
diff options
context:
space:
mode:
Diffstat (limited to 'camera.lua')
-rw-r--r--camera.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/camera.lua b/camera.lua
index 04590d1..7a02bf1 100644
--- a/camera.lua
+++ b/camera.lua
@@ -24,6 +24,8 @@ function Camera:new (world)
setmetatable(o, self)
self.__index = self
o.world = world
+ o:setPosition(o:follow())
+ o:setDestination(o:follow())
return o
end
@@ -118,9 +120,9 @@ function Camera:follow ()
y = point.body:getY() + y
end
end
- x = x / i - love.graphics.getWidth()/2/self.scale
- y = y / i - love.graphics.getHeight()/2/self.scale
- self:setDestination(x,y)
+ x = x / i - love.graphics.getWidth()/self.scale/2
+ y = y / i - love.graphics.getHeight()/self.scale/2
+ return x,y
end
-- Update
@@ -134,7 +136,7 @@ function Camera:update (dt)
self.delay = self.delay - dt
end
else
- self:follow()
+ self:setDestination(self:follow())
end
local dx, dy = self:getDestination()
dx = (dx - self.x) * 6 * dt