Rem Project: Xmas Tree
Rem Created: 29/11/2005 13:07:09
 
Rem ***** Main Source File *****
 
Set Display Mode 800,600,32
Sync On
Sync Rate 0
AutoCam Off
Color Backdrop RGB(100,100,120)
Hide Mouse
Randomize Timer()
Gosub MakeTextures
Make Matrix 1,10000,10000,50,50
Prepare Matrix Texture 1,1001,1,1
Position Matrix 1,-5000,-400,-5000
Randomize Matrix 1,50
Update Matrix 1
Gosub MakeTree
Gosub Decorate
 
Position Camera 0,100,-700
Point Camera 0,0,0
XDist#=800.0: ZDist#=800.0
Do
  X# = WrapValue(X# + .05)
  Z# = WrapValue(Z# + .1)
  Position Camera newxvalue(Object Position X(1),X#,XDist#),  0,  newzvalue(Object Position Z(1),Z#,ZDist#)
  Point Camera 0,0,0
  Sync
Loop
 
MakeTree:
  Make Object Cylinder 100, 30
  Color Object 100,RGB(30,0,0):Scale Object 100,50,500,50: Position Object 100,0,-300,0
  Set Object 100,1,0,1,1,1,1,0
  For N=1 To 18
    Make Object Plain N, 800,600
    Texture Object N,1000
    YRotate Object N,WrapValue(N*20)
    Set Object N,1,1,1,0,0,0,0
    Set Object Smoothing N,100
  Next N
Return
 
Decorate:
  For N=1 To 9
    Make Object Sphere N+80, 20
    Set Object N+80,1,1,1,1,1,0,0
    R=Rnd(1)*255: G=Rnd(1)*255: B=Rnd(1)*255: If R=0 and G=0 and B=0 Then R=255
    Color Object N+80,RGB(R,G,B): Position Object N+80,0,150,0
    Set Object Emissive N+80,RGB(R/2,G/2,B/2)
    YRotate Object N+80,WrapValue(N*40-10)
    Move Object N+80,100
  Next N
  For N=1 To 9
    Make Object Sphere N+70, 20
    Set Object N+70, 1, 1, 1, 1, 1, 0, 0
    R=Rnd(1)*255: G=Rnd(1)*255: B=Rnd(1)*255: If R=0 and G=0 and B=0 Then R=255
    Color Object N+70,RGB(R,G,B): Position Object N+70,0,95,0
    Set Object Emissive N+70,RGB(R/2,G/2,B/2)
    YRotate Object N+70,WrapValue(N*40+10)
    Move Object N+70,115
  Next N
  For N=1 To 9
    Make Object Sphere N+19, 20
    Set Object N+19,1,1,1,1,1,0,0
    R=Rnd(1)*255: G=Rnd(1)*255: B=Rnd(1)*255: If R=0 and G=0 and B=0 Then R=255
    Color Object N+19,RGB(R,G,B): Position Object N+19,0,30,0
    Set Object Emissive N+19,RGB(R/2,G/2,B/2)
    YRotate Object N+19,WrapValue(N*40-10)
    Move Object N+19,140
  Next N
  For N=1 To 9
    Make Object Sphere N+30, 20
    Set Object N+30,1,1,1,1,1,0,0
    R=Rnd(1)*255: G=Rnd(1)*255: B=Rnd(1)*255: If R=0 and G=0 and B=0 Then R=255
    Color Object N+30,RGB(R,G,B): Position Object N+30,0,-45,0
    Set Object Emissive N+30,RGB(R/2,G/2,B/2)
    YRotate Object N+30,WrapValue(N*40+10)
    Move Object N+30,175
  Next N
  For N=1 To 9
    Make Object Sphere N+40, 20
    Set Object N+40,1,1,1,1,1,0,0
    R=Rnd(1)*255: G=Rnd(1)*255: B=Rnd(1)*255: If R=0 and G=0 and B=0 Then R=255
    Color Object N+40,RGB(R,G,B): Position Object N+40,0,-130,0
    Set Object Emissive N+40,RGB(R/2,G/2,B/2)
    YRotate Object N+40,WrapValue(N*40-10)
    Move Object N+40,205
  Next N
  For N=1 To 9
    Make Object Sphere N+50, 20
    Set Object N+50,1,1,1,1,1,0,0
    R=Rnd(1)*255: G=Rnd(1)*255: B=Rnd(1)*255: If R=0 and G=0 and B=0 Then R=255
    Color Object N+50,RGB(R,G,B): Position Object N+50,0,-225,0
    Set Object Emissive N+50,RGB(R/2,G/2,B/2)
    YRotate Object N+50,WrapValue(N*40+10)
    Move Object N+50,240
  Next N
  For N=1 To 9
    Make Object Sphere N+60, 20
    Set Object N+60,1,1,1,1,1,0,0
    R=Rnd(1)*255: G=Rnd(1)*255: B=Rnd(1)*255: If R=0 and G=0 and B=0 Then R=255
    Color Object N+60,RGB(R,G,B): Position Object N+60,0,-310,0
    Set Object Emissive N+60,RGB(R/2,G/2,B/2)
    YRotate Object N+60,WrapValue(N*40-10)
    Move Object N+60,240
  Next N
  For N=1 To 10
    Make Object Cylinder N+89,100
    R=N*15
    Texture Object N+89,1002:Scale Object N+89,(11-N)*40+R,(11-N)*40+R,(11-N)*40+R: Position Object N+89,0,(N*80)-330-(R*2),0
    Set Object N+89,1,1,0,1,1,1,0
    Set Object Emissive N+89,RGB(R/2,G/2,B/2)
    YRotate Object N+89,Rnd(360)
    ZRotate Object N+89,Rnd(40)-20
  Next N
Return
 
MakeTextures:
  Create Bitmap 1,800,600
  Rem Tree
  CLS RGB(0,50,0)
  For N=1 To 5000
    Ink RGB(0,Rnd(255),0),0
    X1=Rnd(520): Y1=Rnd(520)
    X2=X1+Rnd(20)-10
    Y2=Y1+Rnd(20)-10
    Line X1,Y1,X2,Y2
  Next N
  Ink RGB(255,255,255),0
  For N=1 To 5000
    X1=Rnd(520): Y1=Rnd(520)
    Box X1,Y1,X1+1,Y1+1
  Next N
  Gapy#=4: Gapx#=0: Slope#=1.0
  For N1 = 0 To 17
    Ink 0,0
    For Ny = Int(N1*Gapy#) To Int((N1+2)*Gapy#)
      Line 0,  Ny,  Int(250-Gapx#),  Ny
      Line 512,  Ny,  Int(260+Gapx#),  Ny
      Inc Gapx#,Slope#
    Next Ny
    Gapx#=0: Inc Gapy#,4: Inc Slope#,0.1
  Next N1
  Blur Bitmap 1,1
  Get Image 1000,0,2,512,514,0
  Rem Snow
  CLS RGB(255,255,255)
  For N=1 To 5000
    Col=Rnd(55)+200
    Ink RGB(Col,255,Col),0
    X1=Rnd(520): Y1=Rnd(520)
    Dot X1,Y1
    Circle X1,Y1,Rnd(10)
  Next N
  Blur Bitmap 1,4
  Get Image 1001,0,1,513,513,0
  Rem Garland
  CLS 0
  For N1= 1 To 1
    sine#=10: velocity#=0
    For X=0 To 512
      IF sine#>=0
        Dec velocity#,.02
      ELSE
        Inc velocity#,.02
      Endif
      Inc sine#,velocity#
      Ink RGB(255,255,255),0
      Line X,sine#+256,X+Rnd(20)-10,sine#+256+Rnd(20)-10
      Line X,sine#+256,X+Rnd(30)-15,sine#+256+Rnd(30)-15
      Line X,sine#+256,X+Rnd(40)-20,sine#+256+Rnd(40)-20
    Next X
  Next N1
  Get Image 1002,0,1,513,513,0
  Delete Bitmap 1
Return