I've made a couple RPG-style "Hello World" games in Allegro, and I'm looking to apply what I learned from those to make something a bit bigger now. I'd like to use the Tiled Map Editor, and I made a test map, but I'm unsure how to use data from the XML file it outputs in my game.
I've read tutorials for XML itself and for TinyXML (if there's a better tool or this won't do what I need, please let me know) but I'm still at a loss on how to proceed. I don't have prior experience with XML, zlib, or with using another language in conjunction with C++.
This is what the output file looks like:
The map consists of the tiles, a meta layer that defines which tiles should be impassible, and an object layer that will define map transitions like doors. How can I read and use this data in C++ (presumably as a class), or where can I learn how to do this? Thanks.
We used XML configuration and TinyXML for Intern's Quest[1]. Perhaps you could look at how we did it there?
If the "Tile Map Editor" is a library, then it should come with the tools to parsing the map files and instantiating objects from them.
I think this is what you want:
Tiled Map Support for A5
I haven't tried it myself though as I use my own custom XML format.
@bamccaig: Thanks! I'm pretty new to file I/O in general, and your code is very helpful.
@James Lohr: Tiled is just a GUI app that lets one "paint" maps with tilesets and define properties for tiles, then exports the data as XML.
@Ashteth: Oh this is cool. (Their link is broken, this is the proper one: https://github.com/dradtke/allegro_tiled.)
I've been messing around all night and managed to write functions to printf the data I need, so I should be able to modify them to draw instead without too much hassle. Luckily the rest of what I have is written in such a way that it shouldn't care how the map drawing is done.