I've managed to come up with this, which works fine If I wasn't to place EVERY tree individually in load(), but I don't. I'd like for the trees to still spawn based on the number of the tile.
Code: Select all
trees = {}
function spawnTrees(x, y, w, h, t)
table.insert(trees, {x = x, y = y, w = w, h = h, t = t})
end
function drawTrees()
for i=1, #trees do
love.graphics.drawq(images.tileset, quads[trees[i].t], mapToWorld(trees[i].x, trees[i].y))
end
end
this was my old code
Code: Select all
function drawTrees()
for i = 1, #map do
for l = 1, #map do
if map[i][l] ~= 0 then
love.graphics.drawq(images.tileset, quads[map[i][l]], mapToWorld(l-1, i-2))
end
end
end
end