Sorry abiut that. Here is the code
rem 3D Starfield Demo - Written by Jason Clogg
rem Feel free to use any of this code
sync on
sync rate 60
autocam off
color backdrop 0
rem Make a dummy object to be moved with the camera as camera angles give funny results.
make object box 1,.1,.1,.1
hide object 1
while spacekey()=0
if leftkey()=1
roll camera left 1
roll object left 1,1
endif
if rightkey()=1
roll camera right 1
roll object right 1,1
endif
if upkey()=1
pitch camera down 1
pitch object down 1,1
endif
if downkey()=1
pitch camera up 1
pitch object up 1,1
endif
if mouseclick()=1 then speed#=speed#+.1
if mouseclick()=2 then speed#=speed#-1
if speed#>5 then speed#=5
if speed#<0 then speed#=0
move camera speed#
move object 1,speed#
gosub draw_starfield
text 0,0,"3D Starfield - Written by Jason Clogg"
text 0,20,"fps= "+str$(screen fps())
sync
endwhile
end
draw_starfield:
rem base sprite number
base=600
rem How widely to spread the stars
spread=80
rem How many starts to display
stars=20
rem The initial distance to start the starts displaying
dist=250
`Calculate a point in front of the camera to start drawing the starfield
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
pick screen screen width()/2,screen height()/2,dist
sx#=get pick vector x()
sy#=get pick vector y()
sz#=get pick vector z()
if object exist(600)=0
make object box 600,.5,.5,.5
for i=601 to 600+stars
clone object i,600
rem stars should not be affected by light or included in collisions
set object light i,0
set object collision off i
position object i,rnd(spread*2)-spread,rnd(spread*2)-spread,camera position z()+rnd(dist)
next i
endif
for i=600 to 600+stars
`reposition stars if they are out of camera shot
if object in screen(i)=0
position object i,cx#+sx#+(rnd(spread)-(spread/2)),cy#+sy#+(rnd(spread)-(spread/2)),cz#+sz#+(rnd(spread*2)-(spread/2))
endif
`Calculate distance of star from camera and scale star accordingly
dist#=distance(cx#,cy#,cz#,i)
scale object i,.1*(dist#*2),.1*(dist#*2),2000*speed#
set object to object orientation i,1
rem The multiple of 1.2 will need to be changed depending on the frame rate.
rem This value works best with a sync rate of 60
move object i,speed#*-1.2
next i
return
function distance(x1#,y1#,z1#,obj)
x2#=object position x(obj)
y2#=object position y(obj)
z2#=object position z(obj)
dist#=sqrt((x1#-x2#)*(x1#-x2#)+(y1#-y2#)*(y1#-y2#)+(z1#-z2#)*(z1#-z2#))
endfunction dist#
Cheers,
Cloggy