Game
Rhythm, Paper, Scissors
7 years ago

Random Level Generation - How it works


Hello again, Mattis here. I am back to tell you more about the random generation in Rhythm, Paper, Scissors. Today I would like to go over the basics of how the script actually generates rooms. I would also like to tease some of the progress I’ve made since the last post. In the next post I will go over the progress I’ve made and the problems I’ve had to solve in more detail.

Random Generation

In order to create the random generation in Rhythm, Paper, Scissors I started out with looking through some tutorials and examples of how you could go about solving this problem. I then created a very basic script that could generate rooms and connect them with corridors, that’s all you saw in the last post and I thought I would explain how the script does this in this post.

I start out with creating a list that holds all the tiles of the entire level. I use this list to keep track of what needs to be instantiated at what positions when I have completed the random generation.

Next step is creating the first room of the level where the player will spawn. It’s a 5x5 room that I place in the center of the level. After the first room is created I generate a corridor that leads out of the starting room in a random direction. I then generate another room at the end of the corridor and the cycle repeats until the entire level is generated.

I control the random generation using various public variables that can be set through the inspector in unity for quick testing and editing.

• They control the size of the level that is to be generated.
• They control the amount of rooms we want in the level.
• They control the size of the rooms we generate.
• They control the length of the corridors that connects the rooms.

5d0a9431a0141.png

After the level is generated and my list contains the information it needs I use the list to instantiate the entire level.

When I instantiate things into the world I pick a random prefab from the Prefab Lists which contain several variants of the floor, wall, enemy and prop prefabs. This leads to the levels looking a bit more varied and interesting.

Currently our sprites are limited but I want to make sure we have a higher quantity of different looking prefabs to make sure that the levels stay interesting.

Finally… I would like to leave you with this GIF of what the levels look like right now and a little teaser for the progress I’ve made with the level generation. The generation scales up the amount of enemies as you generate more levels and makes sure that you don’t get flooded by enemies (or props for that matter) as the levels get bigger and more difficult.

5d0a9433d719d.gif

I hope you enjoyed reading about the Random Level Generation I’ve created for Rhythm, Paper, Scissors and I hope you join me again next time for more in depth info on how I solved some of the problems that came up when I started adding enemies and props into the mix.

See you next time!

  • Mattis



0 comments

Loading...

Next up

Did you know that today is #InternationalJazzDay? 🎷😎

No? 😯 Well, we couldn't pass up this date!

And what better to celebrate this day than #Pecaminosa #OST? 🎷

Let us know what you think about it and have a great weekend!

Another house i made long time ago.

Finished a project I've been working on over the last few days!

Modeled and textured in Blender.

#3dart #lowpoly #npbr #fantasy #hut

Shadow The Hedgehog X pixel art

I-Buki

Mio-Da!

Ibuki Mioda!

One of the most critical update for Sunblaze demo. Now you are able to pet a cat! Finally!

Let me introduce you to the new Mech line: Gendai Spec. Those are Mech that specializes in surprise attacks, covered operations, and stealth. They are equipped with melee weapons but one of Gendai's frames supports sniper rifles.

2d lighting experiment

Hi all, Quick update with a bunch of fixes and changes.

Updated save system, optimisation and screen tear fixes, a new shoutout room and more sounds.

Don't forget to follow the kickstarter going live on the 20th! https://www.kickstarter.com/projects/9fingergames/zapling-bygone

Enjoy!