Generation Game

Mouse Bounce

22 Sep, 2014

By Dave Ward

Warning: Technical post!

The most interesting and difficult part of Mouse Bounce to develop has been infinite, randomly generated levels.

A level is a combination of:
– Platforms
– Pickups
– Enemies

The main goal of level generation is to make something that is different every play through, fun and more difficult as the player progresses. Easy, right? So, starting at the beginning, Platforms! Hopefully, as you’ve noticed, there are two levels of platforms, one at the front that the player can jump on and one at the back that he can’t. They are switched around with a double tap to make finding a path more fun and challenging.

There always has to be at least one platform within reach otherwise it’d be cruel and you’d hate me. This is done using the following simple formula:

NewPlatformY = OldPlatformY + RandomNumberBetween(PlatformHeight, MaximumJumpHeight)

Using this formula can generate a playable level but it’s no fun, there’s no challenge or difficulty.To make things interesting, platforms need to be spawned at the back as well as the front of the level. Here are a few methods to do that:
– 1. Spawn a platform at the front or back using the above formula. Simple. Normal difficulty.
– 2. Spawn two platforms at the same time, front and back. More platforms. Easier difficulty.
– 3. Spawn multiple platforms in one go. All at the front or all at the back. Less platform switching needed. Easier difficulty.
– 4. Spawn a platform that will fall away when jumped on. Harder difficulty.
– 5. Spawn a moving platform. Harder difficulty.

With each option affecting the difficulty, the easier options should be picked more often at the start of the level and the harder ones almost exclusively when the player reaches high enough.

What is a mouse without his cheese? (Probably just a cheeseless mouse but glossing over that). The level needs to be sprinkled with cheese pickups. When any platform is generated there is a chance of a pickup coming with it (15% chance if you’re interested). This leaves pickups everywhere, the most fun ones being on moving, falling and hard to reach platforms.

Enemies are similarly linked to platforms, given a random chance to spawn at the same time. Again, this is something that has a higher probability as the difficulty increases.

All of this makes a level. The generation algorithm triggers whenever the players moves a certain distance upwards, adding more to the top and taking away what can’t be seen at the bottom.

Hopefully you found some of this interesting. Ask me any questions and let me know what you think on Twitter.



< Back to blog feed

Get the latest posts delivered to your inbox