This one shows how to use different speeds for different cubes
Type obj
a As Float
y As Float
endtype
Sync On
Rem Ground
Make Object Plain 1, 1000, 1000, 1
xRotate Object 1, 90
Rem irrelevant shadow stuff, to visualize the hovering better
set global shadows on : set global shadow shades 1 : set global shadow color 0,0,0,64
set shadow light 1,50,100,50,500 : set shadow position -1,50,100,50
Rem Cube
For i = 2 To 11
Make Object cube i, 10
set shadow shading on i
Next i
Rem position camera to watch scene
Position Camera 0, 20, -100
dim obj(10) as obj
rem main loop
Do
For i = 1 To 10
obj(i).a = math_wrapFloat(obj(i).a, i/10.0)
obj(i).y = math_wrapPingPong(obj(i).y, 20, 40, obj(i).a)
Position Object i+1, (i*15)-50, obj(i).y, 0.0
Center Text object screen x(i+1), object screen y(i+1), Left$(Str$(obj(i).a), 6)
Next i
Control Camera using arrowkeys 0, 1, 1
Sync
Loop
End
Function math_wrapFloat(n As Float, spd As Float)
n = n + spd
If n => 360.0 Then n = 0.0
endFunction n
Function math_wrapPingPong(n As Float, rng1 As Float, rng2 As Float, ang As Float)
Local i As Float
i = (rng2 - rng1) / 2.0
n = rng1 + i + (Cos(ang) * i)
endFunction n
This one shows how to use different height ranges for each cube
Type obj
a As Float
y As Float
r1 As Float
r2 As Float
endtype
dim obj(10) as obj
Sync On
Rem Ground
Make Object Plain 1, 1000, 1000, 1
xRotate Object 1, 90
Rem irrelevant shadow stuff, to visualize the hovering better
set global shadows on : set global shadow shades 1 : set global shadow color 0,0,0,64
set shadow light 1,50,100,50,500 : set shadow position -1,50,100,50
Rem Cube
For i = 2 To 11
Make Object cube i, 10
set shadow shading on i
obj(i-1).r1 = Rnd(20)
obj(i-1).r2 = Rnd(40)
Next i
Rem position camera to watch scene
Position Camera 0, 20, -100
rem main loop
Do
For i = 1 To 10
obj(i).a = math_wrapFloat(obj(i).a, 0.2)
obj(i).y = math_wrapPingPong(obj(i).y, obj(i).r1, obj(i).r2, obj(i).a)
Position Object i+1, (i*15)-50, obj(i).y, 0.0
Center Text object screen x(i+1), object screen y(i+1), Left$(Str$(obj(i).y), 6)
Next i
Control Camera using arrowkeys 0, 1, 1
Sync
Loop
End
Function math_wrapFloat(n As Float, spd As Float)
n = n + spd
If n => 360.0 Then n = 0.0
endFunction n
Function math_wrapPingPong(n As Float, rng1 As Float, rng2 As Float, ang As Float)
Local i As Float
i = (rng2 - rng1) / 2.0
n = rng1 + i + (Cos(ang) * i)
endFunction n
There is always one more imbecile than you counted on.