So the code
Code: Select all
function love.load()
tilemap = {
{16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
{16, 16, 16, 16, 16, 16, 11, 12, 13, 12, 13, 12, 13, 12, 13, 15},
{16, 16, 16, 16, 16, 16, 21, 22, 23, 22, 23, 22, 23, 22, 23, 25},
{16, 16, 16, 16, 16, 16, 31, 33, 32, 33, 32, 33, 32, 33, 32, 35},
{16, 16, 16, 16, 16, 16, 31, 33, 32, 33, 32, 33, 32, 33, 32, 35},
{16, 16, 16, 16, 16, 16, 31, 33, 32, 33, 32, 33, 32, 33, 32, 35},
{16, 16, 16, 16, 16, 16, 31, 33, 32, 33, 32, 33, 32, 33, 32, 35},
{11, 12, 13, 12, 13, 12, 25, 33, 32, 33, 32, 33, 32, 33, 32, 35},
{21, 22, 23, 22, 23, 22, 25, 33, 32, 33, 32, 33, 32, 33, 32, 35},
{31, 32, 33, 32, 33, 32, 33, 32, 33, 32, 32, 33, 32, 32, 33, 35},
{31, 32, 33, 32, 33, 32, 33, 32, 33, 32, 32, 33, 32, 32, 33, 35},
{31, 32, 33, 32, 33, 32, 33, 32, 33, 32, 32, 33, 32, 32, 33, 35},
{51, 52, 53, 52, 53, 15, 32, 33, 32, 33, 32, 33, 11, 52, 53, 55},
{16, 16, 16, 16, 16, 31, 32, 33, 32, 33, 32, 33, 35, 16, 16, 16},
{16, 16, 16, 16, 16, 31, 32, 33, 32, 33, 32, 33, 35, 16, 16, 16},
{16, 16, 16, 16, 16, 51, 52, 53, 54, 52, 53, 54, 55, 16, 16, 16}
}
tile_11 = love.graphics.newImage("/DungeonTiles01/11.png")
tile_12 = love.graphics.newImage("/DungeonTiles01/12.png")
tile_13 = love.graphics.newImage("/DungeonTiles01/13.png")
tile_15 = love.graphics.newImage("/DungeonTiles01/15.png")
tile_21 = love.graphics.newImage("/DungeonTiles01/21.png")
tile_22 = love.graphics.newImage("/DungeonTiles01/22.png")
tile_23 = love.graphics.newImage("/DungeonTiles01/23.png")
function love.draw()
for i,row in ipairs(tilemap) do
for j,tile in ipairs(row) do
if tile == 11 then
love.graphics.draw( tile_11, j * width, i * height)
elseif tile == 12 then
love.graphics.draw( tile_12, j * width, i * height)
elseif tile == 13 then
love.graphics.draw( tile_13, j * width, i * height)
elseif tile == 15 then
love.graphics.draw( tile_15, j * width, i * height)
elseif tile == 21 then
love.graphics.draw( tile_21, j * width, i * height)
elseif tile == 22 then
love.graphics.draw( tile_22, j * width, i * height)
elseif tile == 23 then
love.graphics.draw( tile_23, j * width, i * height)
end
end
end
end
So i wrote that:
Code: Select all
tiles = { }
for i = 1, num_tiles do
tiles[i] = love.graphics.newImage("/DungeonTiles01/" .. string.format("%02d", i) .. ".png")
end
function love.draw()
for i,row in ipairs(tilemap) do
for j,tile in ipairs(row) do
love.graphics.draw(tiles[tile], j * width, i * height)
end
end
end