REM ************************************************
REM  Spiral Game by Irojo - DBC Challenge Thread
REM ************************************************
 
 
 
 
 
 
 
 
rem Dont have it make a hitme every loop
rem setup screen
`hide mouse
sync on
sync rate 0
red=rgb(255,0,0)
rem boxlocate (x1,y1,x2,y2)
sw=screen width()-1
sh=screen height()-1
DIM bxl(sw,sh,sw)
health=100
hitx=rnd(screen width())
hity=rnd(screen height())
rem (Hit-me's.)
rem These should be hit.
ink rgb(255,255,255),0
dim hitmes(screen width()+100,screen height()+100)
rem (/)
gosub Make_images
input "please enter difficulty (1=easy, 10=hard)-->",difficulty:if difficulty>10 then difficulty=10
gosub Target_Locate
DO
  For angle= 0 to 360 step 6
    ink rgb(red,255,255),0
    spiral(mousex(),mousey(),angle,50,8)
    box hitx-20,hity-20,hitx+20,hity+20
    set cursor 0,0
    ink rgb(255,0,0),0:printc "Health : ":ink rgb(0,0,255),0:printc health:ink rgb(255,0,0),0:printc "    Score : ":ink rgb(0,0,255),0:print score
    x=mousex()+cos(angle+8*51)*50:y=mousey()+sin(angle+8*51)*50
    gosub targets
    ink rgb(255,255,255),0
    newx=mousex()
    newy=mousey()
    if mouseclick()=1
       for checkx=newx-22 to newx-4
         for checky=newy-22 to newy-4
           if hitmes(checkx,checky)=1 then hitmes(checkx,checky)=0:inc score,1
         next checky
        next checkx
     for fire=1 to 200
       inc x,cos(angle+140)*6
       inc y,sin(angle+140)*6
       dot x,y
       if x>hitx-20 and x<hitx+20 and y>hity-20 and y<hity+20:dec health,10:exit
       endif
     next fire
     if health<0 then gosub death
    endif
    sync:cls
  Next angle
LOOP
 
End
 
rem subroutines ---------------------------------------------------------------------------------------------------
death:
cls
repeat:until scancode()=0
print "You have failed.  Score : "+str$(score)
wait key
end
return
 
targets:
if difficulty>2
 for make=1 to 3
   hitmes(rnd(screen width()-100)+50,rnd(screen height()-100)+50=1
 next make
endif
if difficulty>0
    hitmes(rnd(screen width()-100)+50,rnd(screen height()-100)+50=1
endif
 
for scanx=0 to screen width()
  for scany=0 to screen height()
    if hitmes(scanx,scany)=1 then paste image 1,scanx+7,scany+7:inc total,1
  next scany
next scanx
hitcount=total
total=0
return
 
Make_images:
SBFillCircle(10,10,7)
get image 1,0,0,18,18
cls
return
 
Target_Locate:
for targets=1 to difficulty*10
  hitmes(rnd(screen width()-100)+50,rnd(screen height()-100)+50=1
next targets
return
 
 
Function spiral(x,y,angle,radius,coil)
  xx=x
  yy=y
  a= angle
  for r= 0 to radius
     inc a,coil
     oldx= xx
     oldy= yy
     xx= x + cos(a) * r
     yy= y + sin(a) * r
     line oldx,oldy,xx,yy
   next r
Endfunction
 
function SBFillCircle( CX, CY, R )
   sR = R*R
   for i = 1 to R
      h = sqrt( sR - i*i )
      box CX - i, CY - h, CX + i, CY + h
   next i
endfunction