Highlight 3/8: Level generation

This week on our Highlight-series, we’re taking a look at how our levels are created.

At the heart of most rogue-like and rogue-lite games is a procedural generation system. For the uninitiated, this means generating content using algorithms and rules (i.e. it’s not totally random). While it can be used for creating many things (enemies, items, etc) it is most often used in creating levels – which is also the case for Gerty.

Building blocks

All levels in Gerty consist mainly of two types of terrain, which in the first world are ice and rock. While ice is more plentiful, it is also the softer of the two, which makes it easy to dig and shoot your way through. Rock on the other hand is tougher, but also mostly found at the bottom of levels near the Teleporter. To make the actual magic happen, we use some weighted Perlin Noise to generate the shapes for both ice and rock (and Juice) areas separately, lay them on top of each other and BAM – you’ve got the base of a level!

perlin_comb

Deeper into the game however, you will start coming across other types of terrain as well. Pits for example are a bit more special. You can’t dig or explode your way through them (they’re pits), but on the flipside, you can potentially snipe enemies from the other side safely. Unlike ice and rock though, we use more hand created functions to generate them, so that they don’t create game breaking dead ends.

pits

Later on you will also find chunks of obsidian, which are effectively indestructible rock. Or is it? Maybe if you had some sort of hammer you might be able to dig through them…

obsidian

Later still in the second world, you will find yourself in a completely new environment, with new terrain to match. Ice has been replaced with sand, which has a secret quirk of its own… There’s also thorns. Care to guess what happens when you stick your fist into spiky brambles?

world2

Level types

Most levels in the game require you to find the Teleporter to advance. These levels come in two shapes: horizontal and vertical. Horizontal levels tend to be more open for exploration while vertical ones are more straight forward. Sometimes you’ll also have to complete a secondary objective before you can move on.

vertical

To break up the pacing, twice per world you’re thrown into a Survival level, where the objective is rather obvious. While staying in the center gives you more space to maneuver, exploration always has its rewards. Survival levels often feature pits or obsidian chunks.

survival

In the middle of each world you will always face an enemy Commander (which you might call a mini-boss) that you have to defeat before the Teleporter activates. As with Survival levels, expect to see pits and obsidian chunks to spice things up.

mini-boss

Objects and enemies

To reward exploration, levels have several helpful objects for you to find. However, throwing them around haphazardly would not make for an engaging experience so instead we use some clever tricks to spread them out more evenly. First, we divide the level into a grid. Second, we place the start and end Teleporters and mark off the nearby areas so that other objects aren’t right next to them. Them we keep generating the rest of the content: possible additional objectives like Power Disruptors, interactable objects like Runes and lastly Forges and Chests.

grid

Like with the Teleporters, we mark off areas around each object, so that for example you won’t find two Forges right next to each other. The end result is a level that’s fairly evenly filled, but natural feeling in structure.

After all the objects have been generated, we finish the level off by spawning the enemies. In each level we randomize the enemies you face from pre-determined difficulty categories, so that you’re unlikely to face the same foes on every playthrough. Depending on the game’s difficulty, they’re placed in either small or large groups, so that you’re rarely up against just one at a time.

Putting it all together

To wrap this highlight up, here’s a step-by-step recap of how a level is generated:

  • Generate ice and rock with weighted Perlin noise
  • Generate possible pits and obsidian chunks by hand
  • Place objectives and interactable objects all around the level
  • Place enemies in groups all around the level

Play for yourself!

Head on over to Steam, add Gerty to your Wishlist and play the free demo to prepare yourself for the Early Access release on December 3rd.

Share this post!