Posted: 15th Mar 2014 11:34
As a first draft, it is at least working - but some optimizations are needed. For example it would be possible to generate a series of images from this and output as animated sprite.. that would immensely increase performance (I think).

Anyway, maybe it will be useful to someone.

+ Code Snippet
Rem LW - Initalize
Set Window On
Set Display Mode 640, 480, 32
Set Window Position (Desktop Width()/2)-(Screen Width()/2), (Desktop Height()/2)-(Screen Height()/2)
Sync On
Sync Rate 0

Rem LW - add a cooldown
Type tCooldown
    MaxTime As Integer
    CurTime As Integer
    Start   As Integer
EndType

MyCooldown As tCooldown
    MyCooldown.MaxTime = 15



Do
    Rem LW - Empty screen
    CLS 0
    
    Rem LW - press SPACE to initialize cooldown
    If SpaceKey()=1 Then MyCooldown.Start = Timer()
    
    Rem LW - handle cooldown
    If MyCooldown.Start   > 0 Then MyCooldown.CurTime = MyCooldown.MaxTime - ( (TIMER()-MyCooldown.Start) /1000 )
    If MyCooldown.CurTime < 1 Then MyCooldown.Start = 0
    
    Rem LW - Draw the box
    drawCircle( 150, 150, 30, RGB(255,255,255), MyCooldown.MaxTime, MyCooldown.CurTime )

    Rem LW - Debug
    Print "Press SPACE to initiate cooldown"
    Print "Remaining time: ", MyCooldown.CurTime
    Print "Cooldown Active: ", (MyCooldown.Start > 0)
Sync
Loop


Rem LW - Function to draw circle depeding on cooldown
Function drawCircle( xPos As Integer, yPos As Integer, Dia As Integer, Color As Dword, MaxCD As Float, CurCD As Float )
        Local aBegin As Float
        Local aFinis As Float
        
        aBegin = -180.0
        aFinis = ((CurCD/MaxCD) * 360.0) - 180
        
        INK Color, 0
        
        Lock Pixels
        
            For x = 1 To DIA
                For y = 1 To DIA
                    If SQRT((x-DIA/2)*(x-DIA/2) + (y-DIA/2)*(y-DIA/2)) < DIA/2
                        angle# = Atanfull( x-DIA/2, y-DIA/2 )
                        If angle# > aBegin && angle# <= aFinis
                            DOT xPos+x, yPos+y, Color
                        EndIf
                    EndIf
                Next y
            Next x
        Unlock Pixels
EndFunction
Posted: 15th Mar 2014 12:50
Here is same thing but using animated sprite. On my pc that is a 2x performance gain (1500fps -> 3200fps)

+ Code Snippet
Rem LW - Initalize
Set Window On
Set Display Mode 640, 480, 32
Set Window Position (Desktop Width()/2)-(Screen Width()/2), (Desktop Height()/2)-(Screen Height()/2)
Sync On
Sync Rate 0

Rem LW - add a cooldown
Type tCooldown
    MaxTime As Integer
    CurTime As Integer
    Start   As Integer
EndType

MyCooldown As tCooldown
    MyCooldown.MaxTime = 6


drawAniCooldown()


Do
    Rem LW - Empty screen
    CLS 0
    
    Rem LW - press SPACE to initialize cooldown
    If SpaceKey()=1 Then MyCooldown.Start = Timer()
    
    Rem LW - handle cooldown
    If MyCooldown.Start   > 0 Then MyCooldown.CurTime = MyCooldown.MaxTime - ( (TIMER()-MyCooldown.Start) /1000 )
    If MyCooldown.CurTime < 1 Then MyCooldown.Start = 0
    
    Rem LW - Draw the box
    If MyCooldown.CurTime > 0
        Show Sprite cooldown_animation_img
        Sprite cooldown_animation_img, 100, 100, cooldown_animation_img
        Play Sprite cooldown_animation_img, 1, 64, (MyCooldown.MaxTime*64)/4
    Else
        Hide Sprite cooldown_animation_img
        Set Sprite Frame cooldown_animation_img, 1
    EndIf

    Rem LW - Debug
    Print "Press SPACE to initiate cooldown"
    Print "Remaining time: ", MyCooldown.CurTime
    Print "Cooldown Active: ", (MyCooldown.Start > 0)
Sync
Loop

Rem LW - Function that generates a series of images and create animated sprite from it
Function drawAniCooldown()
        Global cooldown_animation_img As Integer
        detail = 64
        Dim ani( detail )
        For x = 1 To detail
            CLS 0
            x1 = detail-x
            drawCircle( 0, 0, 64, RGB(255,255,255), detail, x1 )
            img = freeIMG()
            FASTSYNC
            Get Image img, 16, 16, 48, 48
            ani(x) = img
        Next x
        size = detail*32
        Create Bitmap 1, size, 32
        Set Current Bitmap 1
        For x = 1 To detail
            Paste Image ani(x), x*32, 0
            Delete Image ani(x)
        Next x
        SYNC
        cooldown_animation_img = FreeIMG()
        Get Image cooldown_animation_img, 0, 0, size, 32
        Set Current Bitmap 0
        Delete Bitmap 1
        Save Image get dir$()+"/myimg.bmp", cooldown_animation_img
        Delete Image cooldown_animation_img
        Create Animated Sprite cooldown_animation_img, get dir$()+"/myimg.bmp", detail, 1, cooldown_animation_img
        Delete File get dir$()+"/myimg.bmp"
        Undim ani()
EndFunction
Function freeIMG() : Repeat : Inc returnVal, 1 : Until Image Exist(returnVal) =0
EndFunction returnVal

Rem LW - Function to draw circle depeding on cooldown
Function drawCircle( xPos As Integer, yPos As Integer, Dia As Integer, Color As Dword, MaxCD As Float, CurCD As Float )
        Local aBegin As Float
        Local aFinis As Float
        
        aBegin = -180.0
        aFinis = ((CurCD/MaxCD) * 360.0) - 180
        
        INK Color, 0
        
        Lock Pixels
            For x = 1 To DIA
                For y = 1 To DIA
                    If SQRT((x-DIA/2)*(x-DIA/2) + (y-DIA/2)*(y-DIA/2)) < DIA/2
                        angle# = Atanfull( x-DIA/2, y-DIA/2 )
                        If angle# > aBegin && angle# <= aFinis
                            DOT xPos+x, yPos+y, Color
                        EndIf
                    EndIf
                Next y
            Next x
        Unlock Pixels
EndFunction


Sadly I did not keep in mind a higher frame count than 64 frames. So were you to change the frames on animations to, let's say 32 frames, then you need to change calculations for time offset yourself.