Progress off Power Ups, slow and steady.

Hello there!

Today I am going to talk about our game power ups, well we currently only have one so far in our game and it boosts the player’s speed during a short period of time. Our power-ups will consist of three major ones which can be combined into a various number of new ones depending on which two was combined. They will not activate automatically when you pick them up or as it is in our game when run over them, we have a bar that holds the power up until you activate it. And to clarify that you wont necessarily need to get two power-ups before you can use.

Power Up 1

This is how our power-ups are presented in our game as a piece of candy shaped as a skull to contribute to the festival. And we have a collision that checks if the player and the power ups collides and if there is a collision the power-up will be added the bad until the player activates it.

Power Up 2

This is our bar that temporary holds the power-up until the player presses the activation key (which we have set to the space bar). Now let me explain how this is coded.

Firstly I created an individual class for power-ups which only job at the moment is to hold a sprite that is drawn on to the level and has a reset functions for relocation the sprite to a new location after it has been activated. Secondly i added two new functions and a new variable for our player class and named them fittingly to GetBounsSpeed and SetBonusSpeed to clarify exactly what they are meant to do. In our player class we already have a function that handles our normal speed and added that it will now take the normal speed and add the function for GetBonusSpeed while the power-up is active and afterwards it will set the speed back to its normal values.

As there is a slight problem with getting the right values from our game state into each individual class such as the power-up class we have added one additional function to out game state class which handles and sets values for SetBonusSpeed and updates it. Although this is a temporary power-up and only last for a couple of seconds, currently i work with two bools (for those of you that do not know a bool checks to values, false or true and depending on which it is the program responds differently) to check if firstly we have added a power-up and a bool for when we press the space bar which sets the next bool to true and we have an active power-up.

While this bool is true the player will have a bonus speed and moves faster. In order to reset this and cancel this effect I implemented a variable with a set value at the start of the game which slowly drops until it reaches zero and if this variable returns the value zero the bool will return false. In  this order it will relocate the power-up unto the level and we will return to our normal speed,

This is all for this week and at the end of next I will be back presenting next weeks major artifact. So until then I wish you a good weekend.

//David

About David Eliasson

2014  Programming