Expanding healtbars

0 favourites
  • 4 posts
From the Asset Store
Fully animated twelve sided dice, top down wooden tray and dice throwing cup
  • Hey there!

    I am currently making a Tower defense game and with this i am creating enemies that has increasing health each wave. The formula goes CurrentWave*5 which means that on wave 1 they have 5 health, wave 2 10 health, wave 3 15 health and so on and so no. Problem is that i want to add healthbars on top of their little heads, and i since i want to accurately show the health that they have i have made the healthbars width to set after their current health. This of course makes their healthsbars insanely long after a few waves, covering the entire room at later waves.

    So my question is, do you have any ideas on how i could make a static expanding bar but still accurately show the health of my enemies? Or perhaps you have a better idea on how to show their health.

    Any tip is appreciated

    Thanks in advance!

  • Don't make them expand. If you want the player to know how much health they have, make them selectable and display it at an information panel or just generally show it somewhere.

    Dota 2 uses separators on the health bar that visually divide it into 250 health segments, but that makes only sense for big health bars. Sure you could add such separation, but I don't think it adds something to you game. Just give the player another way of finding out how much total health those guys have imo.

  • Its actually quite easy to do.

    For your enemies you add 2 variables:

    Max_health (Just hold the max health the enemy can have)

    Current_health (Enemy current health)

    Then you make a sprite to indicate the health bar. You can use whatever width you want.

    Width_of_enemy_health_bar_start_width

    have to be the same, so you can either add that as an variable to the healthbar it self, would probably be the best, or you can hardcode it or add it as a global whatever way you prefer doing it.

    Then use the following math to control it.

    Width_of_enemy_health_bar = int((Width_of_enemy_health_bar_start_width / Enemy_Max_health) * Enemy_current_health)

    So it looks like this:

    Width_of_enemy_healthbar = 100px

    Enemy max health = 20

    Enemy_current_health = 14

    Width_of_enemy_healthbar = int(100 / 20) * 14) = 70 px

    Width_of_enemy_healthbar = int(100 / 20) * 8) = 40 px

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I did about the same what nimos did, but added a red bar at max length below a green bar. As the green bar reduced, more of the red became visible :)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)