Platformer Procgen

I've been working on a simple infinite runner / platformer game. It uses a pretty simple yet quite functional procedural generation system.


As the player progresses towards the left, new bits of level are generated. These can be of several different sorts, the most common of which is a "normal" piece of terrain. The normal terrain is actually the most complex bit. It generates just one slice of blocks at a time, and before the next slice, there is a chance to push up or push down the terrain. When terrain height is changed, it can either be done with a ramp, allowing the player to run without obstruction, or without, where the player might need to jump.

In this way, the basic terrain itself is quite interesting, which means that the other pieces of terrain do not need to be anywhere near as unique.


Yeah, the background is a bit messed up in these zoomed out screenshots.

So, a counter makes sure that normal terrain does not go on for too long without another piece of terrain. Of these, there are at present 12 sorts, each of which is pretty simple, though taking in different levels of randomness:

  1. A horizontal gap of between 5 and 9 blocks.
  2. A cliff of 2-4 tiles or a drop of 4-6 tiles without a gap.
  3. Two gaps of 5-7 tiles with a platform of 3-5 tiles in between.
  4. A row of 3-5 tiles of spikes.
  5. A pit of spikes of variable depth, 5-7 tiles wide
  6. A spiked wall of 1-3 tiles height.
  7. A 7-10 tile gap with a vertical dropoff of 2-4 tiles.
  8. A 5-7 tile gap with a vertical height increase of 2-3 tiles.
  9. A small segment of 2-3 tiles of spikes.
  10. A flat segment with an extra platform of blocks 3-5 tiles above ground level.
  11. The same as above, but with a gap on either side.
  12. Two gaps with an elevated platform in the middle.



And then of course, there are the final touches of rendering tiles with borders and grass, then adding decals (straw, roots, trees). The small trees are part of the tileset, while the larger trees are procedurally generated (though quite simple, too).

Coins are added as a random chance at a random height above any surface block. Each coin has a chance of generating neighbours next to itself, which is how we get the lumping together of coins that almost looks intentional.

The platform tileset, without large trees, coins, player or background can be found on itch.io. It has quite a lot of other terrains and palettes within it, so that's the next goal, to make the terrain change the further you get or something like that.

Comments