How do I generate a dungeon?

1 favourites
  • 8 posts
From the Asset Store
Template for dungeon/maze generation, using wave function collapse
  • Yes, I know this has been asked a lot and can be a difficult task, but I have an idea as to how I can make it much simpler. Essentially, The dungeon is an 8x8 grid of rooms, each with doors on all 4 sides. after picking the random rooms, some doors will be blocked off to create the maze-like part of the dungeon, then I can use pathfinding to see if there is a clear route from start to finish.

    The problem is, I don't know what object to make the rooms. If I use a Sprite, the hitboxes will be an issue since I can't make individual hitboxes in one frame for the walls, and I do not know if I can make tilemaps mid-game using events. Can someone help me, or if there is a simpler method tell me?

    Thanks in advance!

  • I suggest using tilemaps for rooms. They can be invisible and used for collisions only, or you can use the to actually display walls and doors.

    I have a paid template where a level is generated from random rooms. It's a different method - the dungeon layout is pre-defined (rooms and exits don't change). But each room design is picked randomly. The room may consist of a tilemap, sprites and other objects.

    construct.net/en/game-assets/game-templates/random-level-generator-883

  • Okay, I'll use tilemaps then. But is there a way to generate the tiles during runtime using events (perhaps loading from a json array???)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yes, you can load each tile from an array, but it will be much easier to load the entire tilemap.

    Manually create rooms in a separate project (let's call it Level Editor), and export each room tilemap to a string using Tilemap.TilesJSON expression.

    Then in your main game you can quickly restore the entire room from a JSON string using "Tilemap Load" action.

    You can store these tilemap strings in a dictionary, array or text files, it's up to you.

    .

    Another option is to use templates. Simply create all room templates on a separate layout. And in runtime spawn a room by its template name. For example:

    Create RoomTilemap from template "big_boss_room"

  • Okay, thanks. I do have one question though. I am likely going to use the template idea, but for the level editor why does that have to be a separate project? Could it not just be a different layout?

    And as for spawning things such as enemies, how do I include those in the template for when I spawn the rooms? (Sorry, I'm very new to templates)

  • If you choose templates, they definitely need to be in the same project, on another layout.

    A template can consist of several objects combined into a hierarchy. Unfortunately, Tilemaps can't be added to hierarchies. Please vote for this idea:

    construct23.ideas.aha.io/ideas/C23-I-79

    So you will have to create two templates for each room. One template with a tilemap, and a second template with a hierarchy containing all other objects from that room - enemies, loot etc.

  • Thanks again dop2000 for all the help, I really appreciate it.

  • If you choose templates, they definitely need to be in the same project, on another layout.

    A template can consist of several objects combined into a hierarchy. So you will have to create two templates for each room. One template with a tilemap, and a second template with a hierarchy containing all other objects from that room - enemies, loot etc.

    Thanks for the direction! Your post is helpful as always :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)