I am exporting maps from tiled in the lua format with no compression or anything like that. I've create a loader (well, I thought I had) which reads the data from the file as needed and opens it up, but when I launch, it just goes to a black screen after the splashes, and I'm not sure why. Maybe I don't quite understand tables correctly. Would you mind looking at my code and seeing where I've made a mistake? I've included the love file which also contains the map file. the tileset.pck is just a png file with a different extension. Thanks
Code: Select all
Game = {}
g_quads = {}
g_layer = {}
g_events = {}
function Game:load()
g_map = require("maps/el_starters_quarter.lua")
g_til = love.graphics.newImage("graphics/tileset.pck")
g_mapsize_w = g_map.width
g_mapsize_h = g_map.height
g_tile_w = g_map.tilewidth
g_tile_h = g_map.tileheight
g_tileset_w = g_map.tilesets[1].imagewidth / g_tile_w
g_tileset_h = g_map.tilesets[1].imageheight / g_tile_h
for t_y = 0,g_tileset_h do
t_x = 0,g_tileset_w do
t_quad = love.graphics.newQuad(t_x * g_tile_w,t_y * g_tile_h, g_tile_w, g_tile_h, g_til:getDimensions())
g_quads[#g_quads + 1] = t_quad
end
end
for t_l = 1,#g_map.layers do
if g_map.layers[t_l].type == "tilelayer" then
g_layer[#g_layer + 1] = g_map.layers[t_l].data
end
if g_map.layers[t_l].type == "objectgroup" then
for t_o = 0,#g_map.layers[t_l].objects do
g_events[#g_events + 1] = {o_t=g_map.layers[t_l].objects[t_o].type,o_x=g_map.layers[t_l].objects[t_o].x,o_y=g_map.layers[t_l].objects[t_o].y,p=g_map.layers[t_l].objects[t_o].properties}
end
end
end
end
function Game:update(dt)
end
function Game:draw()
for t_l = 1,#g_layer do
t_i = 1
for d_y = 0,g_mapsize_h do
for d_x = 0,g_mapsize_w do
love.graphics.draw(g_til,g_quads[g_layer[t_l][t_i]],d_x * g_tile_w, d_y * g_tile_h)
t_i = t_i + 1
end
end
end
end
return Game