Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Draw a HUD Bar for player variables

    Functions
    3
    4
    514
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Dave
      Dave Fuze Team last edited by Dave

      this is a function you could use to easily draw a bar for player/enemy health, stamina, mana etc. Very versatile, can be customised easily and features a colour shifting effect with interpolate() as it changes size.

      Initially this was a response to another user's request for some help, but the function is actually simple and useful enough that I think it might be valuable here!

      function drawBar(x, y, width, height, value, maxValue, colourEmpty, colourFull)
          w = width/maxValue * value
          t = w/width
          col = interpolate(ease_in_out, colourEmpty, colourFull, t)
          box(x, y, w, height, col, false)
      return void
      
      // Example usage (using some example variables 'health' and 'maxHealth'):
      drawBar(100, 100, 300, 50, health, maxHealth, red, lime)
      
      1 Reply Last reply Reply Quote 6
      • A
        AlexTheNewCoder last edited by

        Thanks, let you know if I failed jt

        1 Reply Last reply Reply Quote 0
        • waldron
          waldron F last edited by

          You mean I don't have to draw 100 tiles to display boss health ! 😉 Cheers will try later

          1 Reply Last reply Reply Quote 0
          • Dave
            Dave Fuze Team last edited by

            @AlexTheNewCoder Make sure to check out the more detailed reply I left for you on the original thread!

            https://fuzearena.com/forum/topic/1898/how-do-i-make-an-hud

            1 Reply Last reply Reply Quote 1
            • First post
              Last post