scenes/levels: make sure that the map follow the camera

This commit is contained in:
Kazhnuz 2019-03-01 18:29:28 +01:00
parent a3b809f3ba
commit 48283ea40b
2 changed files with 12 additions and 2 deletions

View File

@ -542,7 +542,7 @@ function Map:setObjectSpriteBatches(layer)
batches[tileset] = batches[tileset] or newBatch(image)
local sx = object.width / tile.width
local sx = object.width / tile.width
local sy = object.height / tile.height
local batch = batches[tileset]

View File

@ -7,7 +7,7 @@ function Level:draw(dt)
self:drawBackgroundColor()
self.camera:attach()
self.map:draw()
self:drawMap()
self:drawCollisions()
self:worldDraw()
@ -18,6 +18,16 @@ function Level:draw(dt)
self:drawDebugHUD()
end
function Level:drawMap()
local tx = self.camera.x - 424 / 2
local ty = self.camera.y - 240 / 2
tx = math.floor(tx)
ty = math.floor(ty)
self.map:draw(-tx, -ty, self.camera.scale, self.camera.scale)
end
function Level:drawBackgroundColor()
local r, g, b = self.backcolor
love.graphics.setColor(r, g, b)