Jump to content


Photo

Drawing a healthbar for an enemy


  • Please log in to reply
2 replies to this topic

#1 trivettz

trivettz

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

Posted 03 March 2012 - 12:47 AM

I searched the forums and found out how to create a variable indicating an enemy's health, but because of my remedial grasp of the coding language, I wasn't able to understand the drawing of a gradient above the instance of the enemy. If someone would give me a deeply explanatory how-to of drawing this, I would be greatly appreciative.
  • 0

#2 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • Retired Staff
  • 9314 posts
  • Version:Unknown

Posted 03 March 2012 - 01:31 AM

You could do it manually with some math, but if you can't quite grasp that yet, you might want to just use the built-in draw_healthbar function that's part of GM:

draw_healthbar(x1, y1, x2, y2, amount, backcol, mincol, maxcol, direction, showback, showborder) With this function you can draw a healthbar (or any other bar that indicates some value, like e.g. the damage). The arguments x1, y1, x2 and y2 indicate the total area for the bar. amount indicates the percentage of the bar that must be filled (must lie between 0 and 100). backcol is the color of the background for the bar. mincol and maxcol indicate the color when the amount is 0 and 100 respectively. For an amount in between the color is interpolated. So you can easily make a bar that goes e.g. from green to red. The direction is the direction in which the bar is drawn. 0 indicates that the bar is anchored at the left, 1 at the right, 2 at the top and 3 at the bottom. Finally showback indicates whether a background box must be shown and showborder indicated whether the box and bar should have a black border line.


-IMP
  • 1

#3 trivettz

trivettz

    GMC Member

  • New Member
  • 17 posts
  • Version:GM8

Posted 03 March 2012 - 01:35 AM

Thank you so much, with this, I am going to make a boss character for my final level and upon his destruction I will end the game.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users