Moon Rift is a 2.5D Rpg platform shooter boasting random level generation and a virtually limitless amount of randomly generated guns!

Post feature Report content RSS feed Moon Rift Level Generation

An in depth look at the level generation for my game Moon Rift.

Posted by zemrod101 on May 21st, 2013

Moon Rift uses three different generation algorithms at the moment and I'm hoping to add more. The three I have are as follows:

Linear Generation:
This is probably the simplest code and generates levels resembling the kind you would find in older platformers like Mario. The Idea is a simple, fun, fast paced level that lets you focus more on jumping and shooting than the exploration side of Moon Rift.


Dungeon Generation:
The dungeon generation is more relative to games like Zelda or Castlevania. The code creates a series of rooms and pathways to explore. Fans of rougelikes should find this pretty familiar. At the moment I'm working on separating the rooms into different themes relative to their size.


Terrain Generation:
So far I've spent the most time on this type of generation and will explain it in detail shortly. The demo level features this algorithm, you can try it here. The terrain code creates a more natural looking environment and then fills it with plenty of caves and crevices to explore.


Like a lot of other procedurally generated algorithms, my terrain generation uses a lot of perlin noise. In short, perlin noise is a number generator that returns smoothed out random numbers. This is important to create a rolling hill effect for the terrain. To start, I use a random seed and plot out a perlin noise wave across the map, please forgive the extremely crude drawings that follow.


This creates a decent looking Hill shape but is rather boring. To make it more interesting I plot a second perlin noise curve along the previous one, only at a higher frequency but smaller magnitude (increasing the frequency creates a much bumpier path while the magnitude sets the min and max size of each curve).


While the result is a much more organic and interesting terrain, it still doesn't lend it's self to the game play of a platform shooter.The last step in creating the terrain height is separating it into multiple sections. These sections are randomly shifted apart, first horizontal, to create flat areas much more fit for shooting, then occasionally vertically to create cliffs and ledges. Once again, I'm sorry for the picture, it really doesn't do it justice but it gets the point across!


Now that the terrain heights are all set its time to dig out some caves! The digging code is pretty simple, for each cave the code creates a digger object. The digger carves downward in a semi random direction for a set distance, then digs in another semi random direction for yet another predetermined distance, this repeats until the cave is at the desired length. The size of the hallway the cave carves out is determined by perlin noise as well, this ensures the caves come out more natural looking. The demo level is set to 50 caves, with an average length of 40 (tiles). Having the value this high results in not only caves, but plenty of valleys and gorges.

The last step in the Terrain generation is to make sure every area is reachable. Moon Rift doesn't use any jet packs, grappling hooks etc. Where you can explore is limited to where you can jump so it's important to make all areas of the map accessible. The code moves through each tile starting from the top left of the map moving downward. Whenever an edge is found, the distance to the ground below it is measured, if the distance exceeds the players jumping ability a platform is placed semi randomly below the edge, the code repeats this step from the platform until it finds ground.

I hope you found this at least some what informative and don't forget to check out the kickstarter page for way more information!

Post comment Comments
Biscuitfist May 22 2013 says:

Nice of you to share this information!

I can't say much for programming myself but I like to see solutions. :)

+2 votes     reply to comment
d2theRizzle May 22 2013 says:

These are all pretty great. I'm especially familiar with the dungeon generation as I've written (most of) a roguelike in python. I'm also familiar with perlin noise, but I haven't used it (yet :) ). It's great to see these different methods combined to make one awesome level generator. Keep it up man!

+2 votes     reply to comment
Post a comment

You are not logged in, your comment will be anonymous unless you join the community. Or sign in with your social account:

Moon Rift
Send Message
Release date
Released Nov 2013
Game watch
Start tracking
Related Games
Moon Rift
Moon Rift Platformer
Related Engines
Unity Commercial Released 2005