Full District Generation Demo
What's up everyone? I've got great news! The procedural generation script for generating an entire district is finished and ready to be thrown into CoA. I'll be continuing to make tweaks to the script to increase its efficiency and ease of implementation, but it does work which we love. Another cool thing is that the script allows developers to set the dimensions of the district by changing the length of the four sections which collectively make up the district. This part of the script's implementation is a little tough to read and follow, so that is one spot I'll be making changes ASAP. For now though, the script can handle any number greater than or equal to zero (0) as the input for section length.
For those of you interested in how the district generation works I'll be discussing the technicalities of the script below. For the rest of you, please enjoy the attached demos of the Slums district being generated using different inputs for section length.
Section Length of Zero (0)
Section Length of Six (6)
Section Length of Sixteen (16)
The script itself works almost identically to the previous script I had made to create one horizontal section of a district. There are some differences, but the same three steps are, more or less, still present. These are the steps used in the script:
1. Initialize the district as a 2D array of 0s, 1s, 2s, and 3s
2. "Pathify" the array by adding directions to the array indices
3. Instantiate the corresponding prefabs onto the game board
It's important to note that the section length property does not currently take corners into account. Therefore, the actual length of a section is the input value +1 or +2. In this step, 0s represent spaces which will not initially receive a room. A 1 means a room will be placed in that position. A 2 means a space is reserved for corner prefabs, and 3s are spaces which are out of bounds and will not be given a room under any circumstances. So, the initialization step of a district given a section length of four (4) would look something like this:
2 2 0 1 1 0 2 2
2 2 1 0 0 1 2 2
0 1 3 3 3 3 1 0
0 1 3 3 3 3 1 0
1 0 3 3 3 3 1 0
1 0 3 3 3 3 0 1
2 2 0 1 1 0 2 2
2 2 1 0 0 1 2 2
The "pathify" step would then add directions to positions with a value of 1. If necessary, a 0 will be overridden to connect the path from one corner to another. Lastly, prefabs are added to connect the sections on spaces where we see 2s. Which positions represented by 2s are given a prefab is dependent on which position two connected sections end on before the corner spaces.
Finally, we simply iterate through the array one more time. We grab the prefab that corresponds to the direction given to a position and generate a random number to determine which version of that prefab will be instantiated on the screen. The final result looks something like the demos which can be viewed above.
I'm looking forward to sharing more procedural generation progress with you all! Hopefully next time I'll have some demos available for the remaining two districts.
Get City of Abominations (2021)
City of Abominations (2021)
How will you control your bloodlust?
Status | Canceled |
Author | Precipice Games |
Genre | Action |
Tags | 2D, Action RPG, Dungeon Crawler, Perma Death, Pixel Art, Singleplayer, Top-Down |
Languages | English |
Accessibility | Subtitles |
More posts
- KM Devlog 2May 28, 2021
- KM Devlog 3May 28, 2021
Leave a comment
Log in with itch.io to leave a comment.