Nemesis – Level Generating

So, I have been doing some initial work on my dungeon generation this week. It is not quite as I want it yet, but it is getting there.

As it is now, it tries to spawning a random number of rooms between 20 and 39. The world is 100 times 100 tiles and each room is between 5×5 and 9×9. Each room gets 10 tries to find a suitable. A suitable spot is somewhere where it will not put any of its floor-tiles on a wall- or floor-tile of another room. When the room is placed its coordinates and size is saved and stuffed into a container where all the rooms are saved.

When all rooms have been spawned it is time to connect them with corridors. I pick the first room and say that it is connected. Then, while there are still rooms not connected, I loop through them and create corridors between them. As it is now it is a very crude way to connect the rooms with corridors, as you see on the image below.

RoomLayout1

 

What I want to do is to prioritize shorter corridors. By that I mean instead of just picking two random rooms I want to first pick a connected room and then look for one of the three closest to that room that is not connected and make a corridor between them instead. That way the corridors will be shorter and lower the possibility for corridors that are three to four tiles wide.

Next week I will start with the player, making him able to walk and attack. I will also work on creating enemies, for the player to attack.