something like this
SetWindowTitle( "Radial Progress Bar" )
SetWindowSize( 1024, 768 , 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 0, 0, 1, 1 ) // allow only landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
radialTextureID=CreateProgressRadial()
radialTextureID2=clearProgressRadial()
//SetImageTransparentColor(radialTextureID,0,0,0 )
//SetImageTransparentColor(radialTextureID2,0,0,0 )
CreateSprite(3,0) //this could use any image you have loaded that you wish to hide with your radial progress bar
SetSpriteSize(3,255,255)
SetSpriteColor(3,0,255,0,255)
CreateSprite(1,radialTextureID)
CreateSprite(2,radialTextureID2)
SetSpritePosition(1,0,0)
SetSpritePosition(2,0,0)
SetSpritePosition(3,0,0)
SetSpriteDepth(1,1)
SetSpriteDepth(2,2)
SetSpriteDepth(3,5)
SetClearColor(0,0,0)
angle#=0
repeat
angle#=angle#+1
if angle#<=360
SetSpriteAngle(1,angle#)
tempImg=progressRadial()
DeleteImage(radialTextureID2)
CopyImage(radialTextureID2,tempImg,0,0,255,255)
SetSpriteimage(2,radialTextureID2)
else
angle#=0
tempImg=clearProgressRadial()
DeleteImage(radialTextureID2)
CopyImage(radialTextureID2,tempImg,0,0,255,255)
SetSpriteimage(2,radialTextureID2)
endif
sync()
until GetRawKeyPressed(27)
function clearProgressRadial()
SetClearColor(0,0,0)
ClearScreen()
DrawBox (0,0,255,255,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
Render()
img = getimage(0,0,255,255)
SetImageTransparentColor(img,0,0,0 )
Swap()
endfunction img
function createProgressRadial()
SetClearColor(0,0,0)
ClearScreen()
//DrawBox (124,0,130,128,MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),1)
DrawBox (124,0,130,128,MakeColor(1,1,1),MakeColor(1,1,1),MakeColor(1,1,1),MakeColor(1,1,1),1)
Render()
img = getimage(0,0,255,255)
SetImageTransparentColor(img,0,0,0 )
Swap()
endfunction img
function progressRadial()
SetClearColor(0,0,0)
ClearScreen()
DrawSprite(1)
Render()
img = getimage(0,0,255,255)
//Swap()
endfunction img
I did similar to my above code and made a
speedometer easy enough to modify
SetWindowTitle( "Speedometer" )
SetWindowSize( 1024, 768 , 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 0, 0, 1, 1 ) // allow only landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
#constant speedoTextureID =3
#constant speedoNeedleTextureID =4
CreateSpeedoTexture(speedoTextureID)
CreateSprite(1,speedoTextureID)
SetSpritePosition(1,10,768-GetSpriteHeight(1))
CreateSpeedoNeedle(speedoNeedleTextureID)
CreateSprite(2,speedoNeedleTextureID)
SetSpritePosition(2,10,768-GetSpriteHeight(2))
angle#=0
repeat
angle#=angle#+1
SetSpriteAngle(2,angle#)
sync()
until GetRawKeyPressed(27)
function CreateSpeedoTexture(imgId as integer)
SetClearColor(0,0,0)
ClearScreen()
text1=createText("10"):SetTextSize(text1,20):SetTextPosition(text1,15,167):DrawText(text1)
text2=createText("20"):SetTextSize(text2,20):SetTextPosition(text2,0,130):DrawText(text2)
text3=createText("30"):SetTextSize(text3,20):SetTextPosition(text3,1,87):DrawText(text3)
text4=createText("40"):SetTextSize(text4,20):SetTextPosition(text4,18,46):DrawText(text4)
text5=createText("50"):SetTextSize(text5,20):SetTextPosition(text5,50,17):DrawText(text5)
text6=createText("60"):SetTextSize(text6,20):SetTextPosition(text6,90,1):DrawText(text6)
text7=createText("70"):SetTextSize(text7,20):SetTextPosition(text7,134,1):DrawText(text7)
text8=createText("80"):SetTextSize(text8,20):SetTextPosition(text8,177,17):DrawText(text8)
text9=createText("90"):SetTextSize(text9,20):SetTextPosition(text9,209,46):DrawText(text9)
text10=createText("100"):SetTextSize(text10,20):SetTextPosition(text10,226,87):DrawText(text10)
text11=createText("110"):SetTextSize(text11,20):SetTextPosition(text11,228,130):DrawText(text11)
text12=createText("120"):SetTextSize(text12,20):SetTextPosition(text12,220,167):DrawText(text12)
Render()
//img = getimage(0,0,255,255)
getimage(ImgId,0,0,255,255)
Swap()
DeleteText(text1):DeleteText(text2):DeleteText(text3):DeleteText(text4):DeleteText(text5):DeleteText(text6)
DeleteText(text7):DeleteText(text8):DeleteText(text9):DeleteText(text10):DeleteText(text11):DeleteText(text12)
endfunction //img
function CreateSpeedoNeedle(imgId as integer)
ClearScreen()
DrawLine( 125, 126, 58, 194,255,255,255 )
DrawLine( 126, 126, 59, 194,255,255,255 )
DrawLine( 127, 126, 60, 194,255,255,255 )
DrawEllipse(126,126,4,4,makecolor(255,255,255),makecolor(255,255,255),1)
Render()
//img = getimage(0,0,255,255)
getimage(ImgId,0,0,255,255)
Swap()
endfunction //img
but the easiest way to have a character progression bar for health might be is to use two sprites
one for the health of player in full health and another that is over the top that gradually removes
the green areas.
fubar