# Health Bar, HELP!

### » Thu Sep 22, 2011 7:56 pm

Ok, I'm a newbie in this program. My teacher said to me to make a game, but i dont know what to do from now on.

I mean, I made a health bar for my char, but, i put all that programming stuff in the right place as I saw in the tutorial.

The normal would be, the health bar full above my char and when I touch something who'd hurt him, he loses it, it's what I wanted do to, But my health bar starts tiny, and instead of lose, it gains health :(

I don't know what to do, i'm going crazy to hell, anyone can help me? =(

ps: sorry for my english xP

Here is it Game
B
2
G
1
Posts: 4
Reputation: 558

### » Thu Sep 22, 2011 8:35 pm

You are subtracting a negative one from health which is, infact adding one to health. Thats it! Just a double negative resulting in a positive.

I'm looking into health bars right now, I'm doing more of the zelda approach since thats how the original game was.

Learning this new (new to me!) program is pretty fun.

Have fun! Good Luck!!damainman692011-09-22 20:42:06
B
2
G
1
Posts: 16
Reputation: 482

### » Thu Sep 22, 2011 8:40 pm

Health bars are fun. I like to set a maximum health number and then use that for a percentage calculation. Something like:

Always set Healthbar Width to CurrentHealth / MaxHealth * MaxHealthBarWidth

Alternatively, what you have should work just fine. The problem with it "growing" is that it's not actually growing, it really is shrinking. You have your Private Variable 'Health' set to an initial value of 0, so when Lugia gets hit by the wave he ends up with negative health. In Construct, an image with a negative size value basically just sort of mirrors/flips itself.

Here's a "fixed" cap. Check it out!
http://dl.dropbox.com/u/20459682/lugia.cap

All I did was get rid of the initial "Always set Healthbar width to 65" due to redundancy since almost immediately after you set it to Lugia's 'Health'. Then I just set the value of Lugia's 'Health' to start at 70. Voila! Healthbar that shrinks as Lugia gets hit.
B
65
S
21
G
8
Posts: 305
Reputation: 9,156

### » Thu Sep 22, 2011 8:45 pm

Thank You folks for your support. I'll try the fixed one.

By the way, i'm a newbie in programming, it causes me a lot of headache, believe me =D
B
2
G
1
Posts: 4
Reputation: 558

### » Fri Sep 23, 2011 12:43 am

Forgot to say it worked well, thank you guys ^^
B
2
G
1
Posts: 4
Reputation: 558

### » Fri Sep 23, 2011 2:33 am

Good to hear!! Seeing a working result is always rewarding! Just made a clock/countdown til death timer for my demo. Crappy Arial font is the next thing to go :)

Have fun!
B
2
G
1
Posts: 16
Reputation: 482