2D Game Dev Journey — Day 26: Wave System and Balanced Spawning

Welcome to 2D Game Dev Journey — Day 26: Wave System and Balanced Spawning. Today I go over how I implemented a wave system that sends out different amounts of enemies at each stage, as well as balancing enemies and power-ups.

Starting Point & Setup

Today we will be starting right where we left off in 2D Game Dev Journey — Day 25: Homing Missile.

Wave System

The goal with the wave system to send out enemies at a controlled rate, and once the enemy reaches the last wave, they will be greeted by the boss (which is something to come). Once the player has beat the last wave, they should be greeted with a “You Win!” text. After some coding, this is how my win screen looks:

Don’t worry, we’ll be polishing up that win screen in the future :).

The way I implemented this was mainly through a struct. The reason is that I wanted it to be easy for a developer, at any point, to be able to create more or fewer waves through the editor. With my implementation, a developer can easily set the number of waves, and which enemies appear in a wave, all through the editor. Below is an example screenshot:

As can be seen, on my Spawn Manager I have a variable named “Waves” which keeps track of the enemies to be spawned in each wave. The way I was able to create this in the editor was through the use of structs. My specific implementation for the struct is shown below:

Creating easy-to-use tools like this is actually one of my favorite things to do in general as a developer. Creating tools like these helps when it comes to iteration times, as well as helping those without much programming experience to still be able to contribute to the overall project development in a big way.

Balancing out Spawns

Now when it comes to balancing things out in games, it is very difficult to do and requires a lot of fine-tuning of a myriad of things. Sometimes balancing means decreasing or increasing the probability of certain drops. Other times balancing means increasing or decreasing the difficulty of enemies whether through spawn rate, which enemies spawn when they spawn, etc.

For our purposes, and at this time, balancing will pertain to controlling the probability of power-ups drop, as well as controlling enemy spawn rates. Thankfully the wave system we just created helps with the balancing of enemies per wave already, so we only need to worry about the power-up drops. As it currently stands, this is how I have power-ups distributed

As can be seen, my rare power-ups consist of the heated shot, the homing missile, and the health power-ups. There is a 5% chance a rare power-up will drop. The rest of the power-ups are set to drop randomly if a rare one is not selected. The only power-up that has a higher probability of dropping is the Ammo power-up. This is because if our players will have a limited amount of ammo, we need to ensure they have good means to replenish it. I increased the ammo power-up drop rate by coding in an implementation that gives a 20% chance an enemy will drop an ammo power-up on death.

Conclusion

Thanks for checking in and reading today’s article. In the next article, I will be making the boss for our game. If I have made any mistakes, please let me know so I can correct them for future readers. If you would like a more in-depth tutorial about anything I went over today, let me know and I will take the time to write something up.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store