itch.io is community of indie game creators and players

Devlogs

Procedural Generation - Spawning Actors and Enemies

Slimegeon
A downloadable game

A large portion of procedural generation is spawning enemies within the generation and Actors/objects to fill up space. The main issue with spawning is not the spawning itself but ensuring the rooms are still path able and that enemies are accessible and work. Since I made my dungeon with tiles, I could gather every floor tile within a room. I then removed all the floor tiles connected to the doors to ensure that nothing spawned right in front of them. Next, I worked on generating static actors/objects within the level. To remain path able, I checked every tile around the object and the tiles the object took up and ensured they were usable. Next, I removed the tiles where the object spawned from the array. I got the tile using a random stream from the array. 

However, a major flaw was that the dungeon improperly removed the wrong tile. To debug, I drew every tile within a room to ensure I was getting all of the tiles and getting them correctly. The output showed I was getting them correctly; however, it was different when I tested the usable tile array. The function even showed the player spawn location was improperly removed. I ensured that I removed an item from the array correctly, but I could not wrap my head around why I was getting different variables for what was being removed and the location of the objects. I ensured my math with scaling was correct, and while doing so, I looked at where I was getting my random variable. I was never saving the random variable; instead, I recalled the get random when I went to remove the item from the array. I hurriedly saved the original random locally and used that to withdraw from the array. That ensured I was removing the correct location, and when I tested the function, it worked great.

Leave a comment