I've been using the follwing code which I believe I found here for a health bar. The problem I'm having is that the bar goes from right(full life) to left(no life). I've been trying to get it work the other way, left to right, but all my attempts have failed. Can anyone help me solve this badboy?
here's the code-
Full=LoadImage("Life_Bar.png")
ResizeImage Full,247,13
Empty=LoadImage("Life_Bar_2.png")
ResizeImage Empty,247,13
SetBuffer BackBuffer()
dn=1
Repeat
Cls
Text 1,1,"Health = "+n
n=n+dn
If n=100 Then dn=0-1
If n=0 Then dn=1
DoPowerBar(100,100,n,11,86,empty,full)
Flip
Delay 5
Until KeyDown(1)
Function DoPowerBar(Xpos,Ypos,Percent_Filled,StartX,EndX,emptyimage,fullimage)
;X + Y Pos - where on screen you want the bar
;Percent Filled (0-100%)
;StartX - Where on the image you want 0% to be
;EndX - Where on the image you want the 100% to be
;Empty + Full image - the two images
DrawImage emptyimage,xpos,ypos
from=ImageBuffer(fullimage)
high=ImageHeight(fullimage)
If percent_filled<>0 Then wide=(((endx-startx)*Percent_Filled)/100)+StartX
If percent_Filled=0 Then wide=startX
CopyRect 0,0,wide,high,XPos,YPos,from,BackBuffer()
End Function
here's the code-
Full=LoadImage("Life_Bar.png")
ResizeImage Full,247,13
Empty=LoadImage("Life_Bar_2.png")
ResizeImage Empty,247,13
SetBuffer BackBuffer()
dn=1
Repeat
Cls
Text 1,1,"Health = "+n
n=n+dn
If n=100 Then dn=0-1
If n=0 Then dn=1
DoPowerBar(100,100,n,11,86,empty,full)
Flip
Delay 5
Until KeyDown(1)
Function DoPowerBar(Xpos,Ypos,Percent_Filled,StartX,EndX,emptyimage,fullimage)
;X + Y Pos - where on screen you want the bar
;Percent Filled (0-100%)
;StartX - Where on the image you want 0% to be
;EndX - Where on the image you want the 100% to be
;Empty + Full image - the two images
DrawImage emptyimage,xpos,ypos
from=ImageBuffer(fullimage)
high=ImageHeight(fullimage)
If percent_filled<>0 Then wide=(((endx-startx)*Percent_Filled)/100)+StartX
If percent_Filled=0 Then wide=startX
CopyRect 0,0,wide,high,XPos,YPos,from,BackBuffer()
End Function