Skip to content

JackJ30/DunGen

Repository files navigation

DunGen (unfinished old dungeon generation algorithm) - For Godot 4.0, C#

Original Showcase Video

I have made this repository public due to people asking me on my youtube video. The code is very old, and very bad Please contact me if you have any issues with the liscensing of anything in this repository.

Breakdown

  • Over the course of this project, I created two different algorithms. One spread rooms (rectangular prisms with random sizes) across the grid randomly, and connected them with hallways (with stairs) using a* pathfinding. It worked well, but I wanted tighter generation so I designed a second approach. The first approach (working) can be found on the "old-hallway-gen" branch. This algorithm was essentially the one shown in this video, but with significant improvement to the a* algorithm that allow for more types of hallways.
  • The plan for the second approach was to generate room "clusters", and then connect multiple clusters (and maybe the odd freestanding room) with the a* hallway generation. This was the generation shown in my original showcase video. Clusters were generated by placing a randomly sized room, and then placing more rooms adjacent to its faces. The goal was "true random generation," I didn't want preset rooms like every other roguelike. I randomized the shape of the room by randomly spitting a room "face" into multiple and "extruding" my random amounts. I'm sure the code for this was very crude. I think I also might have implemented room "templates" (t shaped room, L shaped room, etc) that would then have this extrusion algorithm applied. I also allowed rooms to have doorway connection not only on their ground level. This was because I planned to create an algorithm for generating room interiors as well. I won't go into much detail, but the plan was that doorway points in each room would use another a* algorithm to pathfind between them, placing raised walkways or interior stairs. This was never finished. The code of the final working version (before I started a refactor and gave up partway through), is on the "room-cluster-gen-working" branch.

I still like the idea of this algorithm, and I hope to revisit it in the future, especially because the code here is very bad and I would design it much differently. This repository is not intended to be used as "plug and play," please read my explanation, and maybe look at my code for reference. Design your algorithm better than mine.

Visualization

  • One note about the visualization. I generated the actual mesh of the dungeon in a very crude way. It is essentially a 3D tilemap (not sure why I didn't use godot's built in feature for that), but I would not reccomend it. Write your own method of generating 3D dungeon meshes from a 3D array of bools (with door connections).
  • One important thing to consider is each room should have its mesh generated separaretly, except for door connections. This way two adjacent rooms do not merge into one. This rule should only be broken on "door connection points"

I hope this repository helps.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published