I have exported my Game world (Tiles + Collision Tiles) from Tiled as a Lua File, How do i integrate this into my Love2d Game and Determine which one is a Walkable path and Which one is not?
1
votes
I wouldn't consider this a proper answer but if you'd like to see how someone else did this you can check out my implementation: github.com/TannerRogalsky/big_trouble/blob/map_prototypes/… It's not meant to be useful to everyone but it might save you some time in your own implementation.
- WuTangTan
1 Answers
2
votes
If you look in this question (What code do I wrap around Lua code in C++ with LuaBind?) you will find an example of what the lua file looks like. All it is is a file that when run in lua will return a dictionary containing all the data about your game world.
Assuming your map is called "mymap.lua" you would do this in one of the following ways:
require("mymap")
local mymap = love.filesystem.load("mymap.lua")()
Then, to use it, you would do something like:
-- loads the sprites of the first tileset
local tileset1 = love.graphics.newImage(mymap.tilesets[1].image)
-- print the width and height of the first layer
print(mymap.layers[1].width, mymap.layers[1].height)
As for what each piece of the imported data means, you will have to work it out yourself.