Power up, Moonshine

This past week has been quite busy as the beta is approaching!

One of the things I have done this past week is writing the code for some of our power-ups and implementing them into our game. The power-up I will discuss in this post is our Moonshine ability.

The idea behind the moonshine power-up is that it should slow down everything in the game, including the player. The player’s movement speed however shouldn’t get slowed down as much as everything else gets. In order to achieve this I created a class for the moonshine power-up,  which holds information about the duration for which the power-up should last and whether or not it is activated. The player class then activates the power-up, and in our battlestates update function we check if the power-up is active, and if it is, we set our deltatime to be half of itself for the duration of the power-up. This makes everything in our game move half as fast as intended, including the player.

In order to allow the player a higher movement speed in relation to everything else in the game while moonshine is active we have a second check for whether moonshine is active in the update function of our battlestate, if moonshine is active this check sets the deltatime of our player’s update function to be deltatime times 1.5, thus allowing the player’s movement speed to update at a higher frequency than everything else.

Moonshine

The numbers for the moonshine power-up; the deltatime for the player when it’s active and the duration of the power-up (currently set to be 5 seconds) came to be through play testing and will probably be tweaked as we move closer to the beta.

The reason as to why I chose to manipulate the deltatime with the moonshine power-up instead of manipulating the speed variables of the enemies and the projectiles is very simple. Our deltatime is easily accessible and manipulated from our battlestate while all enemies and projectiles have their own speed settings in their respective classes. Trying to manipulate those settings would require quite a bit of cumbersome reworking of our code, and therefore wasn’t even considered when I designed the power-up.

All in all I must say that I am satisfied with both how the power-up works and how it feels to use it in the game, it really gives off a sort of Matrix-bullet-dodging feeling.

See you next week, after the beta! 🙂

About Erik Nilsson

2015 Programming