Blog week 4 – Smart code? Powerup that influence the speed

a9398e8068666b2ec1e28ccae2a679f9
Hello!
Since having the game’s looser or win condition being dependent of how long you take on completing the level, we needed something that would speed up or slow down the scrolling entities depending on what would happen in the game. Turns out to be harder that i thought, maybe I am just over thinking it and making it harder than it is.

However! I started to create the whole power up giving it the proper functions and variables, nothing to majorly fancy. I got it to spawn and behave like the other power ups, so now it was only the functioning of the power up left. I needed something that could change the speed of every scrolling entity in the program, or well that was how far I had thought trough before hand. So I created a variable wich would control the speed, so when I activated the power up it would change that to a higher value, and after a while it would change it back to the original value.

Alright got that covered, now I only needed to make every active object adapt to this speed, so i created a loop for each of the different entities and set so their scrolling speed to what I would set the value to from the power up. Easy enough, so I tested it. Worked out great until i saw what happened when a new entity would spawn, it was as fast as if I would not have a power activated, it was easily fixed by just sending in the extra speed they would have before spawning it in.

Alright, now we have a working speed up system with smart code wich could change the speed with the power up. Now I needed to create something that would slow down the game, like mud! Same story short, i created the class and so forth. So i spawned in the mud and when the mud intersected the player’s hit box it would slow down. This needed its own variable because I can not set the variable to be minus something since then everything would fly away in rocket speed. So i just had to send in the other variable with the first when im setting the speed of every entity.

Either way, if the player would intersect with the mud it will slow down, else it would not. Since it checks every mud tile I can’t have it like this, so I needed something that could check if it still is intersecting the other time around, so I gave the mud class its own bool if it is slowing or not. So after the first collision test I made another that would check the first tile that would have the bool set to true and checked if the player still where colliding with the player, if it did slowed would still be true, otherwise it would turn it off making it a functioning way of controlling speed.

Blog week 4 – Smart code? Powerup that influence the speed

En reaktion på ”Blog week 4 – Smart code? Powerup that influence the speed

  1. Hi Christoffer

    First of all i just want to say that i realy enjoyed your watching your groups presentation of your game yesterday. It looked realy cool especially your boss or what you want to call it with its gigant fists bashing together. I think you got a really good concept going and just keep on doing what you do.

    Anyways when i read your blog post on what you made and how you made it i got some mixed feelings and thaughts. First of all you explained it in a overall good way so that i could folow you on your thaughts and ideas of how you solved the task. You wrote about both the powerup and the mud parts of the track but i did not quite understand if they have some sort of connection to one another or if they just were two different things that you wanted to mention.

    And second of all you said that since the win / lose condition depended on your time completing the track you chose to slow the enemies down but i wonder if that realy benefit the player in the best way. Surely it can but im just thinking if it wouldnt give the player a better boost if you increased the avatar speed and maybe just slowing the enmies attack down. My thoughts with that is that it would give the player a lead against the time since your running down the track at a faster pase.

    Best regards Håkan

    Gilla

Lämna en kommentar