Dungeon generator

C++, C#, Java, PHP, ect...
Post Reply
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Dungeon generator

Post by Torniquet »

Has anyone else attempted to make one?

I have tried many times and read a shed load of forum posts. But never got anywhere...

..until now! :D

I found a nice simple method which seemed the easiest to pull off.

So after 3 evenings of banging my head against the wall, I got all the maths sorted and now have a JS concept ready to use in unity ^^

The hardest part by far was linking all of the rooms up and spent hours thinking of the most suitable way of getting the job done.

Here is the final product. http://playpen.project-blackwidow.com/gen.htm

Its not really in any condition to be used more than a concept and practice. Feel free to look at the source of the page and see how its done if you can understand the mess lol. Its not commented very well... well at all really, but it should be self explanatory if you understand the process.

Here is the article http://roguebasin.roguelikedevelopment. ... generation


Enjoy :)
New Site Coming Soon! Stay tuned :D
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Dungeon generator

Post by Jackolantern »

Very nice! I really like it. In case they could be of more use, or if you wanted to make a solid, maze-like dungeon structure, there are algorithms used in CS that could be of some help: Labyrinth Algorithms. Good ones to check out would be Kruskel's, Prim's, Hunt and Kill, and Eller's.
The indelible lord of tl;dr
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: Dungeon generator

Post by hallsofvallhalla »

you could attach some webGL to this and make it 3d. :)


Its very awesome though. I found one map I will save for my next D&D campaign.
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Dungeon generator

Post by Torniquet »

And here we have stage 1 in unity. The floors are being generated nicely, needs a tweak or two to keep rooms generating so close to each other.
unity-map.png
Moving it from web JS to unity JS was trickier than i expected it to be, but im getting there :D
New Site Coming Soon! Stay tuned :D
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Dungeon generator

Post by Jackolantern »

Looking good :)
The indelible lord of tl;dr
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Dungeon generator

Post by Torniquet »

End of evening 3 and the next step of this beauty is done :D
unity-map2.png
Now I just need to get the walls up with the doors in the right places :s lol.

When I have a proper dungeon being generated, I will upload a copy to the interwebs for people to see ^^
New Site Coming Soon! Stay tuned :D
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Dungeon generator

Post by Jackolantern »

Are the connectors actually hallways, or teleporters (like where you walk from one room directly into the next)?
The indelible lord of tl;dr
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Dungeon generator

Post by Callan S. »

That looks nifty. So your able to make the connecting tunnels break through the walls of each room?
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: Dungeon generator

Post by Torniquet »

@Jack

They are actual hallways which you will walk down to get to the next room. The same logic can be used to link rooms via teleporter as well in theory, rather than generating a mesh you can assign a point to teleport to and from. Which is actually a good idea :)

@ Callan

What you see there is only the floors. My intention is to record all of the points where the doors are and basically skip that point of mesh generation when I build the walls up.

Currently each room and each portion of the corridor is a separate game object (as you can see in the screenshots) I think it might be better to get it all into a single object eventually, but as I am only starting out and have only just started using unity properly, I am not overly worried about that just yet lol.
New Site Coming Soon! Stay tuned :D
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Dungeon generator

Post by Jackolantern »

If you did have the hallways walkable, you probably would want to add to the algorithm to consider the space a hallway has and blow it up into a more content-fillable hallway, or else the dungeon will feel too much like "big room, walk down a tiny empty hallway, big room, walk down a tiny empty hallway". :cool:
The indelible lord of tl;dr
Post Reply

Return to “Coding”