how to choose which waypoint next?

Blitz3D Forums/Blitz3D Beginners Area/how to choose which waypoint next?

THat's because you're seaching through all children 3 times.


Use an array of types .. much quicker to access as no need for loops to find the one you need ... e.g.

Type Waypoint
	Field x#, y#, z#
End Type

Const Lanes = 3
Const Waypoints = 5
Dim WP.waypoint( Lanes-1, Waypoints-1 )

; fill with data
For i = 0 To Lanes - 1
	For j = 0 To Waypoints - 1
		WP( i, j ) = New waypoint
		WP( i, j )\x =Rnd(1,7)
		WP( i, j )\y = 0
		WP( i, j )\z = i
	Next
Next

;print current data
For i = 0 To Lanes - 1
	Print "Lane " + (i+1)
	For j = 0 To Waypoints-1
		w.waypoint = WP( i, j )
		Print "waypoint number: "+(j+1)+" x="+WP(i,j)\x + " y="+ WP(i,j)\y + " z="+WP(i,j)\z
	Next
Print""
Next

;print position 2 in lane 1
Print "****************"
Print "x="+WP( 0, 1)\x + " y="+ WP( 0, 1 )\y + " z="+WP( 0, 1 )\z


;Flip
WaitKey()

End