This week-end I've been working on the auto-tiling feature of the editor.
It's usually a rather popular feature in map editors (mostly because it saves a lot of time) so I thought I would do a little write up to explain to interested watchers how it works.
What is auto-tiling?
Maps for 2D games are generally built by placing square tiles on a grid. This means mapping areas bigger than a single tile requires stitching multiple tiles together. For example placing down individuals tufts of grass is not an issue, but mapping a patch of grass requires you to manually lay down corner pieces, edges, etc.
As you can see in the .gif below, this can easily become a time sink, is a very error-prone process, and requires you to manually place variations if you don't want your floor to look like an ugly pattern of repeating tiles.
Auto-tiling aims to make this process easier and faster by stitching the tiles for you and randomizing them within the parameters you provide.
How does it work?
As always it requires some setup before you start building your map, but once you have configured your tiles you will gain a considerable amount of time! The way it works is by tagging tiles in the tileset as corners, edges, T-junctions, variations, etc.
When a tile is mapped using auto-tiling, the editor examines its direct neighbors, assigns a "weight" to each of them, and calculates the final value for the tile being examined.
This value, which is unique to each possible combination of neighbors, is then mapped into the piece required. For example, one neighbor on the right and one neighbor above will produce a unique value (in this example: 3) which the editor then translates to "we need a corner piece".
Using the tags assigned in the previous step, the editor can now pick the right tile for you!
The result is effortlessly dragging the mouse around while the editor does the hard work for you ^_^
Auto-tiling can also dramatically speed up the mapping of rooms, as the same technique can be applied to drawing the ground. I was going to do a "without auto-tiling" and "with auto-tiling" comparison, but to be honest the "without auto-tiling" version would have ended up so long I doubt anybody would have watched it ^_^
And there you have it. The addition of auto-tiling support also marks the official release of version 1.0 of the editor :) Of course there are still some missing features and polish, which will get added progressively throughout development, but the editor is now functional enough for Cyangmou to start building levels. The next release, which will be made available to our Alpha Backers, is currently planned for mid-November.
Which means it's also time for me to go back to coding the game :D
Cheers everybody, and have a fantastic week!
Marco / benitosub