Another way of doing this is to have a single sprite for the health bar and then scale it using the STRETCH SPRITE command as used in the demo below.
sync on
sync rate 60
`create a sprite for the health bar that will be 150 pixels long
`the length can be anything you want and can be an external file
create bitmap 1, screen width(), screen height()
set current bitmap 1
box 0,0,150,10
get image 1, 0,0,150,10
set current bitmap 0
`set some variables for the maximum health of the mob and the current health of the mob
`you can set the maximum health to whatever you want (the health bar will always be 150 units long at max health)
max_health = 173
current_health = max_health
`main loop
do
`controls for reducing the mobs current health and reseting it to maximum
if downkey() = 1 then dec current_health, 1
if current_health < 0 then current_health = 0
if spacekey() = 1 then current_health = max_health
`Calculate the x scale of the health bar, i.e. the percentage of the mob's current health expressed as a percentage of
`its maximum health
`Note : if your health variable are integers you will need to convert them to floats otherwise the scale_x#
`calculation will return a zero.
ch# = current_health
mh# = max_health
scale_x# = (ch# / mh#) * 100
`position the sprite at middle top of the screen and then scale the sprite
sprite 1, screen width()/2,10, 1
stretch sprite 1, scale_x#, 100
`the above will mean that the health bar will shrink from right to left
`if you offset the sprite by its length then the health bar will dimish from left to right
rem offset sprite 1, 150, 0 :`un comment this line to see
`if you offset the sprite by half its width it will shrink equally from left and right
rem offset sprite 1, 150/2, 0 :`un comment this line to see
`print some info to the screen so you know what's going on
set cursor 0,50
print "Press down key to reduce current health"
print "Press space to reset current health to the max health"
print
print "max_health : ", max_health
print "current_health : ", current_health
print "scale_x : ", scale_x#
sync
loop
In the demo I'm using the down key to reduce the "current_health" variable.
What you will need to do is give each mob (I had to look that up to see what it meant

) a "current_health" variable.
Then you will need to work out how the mob's health is reduced and this will depend on what type of game you are making. If you're firing bullets / arrows then you need to work out if the bullet / arrow has hit the mob (have a look at the SPRITE HIT and SPRITE COLLISION commands).
If it's more of a sword fighting / fisticuffs kind of game then you need to determine if the player is close enough to the mob when the player is pressing the attack buttom (what ever that button is).
Quote: "...increase when my character used potions"
You will need to have a "current_health" variable for the player but after than it's going to depend on what kind of game mechanics you want. For instance:
1) The player's health is immediately increased by 5 (for example) when the player moves onto a health potion bottle.
In this case, again you can use the SPRITE HIT or SPRITE COLLISION command to determine if the player has hit the potion bottle and increase the player's health if a collision has occured. The bit you will need to decide is does the bottle disapear once it has been used? If the player is at maximum health do you want to stop the potion being used so it is available for later?
2) The player picks up a potion, adds it to some kind if inventory (this doesn't have to be a complicated inventory system)and then can use the potion whenever they want.
Use the same process as the first example to detect if the potion has been hit and then picked up. You could then have a variable called "number_of_health_potions" that is increased by 1 when the player collects a potion. If "number_of_health_potions" is greater than zero then the player is able to press a key (lets so P for potion) which will then increase their health. You will then need to decrease "number_of_health_potions" by 1 as one health potion has been used.
Anyway, I didn't mean for this to be so long and rambling but I hope it helps.