More upgrades
Since I figured out how to manage adding upgrades, I decided to add some more. The new ones I added are extra HP, HP regeneration, and increased attack range.
Adding these new upgrades required slight reworking of a few variables to allow for them to work. For example, now that HP can regenerate, I need to know what the max HP is to stop the regen from going over.
As for range, I had to figure out how to accurately show the radius to the player. After some research, I discovered a built-in draw() function and found a page in the Godot Docs about it. Through this, I drew a circle and manually aligned it with the attack range collision shape.
After lining the two circles up, I attached the upgrade button to each radius variable. After each upgrade purchase, both circles will update and increase their radius. Figuring this out was pretty easy as I had easy access to these variables and had to change their hardcoded radius values into a dynamic variable.
That Was Easy
While brainstorming how to spawn waves infinitely, I initially thought of generating wave nodes dynamically. I could write a small algorithm to determine all aspects of each wave and feed it as the next wave. While I was in the process of attempting to figure out how to do this, I had a realization.
Instead of having a bunch of predetermined waves, or an algorithm to generate waves, I could spawn enemies infinitely. I removed the section of code that was clicking through an array containing all waves. Then, I used randi_range() which gives a random integer within a range to determine how many enemies spawn.
With this change, I removed an if statement that checked for any more waves to spawn, and instead just looped it. Now, after x amount of enemies were killed, the next wave would start and pick another random number of enemies to spawn.
The best part of this change is that I can set a condition to happen after x waves. For example, after the first five waves, a new enemy type spawns, or the randi_range() of enemies gets larger. This allows the scaling of the game to be flexible.
Instead of using a blurry gif, I'll show an actual video. At the time of writing, for some reason, the only quality available is 480p. Hopefully, that isn't the case now.
‹ Previous Devlog: #11 Next Devlog: #13 ›