Procedural generation for a 2d roguelike

Godot Version

4.2.1 stable


Hello! I’m pretty new to game dev in general. I’m working on a 2d top-down roguelike rpg andI have a tileset that I have configured and ready, but I’m stuck on the topic of procedural generation. Is there a way to make randomly generated levels? Should I use autotile? Do I have to hand-draw the levels and make the generation based on the levels I’ve already drawn? Thanks in advance.

You can definitely make procgen in godot, but the tools for that are not as sophisticated as you might expect. For example, using autotiles on a TileMap is possible, but rather slow when done in bulk, but this can be overcome by not using a TileMap, which defeats a lot of its actually useful properties. So it will heavily depend on how your game works, wether a pre-processing time is viable or not and how complex your generation needs to be.

1 Like

Nothing too complex; I want something like Pixel Dungeon’s generation: I’ve managed to make some algorithms that succesfully produce a dungeon shape but the walls are always off/not the correct tile. Autotiles (terrains) could also very much be a viable solution. I’m really scratching my head on the coding side of things, though, as procedural generation in GDScript the only thing I haven’t found a tutorial for online.

That’s probably because there’s not much benefit from using godot-specific classes in procgen yet. It’s getting worked on, tho.
But for now you can just use set_cells_terrain_connect() in the TileMap class to place autotiles. As I said, it is slow when done in bulk, but if you’re pre-generating the map or changing only a few tiles each frame it’s fine.

Is there any beginner-friendly guide to setting up terrains that you could point me towards?
I can’t seem to set it up by myself…

By the way, this is my tileset. Does it need to be ordered in a specific way to achieve proper terrain results?

You need to make a Terrain in the Tileset and set the peering bits.