summaryrefslogtreecommitdiffhomepage
path: root/camera.lua
diff options
context:
space:
mode:
Diffstat (limited to 'camera.lua')
-rw-r--r--camera.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/camera.lua b/camera.lua
index 0804860..cb367a3 100644
--- a/camera.lua
+++ b/camera.lua
@@ -83,17 +83,18 @@ end
-- Move follow
function Camera:follow ()
- local x,y,i = 145, 90, 1
+ local m = self.world.map
+ local x,y,i = m.center_x, m.center_y, 1
for k,point in pairs(self.world.Nauts) do
- if point.body:getX() > -20 and point.body:getX() < 310 and
- point.body:getY() > -70 and point.body:getY() < 200 then
+ if point.body:getX() > m.center_x - m.width/2 and point.body:getX() < m.center_x + m.width/2 and
+ point.body:getY() > m.center_y - m.height/2 and point.body:getY() < m.center_y + m.height/2 then
i = i + 1
x = point.body:getX() + x
y = point.body:getY() + y
end
end
- x = x / i - 145
- y = y / i - 90
+ x = x / i - love.graphics.getWidth()/2/self.scale
+ y = y / i - love.graphics.getHeight()/2/self.scale
self:setDestination(x,y)
end