Tiled TMX Map Loading and Rendering – Noah’s Ark Game

I recently resumed work on a game based on the Biblical story of Noah’s Ark. ¬†You can find out more about the game (and view its source code) at GitHub.

Anyway, after getting the basic project framework up recently, I moved onto the first major task – loading and rendering a tile map for the game. The first decision to make was deciding on a tile map editor to use.

I’d previously used Mappy and Tile Studio to varying degrees. While great tools in and of themselves, they aren’t really maintained much anymore, and I’m not too fond of their output formats.

This time, I’ve settled on using Tiled. It has a less-obscure XML output format, which generally makes things easier to parse. Adding advanced features to the XML would have minimal effect on the complexity of any parsing logic. There are also a ton of XML parsing libraries out there, so if I needed to write my own parsing library, it wouldn’t be too difficult.

Like most tile map editors, there are already a bunch of of existing libraries for loading Tiled’s TMX maps. Most of these are tied to specific rendering libraries as well. This can be advantageous, but I really wanted a TMX loading library that wasn’t tied to SDL, SFML, or some other library. My intent is to hopefully have some reusable tile map code of my own that I can largely use regardless of rendering technology.

Thankfully, such a library exists: TmxParser. I was relatively impressed with how clean the library’s API is – reading and understanding the class headers was quick and simple. Throughout the course of the past week or so, I worked on integrating TmxParser into the Noah’s Ark game. The final result is a screen like this when booting up the game:

Rendering of a test map loaded from a TMX file

Rendering of a test map loaded from a TMX file

Next on my list of features for the game is adding an overworld map to connect tile maps. Scrolling between tile maps will soon follow. However, I’ll probably be taking a break from working on this game for the next month or so.