🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Creating maps with Tiled for SFML and C++ game

Started by
2 comments, last by Davindius 6 years, 4 months ago

Hi there.

I'm pretty new to this and I don't know if it has been asked before, but here I go.

I'm developing a game using SFML and C++.

I would like to use the "Tiled" tool to load maps into my game but I don't actually find any tutorial or guide on how to exaclty use it (I know that I have to read an XML file and stuff). I just step into diverse projects that make all a mess. 

Anyone knows where can I find good information to make my map loader by myself?

Thanks in advantage!!

Advertisement

Tiled can export JSON, which (in conjunction with nlohmann/json or similar) I find considerably easier to work with.  After that, remember it's up to you to interpret how to use the data .. and you can do whatever you want with it.  For instance, I often use an object layer for physics objects, trigger regions, spawners, etc.

Note there are some quirks with the format, tile direction, coordinates, etc, but they're pretty easy to work around.  It's also up to you to manage importing object tables, sprite sheets, etc (all of which can be exported as json as well in the latest versions).

I suggest using sfml-tmxloader or tmxlite.

sfml-tmxloader is meant to be used with SFML and is ready to load maps and render with SFML. It has a few examples in the github repo: https://github.com/fallahn/sfml-tmxloader

tmxlite can be used with many libraries (not just SFML) and has an SFML example in the github repo: https://github.com/fallahn/tmxlite

This topic is closed to new replies.

Advertisement