`Cursor Challenge
`thinkdigital
sync on : sync rate 200
hide mouse
randomize timer()
dim green(255)
for i = 1 to 255
    green(i) = rgb(0,255-i,0)
next i
dim red(255)
for i = 1 to 255
    red(i) = rgb(255-i,0,0)
next i
dim yellow(255)
for i = 1 to 255
    yellow(i) = rgb(255-i,255-i,0)
next i
 
TYPE PRTCLE
    X
    Y
    XDIR as float
    YDIR as float
    LIFE
    KIND AS STRING
ENDTYPE
 
dim spr(200) as PRTCLE
global sprayInProgress
out = 20
way = 1
do:cls
 
    `Draw Dots Circling   
 
    if way = 1
        ink green(1),0
    else
        ink yellow(1),0
    endif
       dx = mousex() + (sin(dotRot) * out)
       dy = mousey() + (cos(dotRot) * out)
       dx2 = mousex() + (sin(dotRot+180) * out)
       dy2 = mousey() + (cos(dotRot+180) * out)
    box dx,dy,dx+size,dy+size
    box dx2,dy2,dx2+size,dy2+size
       dotRot = wrapvalue(dotRot+3)
        for i = 1 to 80
            if way = 1
                ink green(i*3),0
            else
                ink yellow(i*3),0
            endif
            dx = mousex() + (sin(dotRot-(i*2)) * out)
            dy = mousey() + (cos(dotRot-(i*2)) * out)
            box dx,dy,dx+size,dy+size
        next i
 
        for i = 1 to 80
            if way = 1
                ink green(i*3),0
            else
                ink yellow(i*3),0
            endif
            dx2 = mousex() + (sin(dotRot+180-(i*2)) * out)
            dy2 = mousey() + (cos(dotRot+180-(i*2)) * out)
            box dx2,dy2,dx2+size,dy2+size
        next i
 
    `Draw Evasive Thing
    edxp = edxp + xdir
    edyp = edyp + ydir
    if rnd(100) = 1 or edxp > screen width() or edxp < 0
       xdir = rnd(20)-10
    endif
    if rnd(100) = 1 or edyp > screen height() or edxp < 0
       ydir = rnd(20)-10
    endif
    if edxp > screen width() then xdir = xdir * -1
    if edyp > screen height() then ydir = ydir * -1
    if edxp < 0 then xdir = xdir * -1
    if edyp < 0 then ydir = ydir * -1
    ink red(1),0
       edx = edxp + (sin(dotRot) * 20)
       edy = edyp + (cos(dotRot) * 20)
       edx2 = edxp + (sin(dotRot+180) * 20)
       edy2 = edyp + (cos(dotRot+180) * 20)
    `box edx,edy,edx+3,edy+3
    `box edx2,edy2,edx2+3,edy2+3
    dotRot = wrapvalue(dotRot+3)
 
    for i = 1 to 80
        ink red(i*3),0
        edxt = edx + (sin(dotRot-(i*2)) * 20)
        edyt = edy + (cos(dotRot-(i*2)) * 20)
        box edxt,edyt,edxt+3,edyt+3
    next i
 
    for i = 1 to 80
        ink red(i*3),0
        edx2t = edx + (sin(dotRot+180-(i*2)) * 20)
        edy2t = edy + (cos(dotRot+180-(i*2)) * 20)
        box edx2t,edy2t,edx2t+3,edy2t+3
    next i   
 
    if mouseclick() = 1
        if (abs(mousex() - edxp) < out) and (abs(mousey() - edyp) < out)
            spray(mousex(),mousey(),"r")
        else
            spray(mousex(),mousey(),"y")
 
        endif
    endif
 
    if mouseclick() = 2
        if way = 1
            way = 0
            goto MC2_Outside
        endif
        if way = 0
            way = 1
        endif
    endif
    MC2_Outside:
 
    out = out + int(mousemovez()/100)
    size = int(out/6)
 
    syncSpray()
 
sync:loop
 
function spray(x,y,k as string)
if sprayInProgress = 0
    for i = 1 to 200
       spr(i).X = x
       spr(i).Y = y
       spr(i).XDIR = rnd(20) - 10
       spr(i).YDIR = rnd(20) - 20
       if i = 1
         spr(i).LIFE = 255
       else
         spr(i).LIFE = rnd(255)
       endif
       spr(i).KIND = k
    next i
    sprayInProgress = 1
endif
endfunction
function syncSpray()
    for i = 1 to 200
       spr(i).X = spr(i).X + spr(i).XDIR
       spr(i).Y = spr(i).Y + spr(i).YDIR
       spr(i).LIFE = spr(i).LIFE - 5
       spr(i).YDIR = spr(i).YDIR + 1 : `Gravity Bill
    next i
    for i = 1 to 200
        if spr(i).KIND = "y"
            ink rgb(spr(i).LIFE,spr(i).LIFE,0),0
        else:if spr(i).KIND = "r"
            ink rgb(spr(i).LIFE,0,0),0
        endif:endif
        if spr(i).LIFE < 1
            ink 0,0
        endif
        box spr(i).X,spr(i).Y,spr(i).X+2,spr(i).Y+2
    next i
        if spr(1).LIFE < 1
            sprayInProgress = 0
        endif
endfunction