Cyningstan DOS Games

Games for Early PCs

Building a Dungeon Level

A sample dungeon generated by the LevelMap library
A sample dungeon generated by the LevelMap library

Wednesday, 28th April 2021

I've been building a dungeon generator library for use in future projects, called LevelMap. A further development of the dungeon generator used in Ossuary, this library will give more variation in dungeon shape and construction than we see in Ossuary.

Ossuary's dungeon creator works on grids at two levels. At its most detailed, it has a strict 16x16 tile dungeon. That space is split up into nine cells on a 3x3 grid. Each cell of 4x4 tiles can be a chamber or a corridor, and cells are connected up in such a way that no groups of cells are fully isolated from the rest of the dungeon.

The dungeons we see in Ossuary therefore have some variation, but are very samey. There are a number of ways that we can change things up. Firstly, we can vary the overall dimensions of the level. We'll be sticking with a maximum of 256 tiles for performance reasons; my projects are in C and I want them to work on an 8088. But within this limit we're not restricted to 16x16 tiles. The illustrated dungeon is 19x13 cells, which is 247 in total.

Along with this change you might notice that I've abandoned the 3x3 grid of cells; this one has a 4x3 grid instead. The number of cells varies with the proportion of the dungeon. The most extreme dimensions I support are 28x9 tiles, which allows a grid of 6x2 cells. As in Ossuary, these are randomly determined to be chambers or corridors. Notice also that the cells vary in size, which adds a bit more variety to the dungeon.

Doors, absent from the Ossuary dungeon, have been introduced here. The process is simple: the exit of each room is marked with a door, while the exits that link corridors together are not. This separates the rooms off properly, while linking the corridors together into labyrinths like the one that permeates most of this level. The doors are optional; the library always generates them but the host game is free to treat them in the same way as open passageways.

Another way to provide variation is by linking some of the chambers together, in the same way as corridors. There is a chance that any two adjacent chambers will be joined into one; the separating wall and door will be removed so that the two chambers form one large one. In fact the library will sometimes link three or more chambers together in this way. It's not uncommon to see large L-shaped chambers that are formed from three chambers joined together at right angles.

One big presentational difference from Ossuary's dungeons is that the walls use connected textures. While the LevelMap library doesn't concern itself with graphics at all, it will helpfully work out which walls, doors and floors are connected to one another so that the host game can more easily display connected textures.

There's no immediate plan to use this library. I would like to write more role-playing games in the future, and have various ideas from more advanced dungeon crawlers than Ossuary to full open-world games with dungeon elements that LevelMap would be useful for. It could also be employed in tactical combat games.

Once the library is fully finished, and has been put to the test in a game, it will be added to the Game Programming Libraries section of the web site.

Comments

New Comment

Yes No