Space Shooter Challenge: Shield Strength

The next feature to implement in my Space Shooter game, is the ability to collect multiple Shield powerups, allowing a maximum strength or hit count of 3.To start, I relabeled my ShieldPowerup method to ShieldStrength and appended a requirement for the…


This content originally appeared on Level Up Coding - Medium and was authored by Calum Slee

The next feature to implement in my Space Shooter game, is the ability to collect multiple Shield powerups, allowing a maximum strength or hit count of 3.

To start, I relabeled my ShieldPowerup method to ShieldStrength and appended a requirement for the call to contain an int value called _strength.

Then in my Powerup script, when collecting the powerup with the shield ID, I simply added a value of 1 to my player.ShieldStrength call, adding one level of strength each time.

To use this _strength variable I also needed to create a private int called _shieldStrength. Whenever the method is called, 1 is added to the total strength, if we call this method seven times, we would have a shield strength of 7.

To give the _shieldStrength value the appropriate functions, I used the following switch statement.

The _isShieldActive bool is used in our TakeDamage method to check whether we need to remove a life, so we first need to set that appropriately. Next we also need to enable and disable our shield visual. To add a way for the user to visualize the different strengths, I simply altered the scale of the shield visual to grow as the shield strength grows. Lastly, my default case keeps the _shieldStrength from going higher than the value of 3.

To lower the strength of our shield when the player is hit, in the TakeDamage method, when we check if _isShieldActive == true, the ShieldStrength method can be called before return and pass through the value of -1, to lower the strength.

Once again, I couldn’t resist adding audio. On top of adjusting and redesigning the powerup pickup sound, I also wanted audio to loop while the shields are active. Again, I messed around with some ambience to create a few different loops that I could play from a Random Container in Wwise. But I also felt like there needed to be an indication of the shield starting up. Once I had the sound I was after, I created a Sequence Container that would play the Shield Start Sound before transitioning into the looping Random Container.

Like the thrusters, I needed both a Start and Stop Event. In my ShieldStrength method I used an if statement to check if the strength was above or equal to 1, as therefore the shield was active. If so, the Start Event would be posted.

Again this resulted in a layering of multiple sounds as the shield strength increased. I could call the Stop Event in every case of the switch statement, but for convenience, I simply called it at the start of the Shield Strength method, so every time the strength level is adjusted, the loop fades, either to a stop, or into a new Start Event. I quite like the idea of the Shield Start Sound playing each time the strength increases, as it gives off the idea of the shield charging up again.


Space Shooter Challenge: Shield Strength was originally published in Level Up Coding on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Level Up Coding - Medium and was authored by Calum Slee


Print Share Comment Cite Upload Translate Updates
APA

Calum Slee | Sciencx (2021-05-25T12:45:51+00:00) Space Shooter Challenge: Shield Strength. Retrieved from https://www.scien.cx/2021/05/25/space-shooter-challenge-shield-strength/

MLA
" » Space Shooter Challenge: Shield Strength." Calum Slee | Sciencx - Tuesday May 25, 2021, https://www.scien.cx/2021/05/25/space-shooter-challenge-shield-strength/
HARVARD
Calum Slee | Sciencx Tuesday May 25, 2021 » Space Shooter Challenge: Shield Strength., viewed ,<https://www.scien.cx/2021/05/25/space-shooter-challenge-shield-strength/>
VANCOUVER
Calum Slee | Sciencx - » Space Shooter Challenge: Shield Strength. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/25/space-shooter-challenge-shield-strength/
CHICAGO
" » Space Shooter Challenge: Shield Strength." Calum Slee | Sciencx - Accessed . https://www.scien.cx/2021/05/25/space-shooter-challenge-shield-strength/
IEEE
" » Space Shooter Challenge: Shield Strength." Calum Slee | Sciencx [Online]. Available: https://www.scien.cx/2021/05/25/space-shooter-challenge-shield-strength/. [Accessed: ]
rf:citation
» Space Shooter Challenge: Shield Strength | Calum Slee | Sciencx | https://www.scien.cx/2021/05/25/space-shooter-challenge-shield-strength/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.