From e138fff2cafd100e10113bfb23e005870ab36642 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 22 May 2016 22:20:45 +0200 Subject: Small tweak --- camera.lua | 10 ++++++---- 1 file 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 -- cgit v1.1