diff options
author | Aki <nthirtyone@gmail.com> | 2016-05-22 19:51:51 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-05-22 19:51:51 +0200 |
commit | 13e368bc2c35c35369a1f6bf76778d88cae240da (patch) | |
tree | ba4ef5f8d966cb5ff6fc3d4255cd58ef762b34ee /camera.lua | |
parent | 846debef23b584a3ebc16cbde3bea8d9c2d2b7c1 (diff) | |
download | roflnauts-13e368bc2c35c35369a1f6bf76778d88cae240da.zip roflnauts-13e368bc2c35c35369a1f6bf76778d88cae240da.tar.gz roflnauts-13e368bc2c35c35369a1f6bf76778d88cae240da.tar.bz2 |
More on maps
Diffstat (limited to 'camera.lua')
-rw-r--r-- | camera.lua | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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 |