Circular Progress Bar


Tweet monkey-x code-archives miscellaneous
(Posted 9 months ago) RonTek

How To Make Circle Progress Bar

Author: SLotman

Blitz3D BlitzMax Monkey-X Circular Progress Bar

Import mojo

Class Game Extends App
    Field angle:Float

    Method OnCreate()
        SetUpdateRate 60
        angle = 0
    End Method

    Method OnRender()
        SetBlend AlphaBlend
        SetColor 0,64,255
        DrawCircle 100,100,53
        SetColor 0,0,128
        DrawCircle 100,100,51

        SetColor 0,0,255
        If angle > 360 Then angle=360
        For Local a:Float = 0 To angle Step .5
            DrawLine 100,100, 100 + 50*Cos(a-90), 100 + 50*Sin(a-90)
        Next

        SetColor 0,64,255
        DrawCircle 100,100,40
        SetColor 0,0,128
        DrawCircle 100,100,38

        Local str:String = String(Int((angle / 360.0) * 100)) + "%"
        SetColor 255,255,255
        DrawText str, 103 - (TextWidth(str)/2.0), 94

    End Method

    Method OnUpdate()
        angle += 1
    End Method
End Class

Function Main()
    New Game()
End Function

Reply To Topic (minimum 10 characters)

Please log in to reply