Software Used: Unity C#, Blender 2.8
Torchlife is a game of endless adventure with a dangerous twist. While exploring unlimited dungeon rooms, you must keep your torch lit or face being plunged into complete darkness! At the start of each level there is a fireplace to relight your torch, but beware, monsters and traps lurk at every corner.
Torchlife has evolved from an older project called "Escape From Odin" when I decided to improve on old code. I updated code with many challenges, but in the process learned many valuable skills.
Procedural Dungeon Room Generation System
In every Torchlife level, the rooms are procedurally generated. It uses an additive generation system where each room has the ability to create another room at each of it's exits. This continues until a certain number of rooms is reached, which then leads to all open rooms sealing off it's exits with a wall. Most of the work went into room collision detection (detecting if any rooms intersected with each other), which was one of the greatest challenges of this system. The generating part was by far the simplest part while the collision detection system was the trickiest part. The finished product involved passing a test where a 100,000 room building was generated with zero room collisions. The video on the right shows how rooms are generated (top down and perspective views shown). Each room exit has a spawner which determines which room to spawn next. If there are no more rooms to be spawned, the spawner will spawn a wall to seal off the dungeon.
A more detailed look on how rooms are generated.
This is a spawner object. It is responsible for spawning a room or a wall off of the exit of another room. It was created as child object of the room to the right of it. If the spawner is inside of another room, then the spawner is destroyed because there is already a room in that location. If the spawner is inside of another spawner, then every spawner, except for one, is destroyed.
This is the sensor that is attached to the spawner in the first note. It is responsible for scanning in front of the spawner to determine what the maximum size is for spawning a room. If the sensor collides with another room, then only a single size room can be spawned. Else, a double size room can be spawned. As larger room sizes are created in the future, more sensors will be added.
This is a spawner who’s sensor (see 4.) is inside of another room. The sensor sends back information to the spawner telling the spawner to limit generation options to only single size rooms.
This is a sensor which is inside of another room. Because of this, it will send information back to it’s spawner (see 3.) about the maximum size that a spawner can generate.