Tiled map editor

A couple of weeks ago I started looking for a 2D map editor that would help me create levels for the game engine. During my research one particular editor named Tiled kept showing up with great reviews, so I decided to check it out.

Scavengers_Level1

Tiled [1] is a free software which has been in development part-time for nearly 9 years. It receives regular updates and its latest version 1.0 was released just a few days ago. Its developer can be supported via his Patreon page [2].

This visual editor allows you to create 2D maps by importing tile sets, creating tile layers, adding metadata with various objects and custom properties. It also supports several formats to export to, such as: CSV, GameMaker, Json, JavaScript, Lua and XML.

Each of these formats have their pros and cons. The CSV format proposes a stripped-down version of the map containing only the definition of the tile layers. While more complex formats such as Json or XML include the metadata added via objects and properties. In my particular case, I’ll need the metadata but I don’t necessarily need all the properties that are included in a format like Json.

After investigating, I realized you can implement your own custom exporter for Tiled in a C++ or Python plugin as described here:
http://discourse.mapeditor.org/t/howto-export-to-custom-export-formats/656

So, I decided to write my own plugin and here are the steps I followed:

  1. Set up the environment, it’s explained on the “Contributing to Tiled” page:
    https://github.com/bjorn/tiled/wiki/Contributing-to-Tiled 
  2. Get the Tiled source code on GitHub:
    https://github.com/bjorn/tiled 
  3. Download the Qt application framework:
    https://www.qt.io/download-open-source/ 
  4. Check out one of the existing exporter plugins:
    https://github.com/bjorn/tiled/tree/master/src/plugins 

When you’re done building your plugin, get the DLL and copy it to the Tiled release folder with the rest of its plugin DLL. Now you just need to launch Tiled and activate the DLL in the editor’s options settings (if it’s not activated by default).

Also make sure you build your plugin with the same Qt version as the one used by the Tiled release. Tiled 1.0.0 is built with Qt 5.8.0. The version 5.9.0 was released just a few days ago so I ended up installing it and at first, I made the mistake of building my plugin with this version which made the plugin DLL incompatible with the release version of the editor.

The exporter format I implemented is called GMapText, it’s a CSV-like format containing the metadata that was missing for my needs. All being in a single file.

If you want to have a look at the implementation here’s the changelist on GitHub:
https://github.com/bjorn/tiled/compare/master…griby:exporter-plugin

As an example, here’s what the XML looks like for the map in the previous screenshot:
https://www.dropbox.com/s/nijyiamcsxuhrfx/Scavengers_Level1.tmx?dl=0

Here’s what the Json looks like:
https://www.dropbox.com/s/ruyvctg7l76qn9t/Scavengers_Level1.json?dl=0

Finally, here’s what the GMapText looks like with this first implementation:
https://www.dropbox.com/s/kyhi22nzmyrfmnu/Scavengers_Level1.gmt?dl=0

I’ll probably improve it in the future depending on the game engine needs.

Cheers.

References:
[1] Tiled map editor main page http://www.mapeditor.org/
[2] Tiled developer Patreon https://www.patreon.com/bjorn

2 thoughts on “Tiled map editor

  1. Nenos Birko

    Tiled is great for 2D level design, I tried to use it a few months ago with Unity but ended up abandoning it when I scrapped my prototype. For my current project (Platformer) I think I will give it another shot thanks to this entry 🙂

    Liked by 1 person

    Reply
  2. Pingback: Project update #5 | Rough Edges

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s