# Microsoft Small Basic

Program Listing:
' Challenge of the month December 2012 by NaochanON
' Draw a Christmas tree

GUI()

While "true"
showstarH2()
Program.Delay(1000)
showstarH1()
Program.Delay(1000)
Program.Delay(1000)
showstarV2()
Program.Delay(1000)
showstarV1()
Program.Delay(1000)
endwhile

Sub snowing
NN=NN+1
Shapes.Move(snow1[NN],Math.GetRandomNumber(1000),-(100+Math.GetRandomNumber(300)))
Shapes.Move(snow2[NN],Math.GetRandomNumber(1000),-(100+Math.GetRandomNumber(300)))
ZM=(5+Math.GetRandomNumber(20))/10
Shapes.Zoom(snow1[NN],ZM,ZM)
Shapes.Zoom(snow2[NN],ZM,ZM)
Shapes.Animate(snow1[NN],Shapes.GetLeft(snow1[NN]),700-Math.GetRandomNumber(250),2000+Math.GetRandomNumber(2000))
Shapes.Animate(snow2[NN],Shapes.GetLeft(snow2[NN]),700-Math.GetRandomNumber(150),2000+Math.GetRandomNumber(2000))
If NN>SN Then
NN=0
EndIf
EndSub

Sub showstarH1
For i=pitch To 1 Step -1
For j=1 To 20
For k=1 to M
Shapes.SetOpacity(star1[K][j][i],100)
Shapes.SetOpacity(star2[K][j][i],0)
EndFor
EndFor
snowing()
EndFor
EndSub

Sub showstarH2
For i=1 To pitch
For j=1 To 20
For k=1 to M
Shapes.SetOpacity(star1[K][j][i],0)
Shapes.SetOpacity(star2[K][j][i],100)
EndFor
EndFor
snowing()
EndFor
EndSub

Sub showstarV1
For j=20 To 1 Step -1
For i=1 To pitch
For k=1 to M
Shapes.SetOpacity(star1[K][j][i],100)
Shapes.SetOpacity(star2[K][j][i],0)
EndFor
EndFor
snowing()
EndFor
EndSub

Sub showstarV2
For k=1 to M
For j=1 To 20
For i=1 To pitch
Shapes.SetOpacity(star1[K][j][i],0)
Shapes.SetOpacity(star2[K][j][i],100)
EndFor
EndFor
snowing()
EndFor
EndSub

For i=1 To pitch
For j=1 To 20
For k=1 to M
PCNT=2-Math.GetRandomNumber(2)     ' 1 or 0
Shapes.SetOpacity(star1[K][j][i],100*PCNT)
Shapes.SetOpacity(star2[K][j][i],100*(1-PCNT))
EndFor
EndFor
snowing()
EndFor
EndSub

Sub GUI
GraphicsWindow.Hide()
GraphicsWindow.Width=1000
GraphicsWindow.Height=700
GraphicsWindow.Top=10
GraphicsWindow.Left=50
GraphicsWindow.BackgroundColor="Black"
GraphicsWindow.BrushColor="Lightcyan"
GraphicsWindow.PenColor="Lightcyan"
'-------------------- Snow back -----------------------------------
SN=1000
For L=1 To SN
Shapes.Move(snow1[L],100,-100)
endfor
'-------------------------------------------------------------------------
M=4
For k=1 To M
'-------------------- Position -----------------------------------
X0=30 +(150+Math.GetRandomNumber(100))*(k-1)  ' left position
Top=20+Math.GetRandomNumber(120)              ' tree top y-position
Xw=200 +Math.GetRandomNumber(50)              ' tree width
Height=300+Math.GetRandomNumber(100)          ' tree height
XC=Xw/2+X0                                    ' tree top x-position 8center)
Y0=Top+Height                                 ' tree bottom
Pitch=12                                      ' light number
'-------------------- Tree ---------------------------------------
Shapes.Move(tree1[K],xc-30+3,top)
GraphicsWindow.BrushColor="Darkgreen"
GraphicsWindow.PenColor="Darkgreen"
Shapes.Move(tree2[K],x0+3,top)
'-------------------- star Light ---------------------------------------
For j=1 To pitch
For i=1 To pitch
y=Y0-(height/Pitch)*i
dx0=Xw/Pitch*(j-1)
x=x0+dx0+((Xw-2*dx0)/2/Pitch)*i
GraphicsWindow.BrushColor="Yellow"
GraphicsWindow.PenColor="yellow"
GraphicsWindow.BrushColor="cyan"
GraphicsWindow.PenColor="cyan"
Shapes.Move(star1[K][j][i],x,y)
Shapes.Move(star2[K][j][i],x,y)
Shapes.SetOpacity(star2[K][j][i],0)
EndFor
EndFor
'-------------------------------------------------------------------------
endfor
'-------------------- Snow Front -----------------------------------
GraphicsWindow.BrushColor="Lightcyan"
GraphicsWindow.PenColor="Lightcyan"
For L=1 To SN