It would be great if someone could improve this, perhaps using CURVEVALUE/CURVEANGLE, ATAN/ATANFULL or whatever else you math whizzes do.
It does work though!
(Remove the cheesy sound statements if not to your liking.)
backdrop on:color backdrop rgb(35,63,45):sync on:sync rate 25
randomize timer()
record sound 1,2000:wait 2000:stop recording sound
set sound speed 1,5000
`MAKE TARGET
target=1:make object sphere Target,5:position object Target,0,0,-10:color object Target,rgb(100,100,200)
`MAKE MISSILE
missile=2:make object cube 2,.3:color object missile,rgb(200,100,100)
TTime=400 `TARGET RESET TIME (timed in loops)
TargetSpeed#=.5 `TARGET SPEED
Turning#=2 `MISSILE TURNING CAPABILIY
MSpeed#=1 `MISSILE SPEED
do
`GET OLD x/y/z
`TARGET/ARC RESET
if TargetTimer=0 or keystate(20)=1 then position object Target,0,0,-10:Arc=rnd(1):TargetTimer=TTime:rotate object Target,0,0,0
dec TargetTimer
`RANDOM ARC (cheap)
if Arc=0 then turn object left target,.1 else turn Object right target,.1
if Arc=0 then pitch object up target,.1 else pitch object down target,.1
`TARGET COORDINATES
x#=object position x(Target):y#=object position y(Target):z#=object position z(Target)
`MISSILE ANGLE
max#=wrapvalue(object angle x(missile)):may#=wrapvalue(object angle y(missile)):maz#=wrapvalue(object angle z(missile))
`GET DESIRED MISSILE ANGLE (temporary rotation)
point object missile,x#,y#,z#
`GRADUAL TURNING
diff#=INT(object angle x(missile)-max#)
if diff#<-1 and abs(diff#)>=180 then inc max#,Turning#
if diff#>1 and abs(diff#)>=180 then dec max#,Turning#
if diff#<-1 and abs(diff#)<180 then dec max#,Turning#
if diff#>1 and abs(diff#)<180 then inc max#,Turning#
diff#=(object angle y(missile)-may#)
if diff#<-1 and abs(diff#)>=180 then inc may#,Turning#
if diff#>1 and abs(diff#)>=180 then dec may#,Turning#
if diff#<-1 and abs(diff#)<180 then dec may#,Turning#
if diff#>1 and abs(diff#)<180 then inc may#,Turning#
diff#=(object angle z(missile)-maz#)
if diff#<-1 and abs(diff#)>=180 then inc maz#,Turning#
if diff#>1 and abs(diff#)>=180 then dec maz#,Turning#
if diff#<-1 and abs(diff#)<180 then dec maz#,Turning#
if diff#>1 and abs(diff#)<180 then inc maz#,Turning#
`ROTATE TO NEW ANGLE
rotate object missile,max#,may#,maz#
`MISSILE MOVE/RESET
if keystate(50)=1 then move object missile, MSpeed#
if keystate(19)=1 then position object missile,0,0,0
ox#=x#:oy#=y#:oz#=z#
`MOVE TARGET
move object Target, TargetSpeed#
x#=object position x(missile):y#=object position y(missile):z#=object position z(missile)
`CHECK FOR INTERSECT
if intersect object (Target,ox#,oy#,oz#,x#,y#,z#) and Chalk=0 then Chalk=1
if intersect object (Target,ox#,oy#,oz#,x#,y#,z#)=0 and Chalk=1 then inc Hits:Chalk=0:Sound#=100:play sound 1
if Sound#>0 then set sound volume 1,Sound#:dec Sound#,.2
`ADJUST TURNING CAPABILITY
if keystate(200)=1 and Turning#<4 then inc Turning#,.1
if keystate(208)=1 and Turning#>1 then dec Turning#,.1:if Turning#<1 then Turning#=1
set cursor 0,0
print "M=Move Missile"
print "R=Reset Missile"
print "T=Reset Target"
print
print "Hits: ";Hits
set cursor 0,350
print "Turning#: ";Turning#
print "(UP/DOWN Arrowkeys to adjust)"
sync
LOOP