Godot's tile editor provides you with the ability to quickly make 2D tile-maps, similar to RPG Maker. This makes it easy to design and tweak maps. But can we take it a step further? Can we, in fact, use the tilemap editor to create functioning entities -- making it a domain-specific editor for our specific game?

We can. This post walks through a lightning-quick method you can use.

The Core Idea

Godot's Tilemap entities are simple. They're essentially a reference to a tileset (graphic with all your tiles on it), and one or more layers of those tiles drawn on a grid. In Godot, tilemaps are all about presentation.

What if you want to add functionality though? Imagine you're creating a 2D adventure or RPG (like, hmm, Eid Island maybe?), and you want to be able to draw enemies on the map. Or trees you can chop down, coins you can pick up, or anything else.

By itself, Godot doesn't provide a way to do this. However, I asked around on Discord, and checked some issues on GitHub about this; a definitive, simple approach appeared, something like a best-practice. How? Easy.

Define your tilesets as usual, including objects

Draw them in as many layers as you like, as usual

At runtime, iterate over the tiles, replacing the object ones with real entities (Scene instances)

The Secet Sauce: Swapping Tiles for Entities

Godot makes this process quite easy. As a pre-requisite, I would recommend:

You create entities for everything you want to replace, such as a Tree scene (subclasses Node2D, has a Sprite, script, etc.)

You map the two. I use a dictionary such as: var entity_tiles = { "Tree": preload("res://Scenes/Entities/Tree.tscn") }

With this in place, we simply iterate over the tiles and -- if the name appears in our dictionary -- replace the tile with its corresponding entity. Here's an early reference implementation in Eid Island.

Globals.TILE_WIDTH and TILE_HEIGHT refer to the (fixed) tile size; you can, alternatively, use the tileset/tilemap to get the cell size, or use the entity size as a reference (although the entity should be exactly one tile size for that to work).

With this in place, you can quickly and easily create levels with real functionality from simple tilesets.

Next Steps

One obvious missing piece of functionality is customization. What if my tile is, say, a door that warps somewhere, and I want to specify the destination properties when I draw the tile? How can I do that?

Unfortunately, I don't know the answer yet. As far as I know, Godot doesn't allow you to add additional variables/properties to the tile itself. Perhaps you could store the data elsewhere, such as a separate dictionary mapping entity/coordinates to custom data.

If you know how to solve this latter problem, drop us a note on Twitter or in the Godot Discord chat so we can use it too!

Other articles

This month, I set out with a very specific goal: create a 2D procedurally-generated RPG; something I've never heard of (or done before). Although I ran out of time, I plan to devote another month to the game. This retrospective discusses the good, the bad, and the work ahead of …

Summary

Godot provides a way to separate the presentation part of game entities from their underlying data. You can think of this as something akin to the Model-View-Controller design pattern, where scripts (classes/code) respresent the model and instanced scenes (sprite, animation, etc.) represent the presentation and control (eg. collision …

July brought a lot of challenges. @Chemical_Ink's internet went down for several days. I ran into a very busy work schedule. All of this meant less time for Abu Hamid X; but walhamdulillah, we still managed to ship a lot of changes.

With the end of Ramadan cutting through the first half of June, we made little progress in the first two weeks. That makes it even more exciting that we completed the prototype of our new game, tentatively titled "Abu Hamid!"

One of our main goals at Deen Games is to represent the views of Islam and Muslims in games. Muslims have something of a negative image in games. To paraphrase one video from Extra Credits: "Enemies in FPS games have gradually changed from Nazis to Arabs [Muslims]." One of the …

In RPGs (especially those of the 90s and early 2000s), game designers typically increase difficulty by creating increasingly powerful enemies (and more dangerous groups). To balance this, player characters engage in combat, gain experience points, and level up. Obviously, you want the game should increase in challenge/difficulty over time …

According to many, open-world is fun. Perhaps it's the sense of freedom, progression, or influence upon the world
which tickles a player's funny bone. Whichever it is, if there's anything we game designers know, it's that it's hard to
pull off.

Open-World?! What's That Mumbo-Jumbo's All About?

Most games never reach completion. Most of us know this -- especially programmers, who typically leave a trail of dead projects in their wake. Well-intentioned projects, but incomplete projects none-the-less.

What steps can you take to increase the chances of actually finishing, and get your game to that glorified "done" state …

After a few months of stagnation on the blogging/marketing side, we're finally back! We hope, inshaAllah (God willing) to publish regular (or at least semi-regular) updates to our blog and our current maintainer's Twitter account.