Health bar growing too long!

JCFordJCFord Member Posts: 785
edited November -1 in Working with GS (Mac)
Following QuantumSheeps's Video, I have made a nice health bar that gradually shrinks over time, my player can then collects health point which increase his health back up.

Is all working nicely, the health bar drops over time and when my player collects health points it increases the health bar, but the problem is if my player collects a lot of health bar points the bar grows longer and longer going off screen, I need a way to cap it at 100% so it can't grown anymore.

Been playing around with different attributes such as
IF game.energy > 100 then
change game.energy to 100

But it doesn't appear to work?

Any ideas or advice?

Comments

  • JCFordJCFord Member Posts: 785
    Thank you very very much Tshirtbooth!
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    can anyone explain what the min does in this example? I would have thought you should a have a rule that says when player collides with health token AND health is < 100

    change game.health to game.health+20

    min does all that in one step?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    @scitunes: yes! MIN is another great math function! I'll try to do a demo when I get a chance.

    Basically, you give the MIN function two choices, and it picks the smallest one.

    It's an easy way to set limits on things - the second choice is usually the max limit of the attribute you're tracking.

    MAX is the opposite, and can be used to set minimums on attributes.

    Essentially it does what you just said, but eliminates that extra rule.

    Joe
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Wow this "min" thing really works!

    My health bar was growing longer than Pinochio's nose, lol!

    Just thought I'd mention it as it may be of use to others :-)
  • debugdesigndebugdesign Member Posts: 886
    That's a great tip, I had the same issue; so instead I created 10 images of the health bar getting smaller, changing color etc...

    Then I made the attribute 'health' an integer and and when health = 5 (for example) it would change the image to health5.png

    This seemed to work for me but that 'min' thing could be useful
Sign In or Register to comment.