Power up pick up

powerupmove

One of the things that I have done this week is that I have made it so that the power up icon, which some enemies drop when hit, moves from the position of the hit enemy towards the HUD when clicked. This icon will then sit next to the ‘Spacebar to launch’ on the HUD as can be seen on the image above (The yellow thing is the power up icon). It’s movement is done by using lerp (linear interpolation) on its x an y position. I have explained a bit about lerp before in a previous post. As we are using sf::view to control where you can see on the planet and the power up pic up is spawned from an enemy and then goes to the HUD, it first has to be converted from a screen position used by the HUD to the in-game coordinates used for the enemies.

I had some trouble where I was checking if a bool was set to true in the code, and I didn’t set it to true, but it looked in the debugger as if it was. I thankfully got it to work after some time. I hadn’t noticed that I had set Visual Studio as ‘Release’ and not ‘Debug’, so changing that made the debugger work much better.

A problem I had, which I think was related to the problem I had when I had the debugger problem, was that I had made a variable to store the time in so I could compare it with the current time to work as a timer, but it would get nonsensical values when I tried to assign it to the current time. I am suspecting that it might have been that the function for getting the time returned a number of the type float, while my variable was of the type double. I didn’t even try to see if using ‘static_cast()’ on the returned time would make it work, and instead went with how we have usually done timing; by having a variable that is increased by delta time each frame.

The power up icon will shrink in size if you take too much time without picking it up. The power up icon on the HUD will in a similar manner shrink and disappear when a new power up is picked up, as you can only have one power up at the time. I think we had said to have the power up icon grow a bit while it’s moving to the HUD, maybe using one sine wave would give a good result, but I haven’t done that yet.

About Linus Bjernhagen

2015 Programming