'+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
'+               Space Rings by Gareth Bailey            +
'+                       July 2002                       +
'+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +

open window 640,512 REM
gosub setup


label loop 
  clear window 
  gosub rotate 
  gosub stars
  gosub drawcurve
  gosub msg
  gosub db
goto loop

label rotate
xr1=xr1+1
yr1=yr1+1
if xr1>360 xr1=xr1-360
if yr1>360 yr1=yr1-360

for b=1 to 2
 if b=1 xr=xr1
 if b=2 xr=0
 if b=1 yr=0
 if b=2 yr=yr1
 
  for a=1 to pts 
    x1=x(a,b)
    y1=y(a,b)
    z1=z(a,b)
    xx=x1
    yy=y1*cosi(xr)+z1*sine(xr)
    zz=z1*cosi(xr)-y1*sine(xr)
    y1=yy
    x1=xx*cosi(yr)-zz*sine(yr)
    z1=xx*sine(yr)+zz*cosi(yr)
    zz=z1
    xx=x1*cosi(zr)-y1*sine(zr)
    yy=x1*sine(zr)+y1*cosi(zr)

    dx(a,b)=xx
    dy(a,b)=yy:dz(a,b)=zz
    xx(a,b)=dx(a,b)/((dz(a,b)/focus)+1)+320
    yy(a,b)=dy(a,b)/((dz(a,b)/focus)+1)+256
  next a
next b
return

label stars
for a=1 to s
  sxx(a)=sx(a)/((sz(a)/focus)+1)+320
  syy(a)=sy(a)/((sz(a)/focus)+1)+256
  col=((500-sz(a))/4)
  setrgb 1,col,col,col
  fill rect sxx(a),syy(a)to sxx(a)+3,syy(a)+3
  sz(a)=sz(a)-15
  if sz(a)<-500 sz(a)=500
next a 
return

label drawcurve
for b=1 to 2
  new curve

  for a=1 to pts
    c=(dz(a,b)+size)
    if b=1 setrgb 1,.8*c,.4*c,1.3*c
    if b=2 setrgb 1,.6*c,1.2*c,1.4*c
    line to xx(a,b),yy(a,b)
  next a

  line to xx(1,b),yy(1,b)
next b
return

label msg
mc=mc-1

if mc<20 then
  mc= 200
  m = m+1
fi

if m>(dp-1) m=0

setrgb 1,.4*mc,.95*mc,1.50*mc
text 320,75,m$(m),"cc"
return

label db
setdispbuf draw
draw =1-draw
setdrawbuf draw
return

label setup
mc=200:pts=24:focus=500:size=100:s=30:read dp 
dim sx(s),sy(s),sz(s),sxx(s),syy(s)
dim x(pts,2),y(pts,2),z(pts,2),xx(pts,2),yy(pts,2) 
dim dx(pts,2),dy(pts,2),dz(pts,2),ang(pts,2) 
dim sine(361),cosi(361) 
dim m$(dp) 

for a=1 to s 
  sx(a)=-320+ran(640) 
  sy(a)=-256+ran(512) 
  sz(a)=-500+int(ran(1000)) 
next a 



for a=0to dp-1 
  read m$(a) 
next a 


for a=0 to 361
  cosi(a)=cos(a*(pi/180)) 
  sine(a)=sin(a*(pi/180)) 
next a 

for b=1 to 2 

  for a=1 to pts 
    ang(a,b)=(360/pts)*a
    x(a,b)=(cos(ang(a,b)*(pi/180))*size) REM
    y(a,b)=(sin(ang(a,b)*(pi/180))*size) REM
  next a
next b
return

DATA 6,"+ WELCOME TO +","+ SPACE RINGS +"
DATA "+ A DEMO +","+ BY JINX +"
DATA "+ DO YOU LIKE THE SPINNING RINGS?!? +"
DATA "+ I THINK THEY ARE COOL +"

