Lighting and Dungeon Prefab Techdemo

The purpose of this demo is to show off the dungeon generation that makes use of dynamic and static light sources and custom dungeon prefabs. You can download the binaries at codeplex.

For this release I improved the room and door placement as well as adding the dungeon prefab functionality. I still have situations where the dungeon generator creates unreachable areas. This is due to the way rooms are placed resulting in certain corridors being cut off. I tried to remedy this by
always adding a door to a deadend with a corridor on the opposite side. Its not perfect yet, but I’m happy with 90% of the results.

I haven’t thought of placing lights in a procedural manner and as a shortcut I make use of the prefabs to get them into the dungeons.

The lighting has been adjusted to allow for proper alpha blending of the light values (before I just used an additive blending which resulted in mostly white lights). There is still the problem of tiles being lit by lights from behind walls. I hope to correct this in a future release.

I am still undecided as to whether lights within the dungeon actually add any value.

Enjoy, and as always comments and feedback are welcome.


This application was developed using .NET 3.5 and is written in C#. I use SDL.NET which runs on top of the Tao.NET framework. Input is handled using SDL and rendering via OpenGL. I use DevIL to do image loading etc.

I have only tested this on Windows XP. And you will need .NET 3.5 to run the application. I have added the SDL dependencies to this release.

I am struggling with getting the application working on OpenSUSE. The error has something todo with DevIL. If anyone is willing to assist. You will need to install Mono 1.9 and SDL.NET. To run the application on mono you will have to use the following script ‘mono RogueLib.Game.exe’


I have noticed some rendering issues on my Radeon X1900. Could be driver related. Works fine on all NVidia machines I’ve tested. I didn’t expect to have any issues using OpenGl but I do.


Use the direction keypad or numeric keys to navigate the map.
Use spacebar to create a new dungeon.
Use escape to end the demo.

Custom Dungeon Prefabs:

The dungeonprefabs.xml file in the config directory is used to configure custom dungeon prefab rooms.

The layout tag uses a CSV layout to describe the structure. Use 0 for a NULL tile, 1 for a floor, 2 for a wall and 3 for a closed door.

Each dungeon row begins on a new line.

The light sources tag allow you to specify lights within the prefab. You can customize the light colour, radius and the attenuation function. The attenuation parameters are used in the formula 1 / constant + (linear * distance) + (quadratic * distance * distance).

The connectors tags tell the dungeon generator how to place a prefab within the dungeon. The generator will attempt to connect the prefab to a corridor for each connector specified. I haven’t really tested this algorithm for connectors within the prefab. My examples only have connectors on the edges of the prefab.

The prefabs will be placed over any existing dungeon structures. At the time of placement there should only be corridors and the prefabs will be placed adjacent to any corridors.


3 thoughts on “Lighting and Dungeon Prefab Techdemo

  1. Hey, finally got around to downloading this and trying it out, everything is looking real smooth, love the FOV and lighting.

    I’m actually trying some stuff with C# myself, i’m currently using sdl.Net and the Tao framework also. While looking through the blog and code i noticed you use XML to load the dungeon prefabs and such and i was just wondering how exactly you went about doing that. I’ve been trying to use System.xml but reading XML documents just isn’t working out for me. Do you have any directions or tips on how this works, or how you used it?

    Other than that, fantastic blog, I’ve had you on my RSS feed list since ASCII dreams linked to your random dungeon generation series. Good work.

  2. Actually,
    sorry after some tinkering (And the discovery of XmlConvert) i was able to get my program reading and assigning data in no time.

  3. I make use of XmlSerialization to deserialize my xml files. The schema of the XML files you see are basically the structure of my DungeonPrefab class.

    The layout tag is rendered by implementing IXmlSerializable.

    Check out XmlSerialization, its a really easy way to write and read from XML files.

    Glad you enjoyed the demo.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s