• Register
Post feature RSS Jumper Game Level Generation

Follow us on our journey in adding procedurally generated maps to our game.

Posted by on

Generating a Level

I've been working on a jumper game in which players run along a strip of land, dodging obstacles like water pits and spinning blades and avoiding traps such as flipping spike panels. So far all of the maps the player has seen has been hand crafted by me and our producer, doing our best to make levels feel interesting and challenging. The problem with this method is it takes a good while to create, test, modify, and input all of these levels, so a level generation system seems like a logical next step.

Banner2

Generating a landscape, albeit a thin one for our game, is always a daunting task. You can’t just randomize all of your options or it would look like madness haphazardly crammed together. You do need a little madness though, that’s the point of generation. Something that is predictable enough, but still presents you with fun, new, and interesting layouts. So I will be walking through how I handled my first pass at world generation.

The Level

First and foremost I started with the basics: water and grass. I generate each row at a time of 7 bricks wide randomly. This produced what I said before, just a crazy madness of water chunks and grass that the player couldn’t progress through. To fix this, I added a “fixer” function to each row. It looks at the row that spawned before it and matches up the water and grass blocks, also creating pathways the player needs if none existed. This made a nice flat land with pools here and there. There was more complexity to how I fixed the land, but that’s the basics of it.

world1

Now I wanted to clean up some of the awkward shaped lakes and pave way for rivers. There are logs in the game that flow down streams, but for that to work, I needed to generate stretches of water that go across the whole row. I told the game to increase the chance of spawning water bricks until a river is made, and then tone it down for a little so there’s a chunk of land after it. This made crossing rivers at regular intervals.

world2

The Obstacles

Next was obstacles the player has to face. Again, randomly throwing them into the world would look sloppy. So what I did is made a list of each possible trap and gave each one a spawning chance between 0 and 32. I chose this, because if it randomly chooses over 20, I tell it not to spawn at all. This makes it so the level can possibly have every kind of trap, or only a few kinds.

I then spawn the traps on a case by case basis. Guns should spawn on the edge of a row, flipper spikes only spawn on ground, spinner blades spawn symmetrically to each other and enemies spawn wherever. Each time it spawns a trap, it decides how soon the next trap should spawn, and each trap changes this value. For example, flippers and guns are less of a hassle than spinners and enemies, so if I spawn one of those, there’s a chance another trap could spawn directly next to it. Enemies have the largest wait time, making sure they are spaced out at least 4 units per baddie.

World3

I turn down the chance of spawning a particular trap after it’s used, and then turn it up when another type is spawned. To make sure the game doesn’t favor which it chooses first, I made a list of all available traps to spawn and randomly picked from it, not factoring in it’s spawn chance. Then it uses the spawn chance for what it handles next. I do the same thing with everything else I spawn: I create a chance of it spawning and then modify it after it spawns. I even have a random chance to increase or decrease that chance afterwards, so maybe there will be 5 guns in a row, or a clean slate of air with 2 traps in it.

world4

What’s next?

There's still plenty more to be worked on here and it’s far from perfect, but for a start, it’s a good baseline. The player always has a chance to beat the level and get by the traps. It’s really interesting seeing what combinations can pop out or what ways it can generate a chunk of land. The important thing to keep in mind is to always give everything a chance. Don’t just favor one brick over another all the time. Give each one their own spot to shine in and don’t overload the player with objects; make sure there is a fair amount of open space for them to breathe in.

it will be awhile before the procedurally generated maps feel as good as the human designed ones but I hope to share our progress with anyone that’s interested. Our team loves to to get feedback and make improvements to the game then post a build online. Follow my game and let us know what you think.

Just Duck It 1.8.16


Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Feature
Tags
Feature
Browse
Features
Share
Related Games
Duck n' Dodge
Duck n' Dodge Platformer
Related Engines
Unity
Unity Commercial
Related Groups
Grenade Tree Games
Grenade Tree Games Developer