Jump to content
Sign in to follow this  
LithiumLi

Stupid Question

Recommended Posts

LithiumLi

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 this post


Link to post
Share on other sites
Achilles

$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 this post


Link to post
Share on other sites
LithiumLi

$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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.