LithiumLi Posted March 8, 2009 Share Posted March 8, 2009 (edited) 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 March 8, 2009 by LithiumLi Link to comment Share on other sites More sharing options...
Achilles Posted March 9, 2009 Share Posted March 9, 2009 $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] Link to comment Share on other sites More sharing options...
LithiumLi Posted March 9, 2009 Author Share Posted March 9, 2009 $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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now