rem ANG&DIST
rem This robot aims specifically at the 4 corners.
rem After shooting one corner, it moves to another position and
rem shoots at another corner.

10  x=10: y=10: gosub 1000:aim=angle:shot=dist:gosub 1010
30  x=490:y=10: gosub 1000:aim=angle:shot=dist:gosub 1010
40  x=490:y=490:gosub 1000:aim=angle:shot=dist:gosub 1010
50  x=10: y=490:gosub 1000:aim=angle:shot=dist:gosub 1010
goto 10

rem Find angle, distance, given coord x,y
rem output: dist, angle
1000 dist=((x-xpos)^2+(ypos-y)^2)^0.5
     angle=atan2(x-xpos,ypos-y)
     return

rem wait till cool down
1010 x = random(300)+100:repair:y=random(300)+100: repair:gosub 2000:return

2000 xvel = (x-xpos)*5: yvel = (y - ypos)*5:repair
     if shot>20 then xvel=0:yvel=0:return
     if abs(x-xpos)<50 and abs(y-ypos)<50 then xvel=0:yvel=0:return
     goto 2000


