However, I'd like to center the player and provide a "half tile" around the edges of the map, like in this mock-up below.
My initial thought to do this is to draw all the tiles, then crop half off each of the tiles around the perimeter of the sprite batch, but I can't find a way to do this. Anyone know how to do this, or, can you suggest a better way?
Here is how I'm loading my background tiles:
Code: Select all
imgBackgroundTiles = love.graphics.newImage("assets/graphics/Tiles.png")
tileSize = 40
tileQuads = {}
for i = 0, 3 do
tileQuads[i] = love.graphics.newQuad(i * tileSize, 0, tileSize, tileSize, imgBackgroundTiles:getWidth(), imgBackgroundTiles:getHeight())
end
mapWindowTilesWide = 10
mapWindowTilesHigh = 10
tileMapBatch = love.graphics.newSpriteBatch(imgBackgroundTiles, mapWindowTilesWide * mapWindowTilesHigh)
Code: Select all
mapData = love.filesystem.read("assets/maps/map" .. id .. ".map")
offset = 0
for y = 1, 30 do
map[y] = {}
for x = 1, 30 do
offset = offset + 1
cell = string.sub(mapData, offset, offset)
map[y][x] = tonumber(cell)
end
offset = offset + 2
end