The Big Refactoring - Chapter 1
Town Alight Dev Diaries – The Big Refactoring
Hello everyone!
Welcome back to The Big Refactoring, where I explain the significant changes we’ve made in Town Alight since we published its first version. Feel free to ask any questions regarding the development process in the comments! Today, I’m going to talk about one of the biggest reasons that led us to refactor the game: Godot’s tilemap system.
Chapter 1: Living in a Tile World
Tiles… most of you might have an idea of what these little guys are; but for those who don’t: a tile is a small rectangle (or hexagon, or other funky shape, but let’s not get ahead of ourselves), which, when placed together with other tiles, creates a tileset. Tilesets are used to create worlds in many 2D games, and when used wisely, they can make your life easier as a game developer. Guess who didn’t use them wisely initially? That’s right—yours truly.
And how could I mess up such a basic concept? Well… let me explain. In the original version of Town Alight that you can play in the browser, almost everything in the game is a tile. The trunk of that tree? A tile. That fire threatening our birb’s way of life? A tile. That piece of roof from where our beloved mayor bravely commands his troops? You guessed it—a tile.
This doesn’t seem that bad, right? Wrong. In Godot, and other game engines, tiles are not their own objects, unlike villagers or the birb. Instead, they are part of the tileset object, which is in charge of telling each tile where it goes and which layer it belongs to. And hey, it’s great it works this way because otherwise, tile-based games would be very resource-intensive. However, because of this, the stuff you can do with tiles is very limited. Each tile only knows about itself and is completely unaware of its surroundings—it doesn’t even know if it belongs to a house or a tree! This leads to weird scenarios...
Now… I confess I’m not an expert on burning trees, but this doesn’t look how a tree would burn in real life. The issue is that, not only does it look weird, we didn’t have control of what happened when a tree or building was scorched because the game didn’t even know that there was a building there in the first place! For this reason, we decided to change how the tileset interacted with the rest of the game, which, at the time, was our core mechanic.
Changing this behavior wasn’t going to be easy because the fires only wanted to spread throughout the tileset without acknowledging that there were other objects in the scene. This meant that the first step was changing the fires from being tiles to being their own separate objects, which allowed them to have individual colliders and check their neighbors. So… here you go, our new, independent fire, with upgraded graphics thanks to Doops!
Now, we just needed to make our building and nature tiles understand that they were part of a group, and the obvious step was simply to take them out of the tileset and make them their own objects, similarly to how the fire became its own object. This allowed us to give each structure its own identity—no more half-scorched, half-healthy trees for us! Not only that, but this also allowed us to give each structure more complex features, such as a defined fire resistance and a value, among other properties. The result (besides many features which I will not discuss yet) was structures that burned in a more natural way, like this guy:
As a bonus, now that structures aren’t part of the tileset system, we can place them wherever we want, without the placement constraints given by the tileset system.
Finally, with these two major changes, we can now improve the interaction between fires and structures. Fires used to only know how to spread throughout their grid, but now they have more complex behaviors, allowing them to detect their neighbors and understand that these neighbors could be other fires, bushes, trees, buildings, and more! The structures, on their end, now understand that having an active fire as a neighbor means trouble. In summary, the world is much more interconnected now than it once was, and you’ll be able to experience that in the future.
There’s so much more I could discuss about the new changes to the tileset system, but I don’t want to overwhelm you with a mega-long entry. For now, we’ve covered the most significant changes. If you have any questions or want me to dive deeper into any of these topics, feel free to let me know—I'll be happy to explore them in future entries!
That’s all from me for now. Thank you for reading, and I look forward to sharing more exciting updates with you soon. Stay tuned!
- Anthuulos
Get Town Alight
Town Alight
Micromanage a group of villagers as they fight a spreading fire.
Status | In development |
Authors | Anthuulos, Doops, nova harbor |
Genre | Strategy |
Tags | 2D, Indie, Pixel Art, Real time strategy, Top-Down |
Languages | English |
More posts
- The Big Refactoring - Chapter 210 days ago
- The Big Refactoring - Chapter 042 days ago
Leave a comment
Log in with itch.io to leave a comment.