On the process of building a dungeon generator you need to solve several problems involving unconnected rooms, and I can't find a solution for the last one I found:
I can easily detect unconnected rooms, but when it comes to unconnected rooms groups I have no idea of what to do.
Here is a picture of what happens...
If you look at the top-right corner you may see a unconnected group of rooms, I need to detect and connect all the unconnected groups of rooms to the rest.
System
The way it works is very simple, there is a array that contain all the tile objects and it's properties. To change stuff I just need to access the objects inside the array.
Dungeon generation:
- Create all the tiles that are of type floor(gray blocks).
- Place random rooms that don't overlap and have a minimum distance of 1 tile from each other.
- Place walls around all the rooms.
- Place walls on floor blocks with a minimum distance of 1 tile from the room walls.
- Place empty blocks on wall blocks with a distance of 1 tile from the walls.
Map legend
White = room blocks
Gray = floor blocks || corridor blocks
Black block, gray border = wall blocks
Brown || red = door blocks
Full black = empty blocks