Savoring Sword Behind-the-Scenes
Added 2024-01-09 18:09:56 +0000 UTCDungeon Generation and Movement
Below I'll explain how the dungeon is generated as well as how Starla knows where to move.

The dungeon is generated on a 21x21 grid, making a total of 441 tiles for things to spawn on. The first thing the generator does is pick a random tile for the enterance and rotates the door. Then, it starts picking tiles to build a hallway until it decides to place the exit.

After it places the exit, it picks another random tile and generates another hallway until it reaches a preexisting hallway. It does this over and over again until it's happy. π

After that, it picks spots to place object and monsters. Some objects will replace walls or spawn in hallways, but monsters can only spawn in hallways.

How the generator figures out if a tile is a hallway or a wall is by a very large sequence of numbers, specifically 1s and 0s. Each tile has a number corresponding to it, making a total of 441 numbers in the sequence. 1s are hallways and 0s are walls. This is also how Starla moves around the dungeon! Whenever she wants to move a specific direction, it first checks if the tile she wants to move to is a 1 or a 0.

This is where is gets a bit confusing. Tile 1 is located at the bottom left of the grid, and tile 441 is located on the top right. So, checking tiles to the left and right of Starla is easy, it first checks which tile she is on, and then checks the number before or after it in the sequence to figure out if its a wall or not. (The image above shows how this works.) If she wants to move forwards or backwards, that's where it gets tricky.

Since there are 21 rows of 21 tiles, the tile in front (or behind) starla is actually 21 numbers away from her current position in the sequence. So it basically adds or minuses 21 from her current position, and checks that number in the sequence if it is a 1 or a 0. If it's a 1, she's able to move there! πͺ
Hope I explained this well enough!
Scene Overview
I will try my best to explain and show what the game looks like outside of the dungeon and where everything is placed!

This first image shows how the walls are moved downwards to create hallways. Each tile on the grid has a cube that will act as a wall. In my previous 'behind-the-scenes' I explained how the dungeon generator marks hallways with numbers, and when it looks at which tiles should be a hallway, it moves that cube below the dungeon floor.
The same things goes for cracked walls! Breaking them simply moves the block below the floor.
When the dungeon resets, it moves all of the cubes back into the dungeon and repeats itself.

All of the items, monsters, and interactables are stored way below the dungeon where Starla can't reach or see them. When a new dungeon generates, it chooses which items to use, how many of each, and where to put them. Then it grabs the items from the pile and places them into the dungeon!
All of the remaining items are left in the pile until the next dungeon is generated.

This last picture shows the placement of everything. To the left we see the dungeon, and to the right we see the minigame where Starla slides down the mountain. Depending on whether she is exploring the dungeon or sliding down the mountain, she will be placed at either spot.
Below the dungeon you can see the pile of items that were left behind.
Hope you enjoyed this little sneak-peek into Savoring Sword!
Comments
Thank you!! π
CupCupMug
2024-01-09 23:36:27 +0000 UTCWow thatβs hella cool
Lorne
2024-01-09 23:18:53 +0000 UTCHonestly I did it all on my own π though I am sure there are guides out there that will do the same thing as I did. Plus, when I first started to learn how to develop games, I used a lot of guides back then. So it definitely came from experience as well!
CupCupMug
2024-01-09 22:19:06 +0000 UTCYou explained that perfectly! Did you have any guides that helped you or did you just wing it?
Lorne
2024-01-09 19:02:55 +0000 UTC