Making a health bar dynamic

beckbbeckb Member Posts: 16
I have a timer set to degenerate the health bar by set amount per second.
I'd like to make a key press stop the degeneration for 3 seconds, and to not have this conflict with other key presses with add health to the bar.

Thank you

Comments

  • SearleSamaSearleSama Member Posts: 108
    if LifedegenerateON = true
    every 1 second
    change att currentHealth = currentHealth - 1

    if key "1" is pressed
    change lifedegenerateON = false

    if lifedegenerateON = false
    after 3 seconds
    change lifedegenerateON = true

    this would not affect other changes to currentHealth att
  • beckbbeckb Member Posts: 16
    if LifedegenerateON = true
    every 1 second
    change att currentHealth = currentHealth - 1

    if key "1" is pressed
    change lifedegenerateON = false

    if lifedegenerateON = false
    after 3 seconds
    change lifedegenerateON = true

    this would not affect other changes to currentHealth att
    SearleSama thanks for your input on this post and my others, you're tremendously helpful. I hope you don't mind if I ask a few more questions as I am a newb and could use clarification.

    I'm assuming the "Lifedegenerate" is a game attribute that I should create? And if so, what type (integer, boolean, etc.). The reason I ask is because I tried naming the specific rule that does the health degeneration to "lifedegenerate" and trying use another rule to manipulate it, but it would show nothing when I typed it in.
  • beckbbeckb Member Posts: 16
    Also, how can I set it so that the game starts with the health degenerating automatically?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    In the example above, game.lifedegenerate has values of true/false, so it's a boolean.

    Just set the boolean to true (checked) when you create it. The rule above will start decreasing health each second as long as game.lifedegenerate is true.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • beckbbeckb Member Posts: 16
    In the example above, game.lifedegenerate has values of true/false, so it's a boolean.

    Just set the boolean to true (checked) when you create it. The rule above will start decreasing health each second as long as game.lifedegenerate is true.
    Thank you both that totally solved it for me. One more question - How can I make the life degenerate by a random amount per second (like an amount between 1 and 10). Thanks again!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    if LifedegenerateON = true
    every 1 second
    change att currentHealth = currentHealth - random(1,10)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.