sync on
sync rate 60
hide mouse
randomize timer()
 
fastest = 99999
nuts = 0
headshots = 0
 
gx = rnd(610)+15
gy = rnd(400)+60
 
`color as dword
color = rgb(rnd(128)+128,rnd(128)+128,rnd(128)+128)
 
bodies = 0
 
DO
   cls
 
   timerz = timer()
 
   if blowup = 0 then bonus = 4000-(timerz - timestamp)
 
   if timerz > timestamp+4000 or t# > 18
      inc bodies
      timestamp = timer()
      gx = rnd(610)+15
      gy = rnd(400)+60
      t# = 0.0
      blowup = 0
   color = rgb(rnd(128)+128,rnd(128)+128,rnd(128)+128)
   endif
 
   if mouseclick() = 1 and flag = 0
      flag = 1
      if mouseWithin(gx-15,gy-60,gx+15,gy+20)
         d = (mousex()-gx)^2 + (mousey()-(gy-50))^2
         if d <= 100
            inc headshots
            inc score, 1000
            headFlag = 1
            headTimer = timer()
         endif
 
         d = (mousex()-gx)^2 + (mousey()-gy)^2
         if d <= 70
            inc nuts
            dec score, 5000
            nutFlag = 1
            nutTimer = timer()
         endif
         blowup = 1
         inc score, bonus
         inc hits
         totalTime = totalTime + (timerz-timestamp)
         avgSpeed = totalTime/bodies
         if timerz-timestamp < fastest then fastest = timerz-timestamp
      else
         inc misses
         dec score, 500
      endif
   endif
 
   if mouseclick() = 0 then flag = 0
 
   if blowup = 1 then t# = t#+0.3
 
   ink color,0
   draw_guy(gx,gy,t#)
 
   if nutFlag = 1
      center text 320,46,"Disrespectful nut shot!  -5000"
      if nutTimer+4000 < timer() then nutFlag = 0
   endif
 
   if headFlag = 1
      center text 320,62,"Head shot!  +1000"
      if headTimer+4000 < timer() then headFlag = 0
   endif
 
 
   rem draw mouse cursor
   mx = mousex()
   my = mousey()
   ink rgb(0,255,0),0
   line mx-5,my,mx+5,my
   line mx,my-5,mx,my+5
 
   rem calculate accuracy
   if hits+misses = 0
      acc = 0
   else
      acc = (hits/(hits+misses+0.0))*100.0
   endif
 
   center text 320,10,str$(bonus)
   center text 320,30,"Round "+str$(bodies)
 
   set cursor 0,0
   print "Score: ",score
   print "Hits: ",hits
   print "Misses: ",misses
   print "Accuracy: ",acc,"%"
   print "Fastest Time: ",fastest
   print "Average Speed: ", avgSpeed
   print "Head Shots: ", headshots
   print "Disrespectful Hits: ", nuts
 
   sync
LOOP
 
 
 
function draw_guy(x, y, t#)
   g# = -4.0
   v = 20
 
   if t# > 0
      x1 = x+v*cos(270)*t#
      y1 = y+(v*sin(270)*t# - 0.5*g#*t#^2)
      x2 = x+v*cos(300)*t#
      y2 = y+(v*sin(300)*t# - 0.5*g#*t#^2)
      x3 = x+v*cos(225)*t#
      y3 = y+(v*sin(225)*t# - 0.5*g#*t#^2)
      x4 = x+v*cos(315)*t#
      y4 = y+(v*sin(315)*t# - 0.5*g#*t#^2)
      x5 = x+v*cos(180)*t#
      y5 = y+(v*sin(180)*t# - 0.5*g#*t#^2)
      x6 = x+v*cos(0)*t#
      y6 = y+(v*sin(0)*t# - 0.5*g#*t#^2)
      draw_head(x1,y1)
      draw_body(x2,y2)
      draw_leftArm(x3,y3)
      draw_rightArm(x4,y4)
      draw_leftLeg(x5,y5)
      draw_rightLeg(x6,y6)
   else
      draw_head(x,y)
      draw_body(x,y)
      draw_leftArm(x,y)
      draw_rightArm(x,y)
      draw_leftLeg(x,y)
      draw_rightLeg(x,y)
   endif
 
endfunction
 
 
 
 
function draw_head(x,y)
   circle x,y-50,10
endfunction
 
 
function draw_leftArm(x,y)
   line x,y-34,x-10,y-20
endfunction
 
 
function draw_rightArm(x,y)
   line x,y-34,x+10,y-20
endfunction
 
 
function draw_leftLeg(x,y)
   line x,y,x-15,y+20
endfunction
 
 
function draw_rightLeg(x,y)
   line x,y,x+15,y+20
endfunction
 
 
function draw_body(x,y)
   line x,y,x,y-40
endfunction
 
 
function mouseWithin(x1,y1,x2,y2)
   if mousex() > x1 and mousex() < x2 and mousey() > y1 and mousey() < y2 then exitfunction 1
endfunction 0