# Gw Temp

## Tutorial - 'HP/MP bars' by [_JuN_]

An item about RPGMaker 2000 posted on

### Blurb

How to create a HP and MP bars for your game

### Body

This is my first tut, and, before everything, I’d like to say that this tutorial is for everybody who has ever tried to make a CMS and couldn’t figure out how to do a bar that changes according to the hero’s HP,or followed a tutorial that didn’t teach how to this stuff.
(Actually, I’ve never read one that explained it, and that’s why I spent more than 6 hours figuring it out…)
Before opening RM2k, go to PSP, MsPaint, Idraw, whatever, and draw the full bar.
I recommend doing a bar with a width that is a multiple of ten, like 40,50,60,70,80 pixels,
you decide. The bar height doesn’t matter. Mine is 40x2 pixels. Now, get a piece of paper and open the PC calculator. Write down the width of your bar(in pixels)and, in the calculator, find the value of 90% of the number. For example: 90% of 40 pixels is 36.Write down the value. Repeat the process for 80,70 until 10%,writing the values in the paper. Now, back to the image editor, draw the bar filled until 90%,mine looks like this:

Then you draw it filled until 80%,70% until 0%,that means the empty bar.
When you are done with the graphics, it’s time to do the coding-don’t worry, it won’t take 6 hours… =^).Open your project and go to “RAW Material Editor”. Import to the picture dir your graphics of the Hp bar. Now, create a common event, parallel process, activated by the switch that starts your battle. Name it something like HP bar (dăăă…).Create a variable called “HeroHP” and set it as the hero’s HP. Create another variable, called “HeroMaxHP”, and set as your hero max HP. Then go to change variable ,choose “HeroMaxHP”, and divide it by 10. Now divide “HeroHP” by the “HeroMaxHP” variable. Create another variable called “BarPercentage”, set, var “HeroHP” value.It should look like this:

<>Variable Ch:[xxxx:HeroHP]Set, hero1 HP
<>Variable Ch:[xxxx:HeroMaxHP]Set, hero1 Max HP
<>Variable Ch:[xxxx:HeroMaxHP] / 10
<>Variable Ch:[xxxx:HeroHP] / , Var.[xxxx](HeroMaxHP) val.
<>Variable Ch:[xxxx:BarPercentage]Set, Var.[xxxx](HeroHP) val.

After this you have to start a FORKConditions sequence that check’s if the hero’s current HP corresponds to 90-100%, 80-90%,70-80% and so on, of the max HP:

<>FORK Optn: Varbl[xxx:Bar Percentage]-9 abov
<>FORK Optn: Varbl[xxx:Bar Percentage]-10 less
<>Show Picture : 1,HP 90%,(x,y)-the place where the bar is shown-
<>
:END Case
<>
:END Case
<>FORK Optn: Varbl[xxx:Bar Percentage]-8 abov
<>FORK Optn: Varbl[xxx:Bar Percentage]-9 less
<>Show Picture : 1,HP 80%,(x,y)

Keep doing this until 0-1. Here you can have a different colored bar to show danger, like yellow instead of red. The last should be If var. BarPercentage=10,show picture HP100%.This is the default, and you can turn it into a MP display bar as well.If you want an even more accurated you can draw bars at 95,85,75…5% and, the beginning of the var operations add something like this:

<>Variable Ch:[xxxx:HeroMaxHP] / 10
<>Variable Ch:[xxxx:HeroHP] x10
<>Variable Ch:[xxxx:HeroHP] / , Var[xxxx](HeroMaxHP) val.

And in the FORK Optn, put 95-100%,90-95%,etc. This code is totally original, so you can use it in your game and it’d be very good if you put my name on the credits,[_JuN_], hehe. Wait for my next tut: how to make an ATB(FF time bar).