Tiled question

I am clearly not getting seomthing. You are using Tiled with Love but JSON? Why not export the tiled map to lua. It works perfectly fine. The only thing you need to change once the file is exported is the first line from return { to level1 = { After that you can access the map as a table. Here is my functions to load and draw a level made with tiled: ``` require 'assets/level1' --this is the tiled map exported to lua playerImg = love.graphics.newImage('assets/mytiles.png') --tiles file used in tiled map level_data = {} level_width = 0 level_height = 0

function load_level() myMap = {} --used for a* path finding

level_width = level1.layers[1].width level_height = level1.layers[1].height

io.write("level_width = " .. level_width.. "\n") io.write("level_height = " .. level_height .. "\n")

for i=1,level_width do myMap[i-1] = {}; for j=1,level_height do tileid = level1.layers[1].data[(j-1)*level_width+i]-1

  if (tileid > 0) then
    compute_x_y(tileid, pos)
    level_data[(j-1)*level_width+(i-1)] = love.graphics.newQuad(pos.x*32, pos.y*32, 32, 32, playerImg:getDimensions())

    myMap[i-1][(j-1)] = 0
  else
    myMap[i-1][(j-1)] = 1
  end
end

end

function compute_x_y(tileId, pos) --this function will compute the x,y pos from a tiled tileid map exported to lua code --and return it in pos x.y because lua passes tables as references pos.x = tileId % 32 pos.y = math.floor(math.abs(tileId / 32)) end

function draw_level() for i=1,level_width do for j=1,level_height do if( level_data[(j-1)level_width+(i-1)] ~= nil ) then love.graphics.draw(playerImg, level_data[(j-1)level_width+(i-1)], (i-1)32, (j-1)32) end end end end ```

/r/love2d Thread Parent