# Stupid Question

## Recommended Posts

I can't think of how to do this because my mind is wandering off once again well trying to code.

My game is a fighting based game with both a progress bar and text that represents the health.

I know that if my character has 400 health and I do 200 damage that would be 50% that I would take away from the progress bar and since a progress bar is made up of 100% I would than have 50% of my bar left over.

but what if I have something like 1337 health and I do 28 damage what would the percentage be that I would take away from the progress bar although I don't think a bar would be taken away from the progress bar since 28 damage subtract 1337 health is very little but if I did 500 damage than a few bars would of course disappear.

I hope someone is good at math here and knows what I am talking about a good example would be Diablo 2 or World of Warcraft they show the health in both text and progress bars/orbs.

I think once I see the math involved I should understand how it works but just in case can you add how you did it and were able to figure it out.

Edited by LithiumLi

##### Share on other sites

```\$totalHealth = 400

\$damageDealt = 200

Msgbox(0, 'Result', 'Set progress bar to: ' & ((\$totalHealth - \$damageDealt) / \$totalHealth) * 100)

\$totalHealth = 1337

\$damageDealt = 28

Msgbox(0, 'Result', 'Set progress bar to: ' & ((\$totalHealth - \$damageDealt) / \$totalHealth) * 100)```

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

##### Share on other sites

```\$totalHealth = 400

\$damageDealt = 200

Msgbox(0, 'Result', 'Set progress bar to: ' & ((\$totalHealth - \$damageDealt) / \$totalHealth) * 100)

\$totalHealth = 1337

\$damageDealt = 28

Msgbox(0, 'Result', 'Set progress bar to: ' & ((\$totalHealth - \$damageDealt) / \$totalHealth) * 100)```
Thanks very much didn't know it was that simple had a brain fart and couldn't think of how it was done.

## Create an account

Register a new account

×

• Wiki

• Back

• Git