How a famous mathematician helped me make BIG levels for my indie game - Blood Running Devlog 03

Cover Image for How a famous mathematician helped me make BIG levels for my indie game  - Blood Running Devlog 03

Watch Instead

Procedural Generation

Image for blog

Procedural generation is like if a chef had a magical cookbook filled with special recipes.

Instead of planning each recipe, the kitchen can just follow the magical cookbook to make an endless variety of different dishes.

Just like the chef's cookbook, procedural generation is like a creative kitchen assistant that uses algorithms to cook up new and exciting things, like landscapes in video games or layouts of virtual cities.

Image for blog

Cellular Automata

In my game, I use a technique called cellular automata to generate the levels.

The concept of Cellular Automata was originally discovered in the 1940s by John von Neumann and Stanislaw Ulam at Los Alamos National Laboratory.

Image for blog

Ulam and von Neumann created a method for calculating liquid motion in the late 1950s. The driving concept of the method was to consider a liquid as a group of discrete units and calculate the motion of each based on its neighbor’s behaviors. This was the birth of cellular automata.

Image for blog

Jump to the 1970s, and John Conway came up with the Game of Life which brought cellular automata to the second dimension.

It involves a 2 dimensional square grid populated with cells. Each cell is either alive or dead and interacts with it’s eight neighbors.

At each step in time in the game, these rules occur simultaneously:

  1. Any live cell with fewer than two neighbors dies.
  2. Any live cell with two or three live neighbors lives on.
  3. Any live cell with more than three live neighbors dies.
  4. Any dead cell with exactly three live neighbors becomes a live cell.

This simple system can create all sorts of behaviors, and people even have even built computers inside it.

Image for blog

Implementation

To use this in my game, I started with basic map generation using cellular automata, then stretched the map vertically and filled in some of the smaller holes, and then made it more interesting by adding terrain details.

Image for blog

Then I added some grass, trees, wind turbines, and a cool parallax background to bring the level to life.

Image for blogImage for blog

Revamping the Artwork

After a month of work, I decided to redo all the art for the game and it was time to revamp the first level.

I recolored everything, adding new trees, rocks, skeletons, and a blue noise algorithm for better object generation.

Next I added mutant deer with extra legs, corrupted by the chemicals in the wasteland. And yes, they do drop you their meat…

Image for blog

Places to Explore

The player needs buildings to find cool loot and explore, so I made prefab rooms that can appear in the level. These rooms are created like any other, and their layers are saved to a file when the game loads.

After that, I load the necessary file to make the prefab, spawn it at the bottom of the level, and I teleport the player there when they walk through a door.

This way I don’t have to save the entire state of the main level whenever the player enters a building.

Image for blog

Each level will have a special location with important characters and enemies. For the first level I’m planning a massive crashed spaceship like in the cover art, I started by creating the design of the interior of the spaceship.

Image for blog

The spaceship and the land around it are controlled by a rogue AI who leads the bandits.

Image for blogImage for blog

Conclusion

It's still a bit rough around the edges, but that's how I made the first level for my game!

If you enjoyed reading, wishlist Blood Running on Steam and help us reach our goal!


More Posts

Cover Image for Crafting the PERFECT Player Home - Blood Running Devlog 02

Crafting the PERFECT Player Home - Blood Running Devlog 02

Homes in video games aren't just a place to sleep and keep your loot safe; they can also serve as a showcase for your creativity.

Cover Image for Unlock the Power of Pixel Art - Blood Running Devlog 01

Unlock the Power of Pixel Art - Blood Running Devlog 01

Pixel art animation is like gardening, but instead of planting seeds, you meticulously place each flower, leaf, and speck of dirt by hand.