Вроде работает, но у меня ощущение, что я тут зря намудрил. Подскажете что-нибудь?

Graphics3D 0,0,32,1
SetBuffer BackBuffer()
Type T_cubes
Field x
Field y
Field z
Field col$
Field ent
Field hndl
End Type
cam = CreateCamera()
CreateCubes()
While Not KeyDown(1)
UpdateWorld()
RenderWorld()
Flip
Wend
End
;---------------------------------------------------;
Function CreateCubes()
For i = 1 To 10
cube.T_cubes = New T_cubes
cube\ent = CreateCube()
cube\x = i * 3 - 15
cube\y = 0
cube\z = 20
cube\hndl = Handle(cube.T_cubes)
If i > 1
pointer.T_cubes = New T_cubes
pointer.T_cubes = Object.T_cubes(i - 1)
If pointer\col = "green"
cube\col = "blue"
ElseIf pointer\col = "blue"
cube\col = "red"
ElseIf pointer\col = "red"
cube\col = "green"
EndIf
Else
n = Rand(1,3)
If n = 1
cube\col = "red"
EntityColor cube\ent,255,0,0
ElseIf n = 2
cube\col = "green"
EntityColor cube\ent,0,255,0
ElseIf n = 3
cube\col = "blue"
EntityColor cube\ent,0,0,255
EndIf
EndIf
If cube\col = "red"
EntityColor cube\ent,255,0,0
ElseIf cube\col = "green"
EntityColor cube\ent,0,255,0
ElseIf cube\col = "blue"
EntityColor cube\ent,0,0,255
EndIf
PositionEntity cube\ent,cube\x,cube\y,cube\z
Next
End Function