Great stuff there Ric!
Here's my version:
autocam off
Sync On
set camera range 1,10000
color backdrop rgb(100,100,250)
fog on
fog color rgb(100,100,250)
fog distance 450
numberofclouds=400
cloudseed=freeobject()
create_clouds(cloudseed,numberofclouds)
do
control camera using arrowkeys 0,0.1,1
move_clouds(cloudseed,numberofclouds)
text 0,0,str$(screen fps())
sync
loop
function create_clouds(cloudseed,numberofclouds)
create bitmap 1,50,50
ink rgb(255,255,200),0
for x=1 to 1000
ang=rnd(180)
rad=rnd(20)
box 25+sin(ang)*rad,25+cos(ang)*rad,rnd(3)+25+sin(ang)*rad,rnd(3)+25+cos(ang)*rad
next x
blur bitmap 1,4
cloudimage = freeimage()
get image cloudimage, 0, 0, 50, 50
delete bitmap 1
for cloudnumber=cloudseed to cloudseed+numberofclouds
make object plain cloudnumber,rnd(50)+100,rnd(50)+100
position object cloudnumber,rnd(1000)-500,rnd(100)+10,rnd(1000)-500
zrotate object cloudnumber,90 : fix object pivot cloudnumber
texture object cloudnumber,cloudimage
ghost object on cloudnumber,0
disable object zwrite cloudnumber
set object light cloudnumber,0
next n
endfunction
function move_clouds(cloudseed,numberofclouds)
for cloudnumber=cloudseed to cloudseed+numberofclouds
move object cloudnumber,-.05
if object position z(cloudnumber)<-500 then position object cloudnumber,rnd(1000)-500,rnd(100)+10,500
point object cloudnumber,camera position x(),object position y(cloudnumber),camera position z()
next cloudnumber
endfunction
function freeobject()
repeat
inc n
until object exist(n) = 0
endfunction n
function freeimage()
repeat
inc n
until image exist(n) = 0
endfunction n
[Edit]
Personally though, this is the way I would code it... I don't like the idea of getting a free seed object, then not check if the rest are free, so this uses arrays. This also means each cloud can be controlled seperatelly.
A few more changes:
The color of the clouds can be changed, and the clouds always respawn back to the front, so they always follow you.
`Startup
Sync on : Sync rate 60
Set Display Mode 1024,768,16 : Hide Mouse
Set Camera Range 1,0x7fffffff : Autocam off
Fog on : Fog color rgb(100,100,250) : fog distance 450
Backdrop on : Color backdrop rgb(100,100,250)
`Setup World
Type Vec3D
X as float
Y as float
Z as float
Endtype
speed#=1
`Create Clouds
cnum=400
climg=CreateCloudImage(rgb(255,255,255))
Type tClouds
Obj as integer
Pos as Vec3D
Move as float
Endtype
Dim Clouds(cnum) as tClouds
for c=1 to cnum
Clouds(c).Obj=CreateCloud(climg)
Clouds(c).Pos.X=rnd(1000)-500
Clouds(c).Pos.Y=rnd(100)+10
Clouds(c).Pos.Z=rnd(1000)-500
Clouds(c).Move=rnd(0.5)
next c
`**Main Loop**
Do
`Control Camera
ay#=wrapvalue(ay#+mousemovex())
if mouseclick()=1
x#=x#+(sin(ay#)*speed#)
z#=z#+(cos(ay#)*speed#)
endif
if mouseclick()=2
x#=x#-(sin(ay#)*speed#)
z#=z#-(cos(ay#)*speed#)
endif
position camera x#,0,z#
rotate camera 0,ay#,0
`Control Clouds
for c=1 to cnum
ControlCloud(c)
next c
`Text
ink rgb(0,0,0),0
Text 10,10,"Use the mouse to move around"
Text 10,screen height()-20,"FPS: "+str$(screen fps())
`**End Loop**
Sync
Loop
`**Functions**
Function FreeObj()
for i=1 to 65535
if Object exist(i)=0
exitfunction i
endif
next i
Endfunction i
Function FreeImg()
for i=1 to 65535
if Image exist(i)=0
exitfunction i
endif
next i
Endfunction i
Function CreateCloud(img)
cloud=FreeObj()
Make Object Plain cloud,rnd(50)+100,rnd(50)+100
zrotate object cloud,90 : fix object pivot cloud
Texture Object cloud,img
Ghost Object on cloud
Disable Object ZWrite cloud
Set Object Light cloud,0
Endfunction cloud
Function CreateCloudImage(col)
cloudi=FreeImg()
Create Bitmap 1,50,50 : set current bitmap 1
ink col,0
for x=1 to 1000
ang=rnd(180) : rad=rnd(20)
box 25+sin(ang)*rad,25+cos(ang)*rad,rnd(3)+25+sin(ang)*rad,rnd(3)+25+cos(ang)*rad
next x
blur bitmap 1,4
get image cloudi,0,0,bitmap width(1),bitmap height(1)
Set current bitmap 0 : delete bitmap 1
Endfunction cloudi
Function ControlCloud(c)
Clouds(c).Pos.Z=Clouds(c).Pos.Z-Clouds(c).Move
if Clouds(c).Pos.Z<Camera Position Z()-500 then Clouds(c).Pos.Z=Camera Position Z()+500
if Clouds(c).Pos.Z>Camera Position Z()+500 then Clouds(c).Pos.Z=Camera Position Z()-500
if Clouds(c).Pos.X<Camera Position X()-500 then Clouds(c).Pos.X=Camera Position X()+500
if Clouds(c).Pos.X>Camera Position X()+500 then Clouds(c).Pos.X=Camera Position X()-500
Point Object c,camera position x(),Clouds(c).Pos.Y,camera position z()
Position Object c,Clouds(c).Pos.X,Clouds(c).Pos.Y,Clouds(c).Pos.Z
Endfunction
That just feels more comfy with me, heh.