The start of a HUD

bloggimage3_5_2015This will weeks blog post will be about the way I programmed part of the HUD. This post will be concerning the life-bar of the avatar, and a bit of the rage system which is currently being improved.

The functionality for it was easy to program and no real complexity in the code was needed. Though some problems occurred while doing it, these problems occurred since I was tired while programming them. This post will mostly contain the problems that occurred while trying to implement the system.

The main problem was how I was going to make the life bar move with the screen. And even though I already had a mini-map in the HUD I did not think of just adding it into a new view.

I currently have three different views in the program. One is the view for the main screen where all the game play is showed. An other view is for the mini-map, this is a separate view from the life-bar since the mini-map view is scaled down and its origin is in the top left corner.

Therefore I had to make a separate view for the rest of the HUD.

To get the life-bar to change accordingly to the players health only a couple of checks on the players health is needed. Right now these checks are made each frame. Though I will make it so that these checks only are called once the player takes damage, or gets healed.

So if the players health is equal to a certain value the sprite will change accordingly.

I also started to implement a rage system which is supposed to increment each time an enemy is killed. This rage will be used to fire a projectile which pushes/knocks enemy units back towards the angle of which the projectiles direction is.

In addition if the rage-bar (which is not currently implemented) gets filled the players projectile will get changed to an offensive one for a set duration which makes it so that the players projectiles deals damage.

A problem with getting the rage system to work is that at first I made a new one in each enemy which resulted in mayhem. I had to do this since I was not aware of that it was the play state that was going to keep track if the enemies were alive or not. Before I had it so that each enemy was aware of its own health. This was a problem since I had to return values from the enemy when it died, and I was not able to get it to work.

So I changed it so that the test-state checked all the enemies health if they were not dead, and if their health is 0 or below 0 I set them to dead and add rage to the player.

An other problem that was the root cause of many other problems is that the player is not a separate class at the moment. I will probably change this after the beta, at this point and time I do not have the time to convert the amount of code for the player to a separate class.

Hopefully this blog post had some value in it, even though it was mostly about troubleshooting.

About Gabriel Ajuwa

2014  Programming