This is my poor man's code put to use in a 200-entity scenario.
Imagine that the boxes are airplanes. Each plane has a random target assigned for it to follow.
I did not use airplane physics here, but the point is the objects will follow their target unless code is implemented to change targets, for example when a box is destroyed. If you add a little intersect object magic and some bullet effects, you have the beginnings of a dogfight. Or, if you want a ground vehicle, just take away the pitch rotation.
The coding is inefficient and sloppy, but the general concept works.
gosub Setup
sync on:sync rate 60
do
gosub MoveObjects
control camera using arrowkeys 0,1,5
set cursor 0,0:print screen fps()
sync
LOOP
MoveObjects: `AND TURN!!!
for All=TeamAStart to TeamAEnd
move object All,TeamASpeed#(All)
move object All+100,TeamBSpeed#(All)
TeamAPosX#(All)=object position x(All):TeamAPosY#(All)=object position y(All):TeamAPosZ#(All)=object position z(All)
TeamBPosX#(All)=object position x(All+100):TeamBPosY#(All)=object position y(All+100):TeamBPosZ#(All)=object position z(All+100)
TeamAangleX#(All)=object angle x(All):TeamAangleY#(All)=object angle y(All):TeamAangleZ#(All)=object angle z(All)
TeamBangleX#(All)=object angle x(All+100):TeamBangleY#(All)=object angle y(All+100):TeamBangleZ#(All)=object angle z(All+100)
point object All,object position x(TeamATarget(All)),object position y(TeamATarget(All)),object position z(TeamATarget(All))
point object All+100,object position x(TeamBTarget(All)),object position y(TeamBTarget(All)),object position z(TeamBTarget(All))
`GRADUAL TURNING
missile=All
max#=object angle x(All):may#=object angle y(All):maz#=object angle z(All)
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 All,max#,may#,maz#
NEXT
return
Setup:
color backdrop rgb(20,160,200)
TTime=400 `TARGET RESET TIME (timed in loops)
TargetSpeed#=.5 `TARGET SPEED
Turning#=.2 `MISSILE TURNING CAPABILIY
MSpeed#=1 `MISSILE SPEED
dim TeamAPosX#(100):dim TeamAPosY#(100):dim TeamAPosZ#(100)
dim TeamBPosX#(100):dim TeamBPosY#(100):dim TeamBPosZ#(100)
dim TeamAExist(100):dim TeamBExist(100)
dim TeamAangleX#(100):dim TeamAangleY#(100):dim TeamAangleZ#(100)
dim TeamBangleX#(100):dim TeamBangleY#(100):dim TeamBangleZ#(100)
dim TeamASpeed#(100):dim TeamBSpeed#(100)
dim TeamAHealth#(100):dim TeamBHealth#(100)
dim TeamATarget(100):dim TeamBTarget(100)
TeamAStart=1:TeamAEnd=100
TeamBStart=101:TeamBEnd=200
load image "TeamA-skin.png",TeamAStart:make object cube TeamAStart,1:texture object TeamAStart,TeamAStart
load image "TeamB-skin.png",TeamBStart:make object cube TeamBStart,1:texture object TeamBStart,TeamBStart
for MakeAll=TeamAStart to TeamAEnd
if MakeAll>1 then clone object MakeAll,TeamAStart:position object MakeAll,rnd(200)-rnd(200),rnd(200)-rnd(200),rnd(200)-rnd(200)
if MakeAll>1 then clone object MakeAll+100,TeamBStart:position object MakeAll+100,rnd(200)-rnd(200),rnd(200)-rnd(200),rnd(200)-rnd(200)
TeamAHealth#(MakeAll)=100:TeamBHealth#(MakeAll)=100
TeamASpeed#(MakeAll)=.1+(rnd(100)/100):TeamBSpeed#(MakeAll)=.1+(rnd(100)/100)
TeamATarget(MakeAll)=101+rnd(99):TeamBTarget(MakeAll)=1+rnd(99)
NEXT
return