' HELLO WORLD - 3D
' beaucoup de choses en quelques lignes :
' des objets, de la trigo, du hasard, des boucles,
' une fonction, un tableau de données, des effets

?horizon = 175
?max = 200

for 1 to ?max as ?i
	' création des 200 mots
	?color = (random 50 to 200)
	?obj = "voxel-?i"
	
	if (even ?i) = 1
		color 0, ?color / 2, ?color * 2' bleu
		create text "HELLO" as ?obj
	else
		color ?color * 2, ?color / 2, 0' orange
		create text "WORLD" as ?obj
	end
	
	' un petit effet visuel...
	paint ?obj to "neon"
	zoom z ?obj to 4
	' et positionnement
	goto "random position", ?obj
next

label "random position" local
	' une fonction avec paramètre pour placer chacun mot
	param ?objet
	global ?horizon
	' positionnement aléatoire :
	?x = (random -?horizon to ?horizon)
	?y = (random -?horizon / 2 to ?horizon / 2)
	move ?objet to ?x, ?y, ?horizon
	turn ?objet to ?y, -?x / 2, 0
	' chaque objet sa propre vitesse :
	[speed, ?objet] = (random 10 to 100) / 50
return

move "camera" to 0
free "camera"

do
	' la boucle principale : animation des 200 objets
	for 1 to ?max as ?j
		?obj = "voxel-?j"
		move z ?obj by -[speed, ?obj]
		' l'objet passe derrière la caméra ? on recommence !
		if (move z ?obj) < 0
			goto "random position", ?obj
		end
	next
	
	' un effet de caméra subtilement choisi
	?angle + 1
	turn y "camera" to 15 * (sin ?angle / 2)
	turn z "camera" to 10 * (cos ?angle)
	
	' et une variation de l'horizon
	?horizon = 175 + 100 * (cos ?angle / 2)
	show fog #303 to ?horizon
	update
loop
x