Skip to content

baylej tmx

Thorbjørn Lindeijer edited this page Nov 28, 2017 · 1 revision
Library

baylej/tmx

Language

C

Links

documentation, issues

Summary

baylej/tmx is well-maintained and implements all features of the TMX 1.0 format. It can read TMX and TSX files, either from disk or from memory. It comes with examples showing how to render the maps using either Allegro 5 or SDL 2.

It depends on libxml2 for XML-parsing (using XmlTextReader) and zlib for decompressing tile layer data. It uses cmake for compilation.

Examples

The project already ships with several examples that show how to access all the data and how to render the map. To compile the examples it is necessary to invoke the compiler with the options necessary for it to find the includes files and libraries of the dependencies.

Compiling the SDL 2 Example on Linux

First compile the library itself. It is not necessary to install the library, so provided you have installed the dependencies you can just run:

cmake .
make

And then compile and link the example, which in addition to libxml2 and zlib depends on SDL 2 and SDL2_image:

cd examples/sdl
g++ sdl.c -o sdl -I../../src `pkg-config --cflags --libs sdl2 SDL2_image libxml-2.0 zlib` ../../libtmx.a

The above command compiles sdl.c into an executable called sdl. It passes ../../src as include folder for finding the TMX library includes. Then it uses pkg-config to pass the needed compiler and linker flags based on the listed dependencies. Finally it links with the static libtmx.a library.

You can then run the example as follows:

./sdl <map-file-to-render.tmx>

Projects Using This Library

The author uses the library in his Ludum Dare games. There are likely some projects using this library, but none are known at the moment. If you are using this library, let us know!