Here's a quick example just using a box to draw the health bar. change the maxlength variable to change the bar length to whatever you want. This doesn't change the health value, just the size of the bar. Use the left right arrow keys to increase or decrease the health.
set display mode 800,600,32
sync on
sync rate 0
rem setup a maximum length for the bar
maxlength=screen width()/2
health#=127
do
cls
text 0,40,"Left right arrow keys to change health"
text 0,60,"Health = "+str$(int(health#))
inc health#,(rightkey()-leftkey())*.1
if health# < 0 then health#=0
if health# > 127 then health#=127
rem find percent
pc#=(health#/127.0)
rem create an empty space to draw the bar fill
ink rgb(255,255,255),0
box 0,0,maxlength,30
rem fill the bar based on the percentage of maxlength
ink rgb(255-(pc#*255),255*pc#,0),0
x2=maxlength*pc#
box 0,0,x2,30
sync
loop
If you want to use an image, create a sliver (maybe 1 pixel wide and however many high) of the image that you'd use as the "fill up". After getting the percentage, find the x2 of the maximum length based on the percentage of health. Create a loop from the start of the bar to the x2 value, and paste the sliver at each new x value building up the bar with your fill image. If the fill image changes or you want to use an image that isn't exactly the same for it's entire length, then store a copy of the complete fill bar on an offscreen bitmap and use copy bitmap to only copy the portion you need to screen 1 at the proper location:
copy bitmap offscreen,x1,y1,x2,y2,0,barx1,bary1,barx2,bary2
The position is found the same way as in the example.
Enjoy your day.