I am working on a PC game and am attempting to do some dynamic math to get a players health level for each of X health icons out of a total starting health.

Lets say:

StartingHealth = 150

PlayerHealth = StartingHealth (Dyanmic, decrements by a number based on enemy strength)

HealthIconCount = 6

4 health increments per / HealthIcon (100, 75, 50, 25)

I need to, based on player's current health, decrement each of the 6 health icons, sequentially based on if they have reached 0% themselves, between their 4 increment states in order.

So if a players health starts at 150 and is currently at 125, what state should the first of 6 health icons with 4 increments be set to and is there a simple/elegant equation to solve this? 100%, 75%, 50% or 25%? Because the other 5 icons are still 100...

Does this make sense?

Im lost... as usual

Lets say:

StartingHealth = 150

PlayerHealth = StartingHealth (Dyanmic, decrements by a number based on enemy strength)

HealthIconCount = 6

4 health increments per / HealthIcon (100, 75, 50, 25)

I need to, based on player's current health, decrement each of the 6 health icons, sequentially based on if they have reached 0% themselves, between their 4 increment states in order.

So if a players health starts at 150 and is currently at 125, what state should the first of 6 health icons with 4 increments be set to and is there a simple/elegant equation to solve this? 100%, 75%, 50% or 25%? Because the other 5 icons are still 100...

Does this make sense?

Im lost... as usual

Last edited: