'Ever wondered what 400 stars in a 3D starfield at full 
'frame rate looks like?
'Press F9!
'This routine uses a simple trick to make more stars
'possible.
'The routine handles 444 stars at full frame rate
'It can also do 880 stars at 25fps.
'
'This was coded by Shockwave (C) 2002.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

open window 640,512

'Stars to calculate; (ns*4=amount of stars displayed)
'_________________________________________________________
ns=111 
window origin "cc"
dim x(ns),y(ns),z(ns)

'Create star positions;
'_________________________________________________________

for a=1 to ns
 x(a)=-3000+ran(2800)   :    y(a)=-3000+ran(2800) 
 z(a)=ran(10)
next a

'Start loop;
'_________________________________________________________
repeat
setdrawbuf dw
dw=1-dw
setdispbuf dw
clear window

'Do Stars;
'_________________________________________________________
for a=1 to ns
'Screen and size transformations;
'_________________________________________________________
 ty=y(a)/z(a)
 tx=x(a)/z(a)
 s=11-z(a)
'Precalculate size adds;
'_________________________________________________________
 xm=tx+s
 ym=ty+s
 fill rect tx,ty to xm,ym
'Invert And Positions for remaining screen quarters
'_________________________________________________________
 fill rect -tx,ty to -xm,ym
 fill rect tx,-ty to xm,-ym
 fill rect -tx,-ty to -xm,-ym
'Move star;
'_________________________________________________________
 z(a)=z(a)-.05
'If off screen make new position;
'_________________________________________________________
 if tx<-320 or ty<-256 then
  y(a)=-3000+ran(2800) 
  x(a)=-3000+ran(2800)
  z(a)=10
 fi
next a
until (1=2)



