This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-06-30 17:39:10

ScratchOS
Scratcher
Registered: 2012-03-20
Posts: 53

Health Bar help?

Hi I'm making a game which includes a health bar.

The health bar uses to variables, Health and Max. Health. With health being the health of player and Max. Health being the maximum healh.

Also, you can increase your maximum health with armour using this script.

forever
set(Max. health v) to ((Max. health)+(armour))
However, it when the armour value is greater than 0, the maximum health constancy increases. For example if armour is 4, the varible keeps rising by 4.

Please help! Thank you.

Offline

 

#2 2012-06-30 18:03:56

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Health Bar help?

It's doing that because it's always making the maxhealth variable equal to itself plus armour, I don't know the context but it'd probably be best to either have that run once whenever armour changes, or when the gf is clicked. Or you could always have a separate variable that is the sum of the two


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#3 2012-06-30 18:12:26

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Health Bar help?

Do this

set [totalHealth v] to <(maxHealth) + (armor)>


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

#4 2012-07-01 04:36:07

ScratchOS
Scratcher
Registered: 2012-03-20
Posts: 53

Re: Health Bar help?

Thank you!!

Offline

 

Board footer