summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-05-22 22:20:45 +0200
committerAki <nthirtyone@gmail.com>2016-05-22 22:20:45 +0200
commite138fff2cafd100e10113bfb23e005870ab36642 (patch)
treef6592dd4fd4715e315e8024595ff1e3a5c5e6be3
parenta8c3aba91e994c29b224279d401691ae39412db1 (diff)
downloadroflnauts-e138fff2cafd100e10113bfb23e005870ab36642.zip
roflnauts-e138fff2cafd100e10113bfb23e005870ab36642.tar.gz
roflnauts-e138fff2cafd100e10113bfb23e005870ab36642.tar.bz2
Small tweak
-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