Charas-Project

Game Creation => Requests => RPG Maker Programming => Topic started by: SilverBlade on October 01, 2006, 08:11:27 AM

Title: Variables to procentages
Post by: SilverBlade on October 01, 2006, 08:11:27 AM
I'm making a 'HP-Bar system': a bar that shows your HP is in the left corner of the screen.
The only problem is the programming, I could make a branch for every sort of HP he could get, example: Branch if his total HP is 30=that would be a full bar, but then I have to do it also for when he's 35, 40, 45...and so on!
So I was wondering, can't I set his Total HP to 100%. This way it would be way more accurate and easier. I just can't figure how to do it(example:

Branch if variable HP equals to 60%
   Show picture 1: HP Bar 60%...


Do you know what I mean? Please help me!
Title:
Post by: WarxePB on October 01, 2006, 02:09:50 PM
To get a percentage from HP, first use a Variable Operation to get the hero's current HP. Then, use another Variable Operation to multiply it by 100, and one more that divides it by the hero's max HP. So it would look like:
<>Variable Operation: Var[0001] Set, Hero HP
<>Variable Operation: Var[0001] *, 100
<>Variable Operation: Var[0001] /, Hero Max HP

Then, as you said, you need branches for every possible position on the bar (1-100).
Title:
Post by: DragonBlaze on October 01, 2006, 03:22:29 PM
Yeah, do what Warxe said.

If you know how many pictures you hae to display it, it'll be easier to just multiply the variable be 1 less than the amount of pictures you have instead of 100.

So lets say you have 21 pictures, you would multiply by 20.

Then you can set it up like:
if var = 0, show empty par
if var = 1, show next bar
...
If var = 20, show full bar.