Right now I'm using this to create the set amount of tiles used for my game. I'm not sure if it's actually a bad thing or not - but incase - is there away to eliminate images entirely? I really just need a grid of numbers.
Code: Select all
tile = {} -- tiles
for i = 0, 32 do
tile[i] = love.graphics.newImage("res/tile0.png")
end
mapvars = {} -- map variables
mapvars.w = #map[1]
mapvars.h = #map
mapvars.x = 0
mapvars.y = 0
mapvars.buff = 2
mapvars.dispw = 16
mapvars.disph = 16
tilevars = {} -- tilevars
tilevars.w = 8
tilevars.h = 8
Code: Select all
function drawWorld()
firsttilex = math.floor(mapvars.x / tilevars.w)
firsttiley = math.floor(mapvars.y / tilevars.h)
for y = 1, (mapvars.disph + mapvars.buff) do
for x = 1, (mapvars.dispw + mapvars.buff) do
if y + firsttiley >= 1 and y + firsttiley <= mapvars.h
and x + firsttilex >= 1 and x + firsttilex <= mapvars.w
then
love.graphics.draw(
tile[map[y + firsttiley][x+firsttilex]],
(x*tilevars.w) - tilevars.w,
(y*tilevars.h) - tilevars.h)
end
end
end
end
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