Nerd For Tech
Published in

Nerd For Tech

Balancing the enemy spawn rates

Now that we have added in a few new enemy types, let’s quickly go into our choice method and adjust the rates at which each of the enemy types will spawn at. We will follow the same method as what we did with our powerups.

All we will need to do is adjust the range of our _enemytype variable so that we can give it more of a % chance for it to occur. This way, we can just use solid %’s for what we want our enemies to spawn at.

Next we have to add in our enemy types and the values we want them to be less than. Just as what we did with the powerups, we can simply put all of the criteria into our switch statements initial bracket and then the names we give to each, we can add it in as the different cases for the rest of our statement.

Now that we have implemented a way to control the chance of each unit to spawn, we are nearing the end of the game. Next, we will look into adding a fifth enemy type, a wave system or homing missiles before figuring out how we will tackle a big boss.




NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit

Recommended from Medium

Accelerated Signal Processing with GPU support

Big O Notation and Time Complexity

Import Yelp data into your local DynamoDB

Running a Stateful Workload with Persistent Storage on Akash Network

Deploy simple Dockerized webserver in Azure VM

The Complete Guide to Incorporating Scrum into Your Project in 2020

Kubernetes Custom Resource Definition

MIXONIUM for O&M — Operations and Maintenance Informatics

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
Jordan Evans

Jordan Evans

More from Medium

Connecting our Information and Working with Maps

Creating MineField In Unity (Part 1)

Daily Progression: Player Setup!

Did you just hit me! — Hitbox attack system in Unity2D