allegro_tiled is an Allegro 5 module that adds support for parsing and using TMX map files. This means that Tiled, as well as any other program supporting the same map format, can be used to create and edit game worlds while the complexity of parsing and drawing them is completely taken care of:
ALLEGRO_MAP *map = al_open_map("data/maps", "level1.tmx");
al_draw_map(map, 0, 0, 0); // (map, dx, dy, flags)
Additional methods are provided to draw one map layer at a time and/or draw only a particular section. Layers, tilesets, tiles, and objects are all given types, with methods that make them easy to access and use.
Currently, the following is supported:
- Orthogonal maps.
- Base64 encoding with gzip, zlib, or no compression.
- XML and CSV encoding. (though honestly, why would you?)
- Tile "flipped" flags, both vertically and horizontally.
- Objects.
The following is not yet supported:
- Isometric maps.
Make sure the following dependencies are installed:
- allegro
- allegro_image
- xml2
- zlib
- cmake
Make sure the following dependencies are installed using Homebrew:
- allegro5
- libxml2
- zlib
- cmake
Then simply run cmake .
followed by make
in the root folder to compile it, and optionally sudo make install
to handle installation. To run the example, cd to the examples folder and type LD_LIBRARY_PATH=.. ./example
. Use the arrow keys to scroll and Space to reload the map file.
If you wish to disable building the example, simply run cmake with -DWANT_EXAMPLE=Off
before building the library.
CMake will configure the build for a static library by default. If you would like to build a shared library instead, add -DBUILD_SHARED_LIBS
to the cmake command above.
This should work just fine on Windows and possibly FreeBSD, provided you know how to use CMake for those platforms and have the proper dependencies installed. However, because I primarily develop on Linux, I don't test on those platforms. Bug reports and fixes are welcome.