Panda Hell update #7: Procedural level generation is live!

Before going deeper into the new features I have added this week, here’s a quick video of the current status (captions pointing some features):

Procedural generation script

Last week I decided to take a detour in the current development and move from a random generated level system to a procedural generated one.

I really believed this could take me at least a few weeks but actually was “simpler” than expected, as there’s lots of case studies in internet where you can learn from, in this case after researching in different implementations for a couple of hours I decided to go through with Will’s tutorial (Six Dot Studios)that you can find below, as was based on Nuclear Throne, which is one of the games I’m taking inspiration for Panda Hell:

The procedural generation script above is based on the random walk algorithm (drunken walk for friends, heh … ), and was a great base to develop my own procedural generator system.

While the generator above works nicely as a paradigmatic example, nothing normally works out of the box for your specific project, so few tweaks were needed.

In my case for example, as you can see in the screenshot below, the green square (exit tile) as well as the white square (power-up tile) were both generated outside of the maze, hence impossible for the Player to interact with them.

There’s also the problem of the random spawn, where enemies or the player could spawn in closed rooms, with no access to the rest of the level.

I’m still working on little modifications to the algorithm to fit exactly what Panda Hell needs, but still needs some tweaks here and there to be completed and 100% functional, as the procedural generation works nice 99% of the times but I still find some edge cases that needs work once in a while.

Random generation of sprites, enemies and items

After this initial stage was completed, I felt that was a good time to push forward the overall design and art of the game, while I have a long list of bugs to fix and features to implement, a change of pace is always nice, and was not completely unrelated to the algorithm, as I also want to populate the levels randomly once generated.

After some planning I found out that there’s 3 base models I need to have for the walls: Empty ceiling (ceiling tiles), empty ceiling and bottom (middle tiles), empty bottom (bottom tiles), plus one basic model for the floor.

From this point I added some extra functionality to the default generator so it can add randomness to the sprite generation, for example I have 4 variations of the floor game object, after applying this new function, it looks like this:

New features added this week:

  • Procedural level generator
  • Added ammo functionality. Weapons use ammo, this is reduced on use and enemies may drop more ammo.
  • Weapon switch is live. Switch between weapons pressing the Space key.
  • Basic info screen between levels. This needs more work, for example show the Player stats till this point, but for the moment a basic implementation is in place.

Objectives for next week:

  • Keep fixing bugs and edge cases created by the procedural generator script.
  • Set all environment to be destructible except the outer walls of the level.
  • Invest time in the art aspect.


3 responses to “Panda Hell update #7: Procedural level generation is live!”

  1. […] researched and worked on in the past, for example the procedural level generation (this is how Panda Hell levels were created), or pathfinding, but other items I never had the chance to implement them, […]

  2. lakehoundgames Avatar

    Do you have an idea how to tackle the item generation outside of the level? I had a dungeon generation learning project a year or so back, and I solved it by creating a list of coordinates that were unavailable through my level generation script. It wasn’t really elegant, but it “kinda worked”. If I’d do something like that now, I’d probably default all tiles as unavailable, and then upon level generation add their coordinates to a list of available tiles. This way you could just randomly choose a spawn location for an item and then remove the coordinate from the list of available tiles.

    1. Gabriel Maldonado Avatar
      Gabriel Maldonado

      That’s a good question, and not sure if I have a good answer as also would depend on your game specifics. In my case I use a grid, which each coordinate is a Vector2, then I loop several times through this grid and each vector to generate everything, for example first all floors, then the walkers, then the walls, etc, ..

      Then from what is leftover after these operations, you basically have the playing terrain: Available floors, which are not walls, and are generated and valid.

      Once you have this, what I do is trigger a script that populates stuff in random X and Y Vector2 within these valid floor coordinates. I personally do not remove the coordinate from the list once is used, but just because items are generated once per level (hence cannot be repeated in the same tile) and enemies spawn recurrently as long as the player is not dead, so I don’t mind if they spawn in the same spot, as they wander around.

Leave a Reply

%d bloggers like this: