Yeh
` setup
sync on : sync rate 60
set display mode 1024, 768, 32 : hide mouse
autocam on : set camera range 1, 0x7fffffff
backdrop on : color backdrop 0
` Start and End of waypoints
StartPoint = 100
EndPoint = 110
` Create a sphere to follow waypoints
make object sphere 1, 100
` Speed of sphere
Speed# = 20.0
` Create waypoints
for w = StartPoint to EndPoint
make object cube w, 100
color object w, rgb( 255, 0, 0 )
position object w, rnd( 5000 ), 0, rnd( 5000 )
next w
` Set target to first waypoint
TargetObj = StartPoint
TargetX# = object position x( TargetObj )
TargetZ# = object position z( TargetObj )
` Set sphere to first waypoint
SphereX# = TargetX#
SphereZ# = TargetZ#
` Create the ground
make matrix 1, 5000, 5000, 50, 50
` Position the camera
position camera 2500, 5000, 2500
xrotate camera 90
` Main Loop
do
` Show FPS
text 10, 10, str$( screen fps() )
` Draw lines through waypoints
for w = StartPoint to EndPoint - 1
line object screen x( w ), object screen y( w ), object screen x( w + 1 ), object screen y( w + 1 )
next w
` Get new positions of sphere
SphereX# = SphereX# + ( sin( atanfull( TargetX# - SphereX#, TargetZ# - SphereZ# ) ) * Speed# )
SphereZ# = SphereZ# + ( cos( atanfull( TargetX# - SphereX#, TargetZ# - SphereZ# ) ) * Speed# )
` Get distance between sphere and current waypoint
Dist# = sqrt( (TargetX# - SphereX#)^2 + (TargetZ# - SphereZ#)^2 )
` If distance < 50, set new target
if (Dist# < 50)
TargetObj = TargetObj + 1
` If Target is out of waypoints, move back to first
if (TargetObj > EndPoint)
TargetObj = StartPoint
endif
` Set new target positions
TargetX# = object position x( TargetObj )
TargetZ# = object position z( TargetObj )
endif
` Update sphere
position object 1, SphereX#, 0, SphereZ#
` Loop
sync
loop
"It's like floating a boat on a liquid that I don't know, but I'm quite happy to drink it if I'm thirsty enough" - Me being a good programmer but sucking at computers