Beginners Devlog 1: More Variation with Dynamic Tilemaps in Phaser 3


I really love 2D tile-based maps for adventures but sometimes they lack on variation or change. Over time if you visit the same location again and again and it never changes it could get boring very fast.

Particularly one thing surprised me when i started building my map with RPG Maker at my first try to build a game. I googled for a possibility to change my map on different triggers or bring some randomness into parts of my map. I didn't want to create the whole map procedural, but some locations or map details need to change, or the feeling of the game would not be right. 

But what i have learned ... surprise, surprise ... there is not a real solution for map-variation in RPG Maker. And that was one reason why i decided to switch to a programming framework and left the game editors behind.

The Noob Detective should perform tasks that could possibly change the map and here is an example of such a task that could slightly change some tiles on the tilemap ...


After my player guy finally found his car key somewhere, he could unlock and open the trunk of his car. In RPG Maker such a change would not be possible. You could work around this if you just write the story for this task like ... "You opened the trunk, got your gloves and closed it again." ... of course that would be possible. But with a framework like Phaser you could change your tilemaps dynamically if you use DynamicTilemapLayer (instead of StaticTilemapLayer).


I have a lot of layers and so i configured it somewhere and just use dynamic layers where i need them. Static layers needs less resources because the framework don't have to take care of potentially changes of the layer. You can mix up dynamic and static layers in one tilemap ... that makes no problems at all.

The difference is at the layer object. Dynamic layers have methods for putting and removing tiles, static layers have not. I have my changes in an object with x/y tile coordinates and to which tile-index (change.to) i want to change on what layer (change.layer). If the change.to is empty i just remove the tile.


For my car trunk example it just looks like this ...

With this methods i do open doors, remove lids from dumpsters, turn on/off lights, tear down posters from walls and so on and so on. If you want to build a completely random map you also have to do it with dynamic layers and placing tiles on random spots on it.

Leave a comment

Log in with itch.io to leave a comment.