Thursday, December 22, 2011

Random dungeon generation

Random dungeon generation is fairly easy, start by creating a room, find a wall and insert a door. Create a new room or corridor on the other side of the door and repeat. That way every room is connected so the player can get everywhere. Problem is making it look good.

A dungeon generated in this way, will be centered around the first room. It will not be a dungeon that is elongated so that he player will have to walk from one end to the other. Unless the map is narrow and the start room is in one end of the map.

This is my first attempt at a random dungeon. The code is ugly and was just slapped together.It will need some serious re-factoring to make it readable and usable.


It consists of 50 rooms and 50 corridors. Rooms can be connected to each other and corridors can be connected to each other.So you can get a bunch of corridors connecting in different ways. Or just a long corridor protruding from a room. I haven't decided if this is a problem or not, but might keep them as it is very simple way to do it.

Another part of the dungeon





Walls will be added to the render method when i have some graphics to draw. The same goes for doors.

On a side note, when drawing a full screen of tiles and a full 1024X768 image for the frame around the edges, yes yes I know its a waste to draw the entire image. I am running around 900 fps. The second picture is around 1200 fps. These numbers are without any optimizations, so can probably be increased.

No comments:

Post a Comment