I am working on a game WPF/C#.
So I have 2 text boxes. HP and Currenthp. I also have 10 images of hearts, each image the heart starts to break till it is dead.
HP.text is the max amount of hit points a character has.
Currenthp.text is the current amount of Hit points a character has. With a +/- button to alter the value.
What I want to do is compare HP and Current HP by %.
So if you have 100 HP and are at 90 currenthp, image 1 will show. If you are at 80 currenthp image 2 will show. I know I will need an IF or switch statement, but trying to figure out how to do the math in %. 10% per case. (HP will not always be 100.)
EDIT* So I am looking for current/total = percentage but not sure how to do this with a switch or if statement.
Thanks in advance!
-Abe
So I have 2 text boxes. HP and Currenthp. I also have 10 images of hearts, each image the heart starts to break till it is dead.
HP.text is the max amount of hit points a character has.
Currenthp.text is the current amount of Hit points a character has. With a +/- button to alter the value.
What I want to do is compare HP and Current HP by %.
So if you have 100 HP and are at 90 currenthp, image 1 will show. If you are at 80 currenthp image 2 will show. I know I will need an IF or switch statement, but trying to figure out how to do the math in %. 10% per case. (HP will not always be 100.)
EDIT* So I am looking for current/total = percentage but not sure how to do this with a switch or if statement.
Thanks in advance!
-Abe
Last edited: