Don't forget delta-time!
In Ashley's tutorial Delta-time and framerate independence the problem of slower and faster computers are discussed.
If your game runs smoothly on your PC, great! But you have no idea how the game will run on other computers, tablets, etc. It makes just sense to integrate the delta-time variable in the health addition and subtraction actions, for example:
Run the game and you'll see a slower reduction of health. In many cases, the refresh rate of the monitors is at around 60[*]dt. So you can play with this value!
- Different monsters can harm the player's health differently.
- The medikit might just be a bit slower to "charge your battery", so this gives the user more adrenaline.. ;-)
And the best thing is, that the health bar will reduce or enlargen at the same speed, regardless of the users' computers.
Slowing down the player
This might be an idea for a more "realistic" player behavior. The less health points, the slower the player moves. What a tragedy, when suddenly monsters or other objects move faster than the player ;-)
In the 8Direction behavior of the Player, the Max speed parameter (currently at 200) is the one to be changed in the conditions where a monster or the medikit overlaps the player.
The formula to be used is: Max speed × Player.Health / 100 in order to change the max speed according to the player's health points. See the image below that there is the identical action included in both conditions we created for overlapping monster and medikit:
Player -> Set Max Speed -> 200Player.Health/100*
Another feature might be that the medikit will only give you power for x seconds. After that you can let the medikit vanish from the game or by adding an instance variable like a boolean value telling if the medikit has been used or not.
Check this one out: Kiyoshi's Making a fancy lifebar