Search code examples
sdltile

How to load tilemap from tiled software into SDL2


I have created a tilemap using the Tiled Software. Now I need to use it in SDL2 code. I am using lazyfoo's tut to learn SDL. The problem is that in his tut , he uses a .map file to represent a tilemap. The tiled software is not allowing an output in this format. The format it is exporting in is .tmx. TMX when opened looks like XML while the .map format used in the tut is not (its directly the numbers relative to the tile jpg while tmx seems encoded). So I can't load my tilemap into the SDL code. How can I resolve this problem ? Also, for a game which is better performance-wise: tmx or .map or is there no difference?


Solution

  • Have a look at http://doc.mapeditor.org/reference/support-for-tmx-maps/ for support for loading a TMX map for various languages and libraries.

    Mine is listed on there which used C++ and SDL: https://bitbucket.org/martingrant/tmxloader