sync on
hide mouse
randomize timer()
 
radius=50
 
maxx=490
minx=150
maxy=250
miny=150
x=rnd(maxx-minx)+minx
y=200
rd#=100
rx=x
ry=y+rd#
ra#=270
xdirection=rnd(1)
ydirection=rnd(1)
speed=1
mode=1
level=1
levelcount=1
lcount=1
cr=rnd(155)+100
cg=rnd(155)+100
cb=rnd(155)+100
set gamma cr,cg,cb
 
do
 
   cls
 
   ink rgb(cr/10,cg/10,cb/10),0
   box 1,1,639,479
 
   if mode=2 or mode=3
      if xdirection=1
         x=x+speed
         if x>maxx then xdirection=0 : x=maxx
      else
         x=x-speed
         if x<minx then xdirection=1 : x=minx
      endif
   endif
   if mode=3
      if ydirection=1
         y=y+speed
         if y>maxy then ydirection=0 : y=maxy
      else
         y=y-speed
         if y<miny then ydirection=1 : y=miny
      endif
   endif
   if mode=4
      ra#=ra#+speed/2+1
      tx=cos(ra#)*rd#
      ty=sin(ra#)*rd#
      x=rx+tx
      y=ry+ty
   endif
 
   position mouse mousex()+rnd(4)-2,mousey()+rnd(4)-2
 
   shots=hit+missed
   shotsr#=shots
   hitr#=hit
   if hit>0 then acuracy#=(hitr#/shotsr#)*100 else acuracy#=100
 
   ink rgb(cr,cg,cb),0
   print "Level: ";level
   print "Score: ";score
   print "Shots: ";shots
   print "Hits: ";hit
   print "Misses: ";missed
   print "Bullseyes: ";bullseyes
   print "Acuracy: ";acuracy#;"%"
 
   circle x,y,radius+1
   circle x,y,radius
   circle x,y,radius/2+radius/4
   circle x,y,radius/2
   circle x,y,radius/4
   circle x,y,radius/16
 
   circle mousex(),mousey(),10
   if mousex()<16 then line 1,mousey(),mousex()+15,mousey() else line mousex()-15,mousey(),mousex()+15,mousey()
   if mousey()<16 then line mousex(),1,mousex(),mousey()+15 else line mousex(),mousey()-15,mousex(),mousey()+15
   ink 0,0
   dot mousex(),mousey()
 
   if fadein=1
      for i=1 to 100 step 10
         ir#=i
         set gamma (ir#/crr#)*255,(ir#/cgr#)*255,(ir#/cbr#)*255
      next i
      fadein=0
   endif
 
   set text size 50
   ink rgb(cr,cg,cb),0
   if mouseclick()=1
      if circlclsn(radius+1,x,y,mousex(),mousey())
         if circlclsn(radius/2+radius/4,x,y,mousex(),mousey())
            if circlclsn(radius/2,x,y,mousex(),mousey())
               if circlclsn(radius/4,x,y,mousex(),mousey())
                  if circlclsn(radius/16,x,y,mousex(),mousey())
                     center text 320,50,"Bullsye! 50 Points"
                     bullseyes=bullseyes+1
                     score=score+50
                  else
                     center text 320,50,"40 Points"
                     score=score+40
                  endif
               else
                  center text 320,50,"30 Points"
                  score=score+30
               endif
            else
               center text 320,50,"20 Points"
               score=score+20
            endif
         else
            center text 320,50,"10 Points"
            score=score+10
         endif
         hit=hit+1
         sleep 500
         crr#=cr
         cgr#=cg
         cbr#=cb
         for i=1 to 100 step 10
            ir#=i
            set gamma ((100-ir#)/crr#)*255,((100-ir#)/cgr#)*255,((100-ir#)/cbr#)*255
         next i
         sleep 100
         gosub nextlevel
         fadein=1
      else
         center text 320,50,"Missed shot! -20 Points"
         missed=missed+1
         score=score-20
         sleep 500
      endif
      sync
   endif
 
   sync
 
loop
 
nextlevel:
   cr=rnd(155)+100
   cg=rnd(155)+100
   cb=rnd(155)+100
   x=rnd(maxx-minx)+minx
   y=200
   rx=x
   ry=y+rd#
   ra#=270
   xdirection=rnd(1)
   ydirection=rnd(1)
   radius=radius-1
   mode=mode+1
   if mode>4 then mode=1 : level=level+1 : levelcount=levelcount+1
   lcount=lcount+1
   if lcount>49 then end
   if levelcount=3
      levelcount=1
      speed=speed+1
   endif
return
 
function circlclsn(radius,x,y,cx,cy)
   collision=0
   if sqrt((x-cx)^2+(y-cy)^2)<radius then collision=1
endfunction collision