Set Display Mode 800,600,32
Sync On: Sync Rate 0: CLS 0: Sync
 
AutoCam Off
Backdrop On: Color Backdrop 0
Hide Mouse
Randomize Timer()
Set Camera Range 1.0,100000.0
Set Text Opaque
Set Ambient Light 100
 
Dim CosTable#(360)
Dim SinTable#(360)
Dim XPos#(50)
Dim YPos#(50)
Dim ZPos#(50)
 
For N=1 To 360
  CosTable#(N) = Cos(N)
  SinTable#(N) = Sin(N)
Next N
 
X=80: Y=80: XPos#=0: YPos#=0
NumRingSets = 20: StartZ = 4000: Gap = StartZ/NumRingSets
RingStartX = 0: RingStartY = 0: MidRing=2: Speed=20
ColourSections = 10
 
Gosub MakeTextures
 
For N=1 To NumRingSets
  ZPos#(N)=4000+N*200
  For A = 1 To 40
    Make Object Plain N*40+A,10,10
    If N=5 Or N=15
      Colour = 3
    Else
      If A=10 Or A=20 Or A=30 Or A=40
        Colour = 2
      Else
        Colour = 1
      Endif
    Endif
    Texture Object N*40+A,Colour
    Ghost Object On N*40+A
    x2 = CosTable#(a*9)*x - SinTable#(a*9)*y
    y2 = SinTable#(a*9)*y + CosTable#(a*9)*x
    Position Object N*40+A,x2,y2,ZPos#(N)
  Next A
Next N
 
Point Camera 0,0,0
 
Make Object Sphere 5001,1000
Scale Object 5001,10000,10000,10000
Texture Object 5001,4
Set Object 5001,1,1,0
 
CubeZ=40: CubeDir=20
MakeLimbCube(1000,10.0)
Position Object 1000,0,-10,CubeZ
Texture Limb 1000,1,5
Texture Limb 1000,2,5
Texture Limb 1000,3,5
Texture Limb 1000,4,5
Texture Limb 1000,5,5
Texture Limb 1000,6,5
 
Repeat
  MMx=MouseMoveX(): MMy=MouseMoveY: Mc=MouseClick(): Sc=ScanCode()
  For N=1 To NumRingSets: Rem Ring Sets
    ZPos#(N) = ZPos#(N)-Speed
    If ZPos#(N) <= 0: Rem Ring behind camera
      ZPos#(N) = StartZ
      Inc RingCounter
      If RingCounter = ColourSections
        RingCounter = 0
      Endif
    Endif
    For A=1 To 40: Rem Spheres per ring
      Position Object N*40+A,  Object Position X(N*40+A),  Object Position Y(N*40+A),  ZPos#(N)
    Next A
  Next N
  Rotate Object 1000,WrapValue(Object Angle X(1000)+1),WrapValue(Object Angle Y(1000)+1),WrapValue(Object Angle Z(1000)+1)
  ZRotate Camera WrapValue(Camera Angle Z()+1)
  ZRotate Object 5001, WrapValue(Camera Angle Z()+1)
  Inc CubeZ,CubeDir
  If CubeZ <= 40 Then CubeDir = 0-CubeDir
  If CubeZ >= 200 Then CubeDir = 0-CubeDir
  Position Object 5001,Object Position X(5001),Object Position Y(5001),CubeZ
  Sync
Until MMx<>0 or MMy<>0 Or Mc<>0 Or Sc<>0
End
 
 
MakeTextures:
  Create Bitmap 1,1024,768
  Rem Particle Red
  CLS 0: C=255
  For N=1 To 127
    Ink RGB(C,0,0),0
    Circle 127,127,N
    Circle 127,128,N
    Dec C,2
  Next N
  Get Image 1,0,0,256,256
 
  Rem Particle Yellow
  CLS 0: C=255
  For N=1 To 127
    Ink RGB(C,C,0),0
    Circle 127,127,N
    Circle 127,128,N
    Dec C,2
  Next N
  Get Image 2,0,0,256,256
 
  Rem Particle Blue
  CLS 0: C=255
  For N=1 To 127
    Ink RGB(0,0,C),0
    Circle 127,127,N
    Circle 127,128,N
    Dec C,2
  Next N
  Get Image 3,0,0,256,256
 
  Rem Stars
  CLS 0
  For N=1 To 2000
    Ink RGB(Rnd(200)+55,Rnd(100)+10,Rnd(100)+155),0
    Dot Rnd(512),Rnd(512)
  Next N
  Blur Bitmap 1,3
  For N=1 To 2000
    C=Rnd(200)+55
    Ink RGB(C,C,C),0
    Dot Rnd(512),Rnd(512)
  Next N
  Get Image 4,0,0,512,512: Rem <<< Add ,1 on the end when running in DBPro
 
  CLS 0
  For N=0 To 255 Step 2
    Ink RGB(0,N,0),0
    Line 0,0,255,N
  Next N
  For N=255 To 0 Step -2
    Ink RGB(0,N,0),0
    Line 255,0,N,255
  Next N
  For N=255 To 0 Step -2
    Ink RGB(0,N,0),0
    Line 255,255,0,N
  Next N
  For N=0 To 255 Step 2
    Ink RGB(0,N,0),0
    Line 0,255,N,0
  Next N
  Get Image 5,0,0,256,256
  Set Current Bitmap 0
  Delete Bitmap 1
Return
 
Function MakeLimbCube(ObjNum,Size#)
  Offset#=Size#/2.0: MeshNum=2000: PlainNum=2000
  Make Object Cube ObjNum,Size#
  Make Object Plain PlainNum,Size#,Size#
  Make Mesh From Object MeshNum,PlainNum
  ADD LIMB ObjNum,1,2000: Offset Limb ObjNum,1,0,0,0.0-Offset#: Rem Cube Side 1 (Front)
  ADD LIMB ObjNum,2,2000: Rotate Limb ObjNum,2,0,90,0: Offset Limb ObjNum,2,0.0-Offset#,0,0: Rem Cube Side 2 (Left)
  ADD LIMB ObjNum,3,2000: Rotate Limb ObjNum,3,0,180,0: Offset Limb ObjNum,3,0,0,Offset#:  Rem Cube Side 3 (Back)
  ADD LIMB ObjNum,4,2000: Rotate Limb ObjNum,4,0,270,0: Offset Limb ObjNum,4,Offset#,0,0:  Rem Cube Side 4 (Right)
  ADD LIMB ObjNum,5,2000: Rotate Limb ObjNum,5,270,0,0: Offset Limb ObjNum,5,0,0.0-Offset#,0: Rem Cube Side 5 (Bottom)
  ADD LIMB ObjNum,6,2000: Rotate Limb ObjNum,6,90,0,0: Offset Limb ObjNum,6,0,Offset#,0: Rem Cube Side 6 (Top)
  Delete Mesh MeshNum
  Delete Object PlainNum
  Hide Limb ObjNum,0
EndFunction