Charas-Project

Game Creation => Requests => Tutorials => Topic started by: Koopapooper on May 29, 2007, 11:21:29 AM

Title: How do I make a Health Bar?
Post by: Koopapooper on May 29, 2007, 11:21:29 AM
I have made a custom Battle..but I dont have a bar of health or MP
so..Please tell me how to do this .

DONT REPLY UNLESS ITS ADVICE PLEASE.
Title:
Post by: DragonBlaze on May 30, 2007, 02:42:30 AM
Ok, how many pictures do you have for the bar? Well lets say you have 20 (if you don't, just replace 20 with the number you have).

First off, set a variable to the current hp, lets call it [hp percent]. Multiply it by 19 (or one less than the number of pictures you have 20-1 = 19), then divide it by the hero's total hp. This will make [hp percent] equal to the percent of the heros life life.

Now make 20 conditional branches. One for if [hp percent = 0] (show the empty bar), one for if its one (show the almost empty bar, and keep going up from there. In the end, it should look like this.

set [hp percent] = current hp
multiply [hp percent] by 19
divide [hp percent] by total hp

if [hp percent] less than or equal to 0
- show picture, empty bar
if [hp percent] = 1
- show picture, almost empty bar

...

if [hp percent] = 19
-show full bar

The reason you have to do it one less than the number of pictures you have is because you need to count 0 as a number. so even though you're only going up to 19, you're counting 0 too, and 0 + 1-19 = 20 numbers.
Title:
Post by: danielturipa on June 18, 2007, 02:14:41 AM
First Off. Open The DataBase.
Go Through Common Event's
Now Open Up The Event Commands,
Now Look For The Conditional Branch
and go to page 2 and click on heroFirst Off.
And Now Hero Hp At Least Write How Much You want.
And Make It A Parallel or a Call
If Its A Call You Can Recieve the Hp Bar Through The Game.

I Have 1500hp and the monsters take 100 damage or less
and You Put your Hp into groups Of 100's For Each Picture.
And You Might Want 1 Picture For Each 100hp
Heres And Example

Quote
Originally posted by danielturipa

<>Branch if ???Hp is 1500 or more
  <>Show Picture:1Hp Bar15.(117,27)
  <>
:Else Handler
  <>Branch if ???Hp is 1400 or more
    <>Show Picture:1Hp Bar14.(117,27)
    <>
:Else Handler
  <>
 :End
 <>
 :End




And Now Put Them All Into Groups
I Could Give You A Link to My Project And Steal My Ideas.
BUT! If You Do Find Out How To Use This
You Can Also Use Them For You Facesets To.
And Mp Bar And Hp Bar.

Well I Hoped This Helped
Title:
Post by: DragonBlaze on June 18, 2007, 04:23:47 AM
Thats not a very good way of doing it, cuz you have that script designed for a specific hp amount, and thus have to make a seperate script for each level. A better way to do it is to base it off of percentages.
Title:
Post by: danielturipa on June 19, 2007, 01:15:33 AM
well im still learning how to code my own stuff.
and i reckon this is a good hp bar if its through out
the whole game.