# How can I implement an RPG-maker style

I'm currently working with Phaser, making a game that's procedurally generated. I wanted to use some RPG maker art in my game (for reference, I'm using the RTP). I stumbled across this article, which breaks down how auto tiles work. I also stumbled across this answer which links to another article that explains auto tiling.

Here's the thing, I have no idea how I would implement something like this. I'm sure I would have to keep track of which tile sets can connect to which other tilesets (ie, some tiles have grass on the outside, and sand on the inside, so in this example I'd have to note that "grass" tiles were the outer tiles).

I've made a map generator, and I wanted to make seamless connections between my tile areas. For example, the brown areas would be "dense" areas (forests, caves, etc). The purple areas would be stone floors, and the green area is the grass. There is a tileset that works very well for things like this:

So I would like to use the top left grass, and the third tile set, stone, which connects to the grass.

What sorts of things would I have to consider when implementing auto tiling using these sorts of tilesets, and is there an algorithm I can look at to implement?

• – jzx Apr 13 '15 at 1:18
• Tiled is an open source map editor which has an auto-tile implementation. You could try to find the implementation in the source-code. – Philipp Apr 13 '15 at 14:15
• @Philipp Tiled's and RPGMaker's autotiling paradigms are different though. Tiled lets you specify the four corners of a tile as a specific terrain type ("sand", "grass", "water" and so on) and picks a matching tile based on that. RPGMaker lets you specify the centres of the tile being a specific type-surrounded-by-type variant (for example "sand inside grass", "water inside grass" and so on). Layers are used to deal with this limitation in both cases. A transformation is possible, of course; here for example using REFMAP sand-inside-grass (with grass padding): i.imgur.com/Z343MVq.png – Martin Sojka Apr 14 '15 at 11:42
• For the record, the RTP resources are licensed only for use with their respective software and other versions of RPG Maker. It's fine as placeholder during development, but you will need to replace them with a different graphic set for distribution - for example the REFMAP set or graphics based on the Liberated Pixel Cup. – Martin Sojka Apr 14 '15 at 11:49
• Thanks for the heads up @MartinSojka - For better or worse, RPG maker provides the best full set of art to work with (tiles, faces, sprites, effects, etc), but I have been limiting what I use, just so I can cover my bases when it comes time to replace them. I just didn't want to spend hours looking for art when I could be programming. Thanks for the info on Liberated Pixel Cup, I'll be looking into that later on. FWIW, I don't plan on selling this game, but if I do I definitely will replace the art. – Seiyria Apr 14 '15 at 12:04

I have implemented this(using the RTP) in a simple(but quite tedious) way.

I took a list of all neighbors for the current cell, and with a lot of if statements I drew the tile as 4 smaller/quarter tiles.

For me this method lead to some barely visible errors, but they can be resolved by testing for some edge-cases and correcting accordingly.

If you look at the source images and the resulting image in the RPG maker, you should be able to do this(perhaps with some trial-and-error) with if statements, identifying what the current case is for the given quarter tile and drawing accordingly.

This method can be further improved and made less tedious with bitmasks(as mentioned by jzx).