mminer / ggj2022

Dungeon, With Friends! (Global Game Jam 2022)
https://matthewminer.com/ggj2022
5 stars 2 forks source link

Implement map generation #8

Closed mminer closed 2 years ago

mminer commented 2 years ago

This seems like it could be a gnarly task if we attempt to do it from scratch. My vote is to integrate an existing library. I found a few:

mminer commented 2 years ago

It occurs to me that pulling in libtcod as a native plugin will prevent us from making WebGL builds, so let's scrap that option.

bradkeys commented 2 years ago

@mminer would it make sense to:

bradkeys commented 2 years ago

To make it more interesting, you could potentially create multiple mazes (ie. 4 would generate Tetris shapes) that connect to each other and self-manage their random elements. Connecting them might difficult but the generator I linked to above allows specifying the start, so it's likely doable and we would know exactly where these connections are, which may allow an opportunity for a mechanic (a special doorway, reward, enemy, difficulty bump, etc).

mminer commented 2 years ago

Hmm yeah, that approach might make sense.

On the pre-made library front, I tried RogueSharp and the maps it generates look good to my eyes. They're effectively a series of rectangles connected by hallways, but the results have a somewhat organic feel to them.

################################
################################
################################
##########.....#################
##########.#...#################
##########.############......###
##########.############......###
######.......................###
######.......##.......#......###
#########..####.......#......###
#########..####.......#......###
#########..####.......#......###
#########..#######.####......###
#########..#######.######.######
#########..#######.######.######
#########..#######.######.######
#########........#.######.######
#########..........####......###
#########........######......###
#########....................###
#########..############......###
#########..############......###
#########..############......###
#######........#################
#######........#################
#######........#################
#######........#################
#######........#################
#######........#################
#######........#################
################################
################################

To enforce hallways with doors, generating four smaller maps like you mention (or two side-by-side?) and carving a path through them seems like a good idea.

For monsters that you have to slay by first finding a chest with a weapon, we could do something similar:

  1. Generate a 1-unit wide hallway
  2. Randomly place a chest in an empty tile
  3. Do a pathfinding check to see if the chest is reachable without passing through the monster
  4. If it's not reachable, back to step 2; repeat until we know it's possible to get a weapon before reaching the monster
mminer commented 2 years ago

I connected RogueSharp to our tilemap. I think this might work nicely as our foundation.

Screen Shot 2022-01-27 at 22 01 24

mminer commented 2 years ago

I'm going to call this done. We have to do more work to fill the dungeons with obstacles and items, but we can consider the map generation itself finished (sans tweaking).