sync on:sync rate 120
sync
make camera 1
color backdrop 1,0
 
set text font "Times New Roman"
set text size 50
 
global sw
global sh
global wins
global finaltime
global time
 
sw=screen width()
sh=screen height()
finaltime=1000
 
center text sw/2,sh/2-200,"Wait until it says draw, then hit space"
sync
wait key
 
 
do
 
 
   walk()
 
   shoot()
 
   finaltime=finaltime*8
   finaltime=finaltime/10
 
 
loop
 
function with_gun(x,direction)
 
   for k=1 to 460 step 8
      i=20
      if direction=-1
         stick_figure(sw/2+x,sh/2,i)
         stick_figure(sw/2+x-480,sh/2,i)
      else
         stick_figure(sw/2-x,sh/2,i)
         stick_figure(sw/2-x+480,sh/2,i)
      endif
 
      gun(20*direction+sw/2+(x)*-direction,sh/2+50-15,direction)
 
      fire(20*direction+sw/2+(x)*-direction+k*direction,sh/2+50-15)
 
      center text sw/2,sh/2,str$(time)
 
      sync
   next k
 
endfunction
 
function fire(x,y)
 
   circle x,y,5
 
endfunction
 
function gun(x,y,direction)
 
 
   line x,y,x+30*direction,y
   line x+30*direction,y,x+30*direction,y+5
   line x+5*direction,y+5,x+30*direction,y+5
   line x,y,x,y+15
   line x+5*direction,y+5,x+5*direction,y+15
   line x,y+15,x+5*direction,y+15
 
endfunction
 
function shoot()
 
   center text sw/2,sh/2,"DRAW"
 
   x=240
   i=0
   stick_figure(sw/2+50+i+x,sh/2,i)
   stick_figure(sw/2-50-i-x,sh/2,i)
 
   sync
 
   if spacekey()
      space=2
   endif
 
   t1=timer()
 
   time=0
 
   repeat
 
      if spacekey()
         if space<>2
            space=1
         endif
      else
         space=0
      endif
 
      time=timer()-t1
 
      `center text sw/2,sh/2,str$(time)
      `sync
 
   until space=1 or time>finaltime
 
   if time>finaltime
      with_gun(sw/2-240,-1)
      You_loose()
   else
      with_gun(sw/2-240,1)
      wins=wins+1
   endif
 
endfunction
 
function you_loose()
 
   cls
   center text sw/2,sh/2,"You won "+str$(wins)+" times"
   sync
   wait key
 
   end
 
endfunction
 
function walk()
 
for k=1 to 3
   for j=1 to 2
      for i=1 to 40
         `cls
         stick_figure(sw/2+50+i+x,sh/2,i)
         stick_figure(sw/2-50-i-x,sh/2,i)
         text 0,0,"Wins "+str$(wins)
         sync
      next i
 
      x=x+40
 
   next j
   center text sw/2,sh/2,str$(k)
 
   i=0
   stick_figure(sw/2+50+i+x,sh/2,i)
   stick_figure(sw/2-50-i-x,sh/2,i)
 
   text 0,0,"Wins "+str$(wins)
 
   sync
   wait 500
next k
 
while rnd(1000)<>0:wait 1:endwhile
 
endfunction
 
function stick_figure(x,y,frame)
 
   xshift=abs(frame-20)
 
   circle x,y,20
 
   line x,y+20,x,y+80
   line x-20+xshift,y+50,x,y+30
   line x+20-xshift,y+50,x,y+30
   line x-20+xshift,y+110,x,y+80
   line x+20-xshift,y+110,x,y+80
 
endfunction