Microsoft Small Basic

Program Listing:
Embed this in your website
'Holiday Recipe - Enjoy!
'Set the background to the color of Snow
ProgramWindow.SetBackgroundColor(Colors.Snow)
'Make the tortoise move as fast as possible
Tortoise.SetSpeed(10)
' Tell the program window to call Click (recipe below) when the mouse is clicked
ProgramWindow.MouseClicked = Click

'------------- Recipe for Click
Sub Click
  ' If the left mouse button is down
  If Mouse.IsLeftButtonDown  Then
    ' DrawTree(recipe below)
    DrawTree()
    ' Otherwise,
  Else
    ' DrawMerryChristmas(recipe below)
    DrawMerryChristmas()
  EndIf
EndSub
'------------- End of Click recipe


'------------- Recipe for DrawMerryChristmas
Sub DrawMerryChristmas
  ' Play the music for Jingle Bells Hint:"EEEP4EEEP4EGCDL1E"
  Sound.PlayMusic("EEEP4EEEP4EGCDL1E")
  ' Set the font to be 48pt
  CurrentFont.SetSize(48)
  ' set the color of the font to red
  CurrentFont.SetColor("Red")
  ' Write "Merry Christmas" on the screen at position 150, 150
  ProgramWindow.DrawText("Merry Christmas", 150,150)
EndSub
'------------- End of DrawMerryChristmas recipe

'------------- Recipe for DrawTree
Sub DrawTree
  ' DrawTreeTop(recipe below)
  DrawTreeTop()
  ' DrawTreeBody(recipe below)
  DrawTreeBody()
  ' DrawTreeTrunk(recipe below)
  DrawTreeTrunk()
EndSub
'------------- End of DrawTree recipe


'------------- Recipe for DrawTreeTop
Sub DrawTreeTop
  ' The current distance is distance of the mouse from the center of the window
  distance = Math.Abs(ProgramWindow.GetWindowWidth()/2 - ProgramWindow.GetMouseX())
  ' The current length is a 20th of the current distance
  length = distance / 20
  ' Change the X position of tortoise to where the mouse is
  Tortoise.SetX(ProgramWindow.GetMouseX())
  ' Change the Y position of tortoise to where the mouse is
  Tortoise.SetY(ProgramWindow.GetMouseY())
  ' Change the tortoise so that it is pointing straight down
  Tortoise.SetAngle(180)
  ' Change the color of the line the tortoise draws to forest green
  Tortoise.SetPenColor(Colors.ForestGreen)
  ' Change the width of the line to the current length divided by 5
  Tortoise.SetPenWidth(length / 5)
  ' Move the tortoise half the current length
  Tortoise.Move(length / 2)
  ' Hide the tortoise
  Turtle.Hide()
  ' Turn the tortoise to the left (90 degrees)
  Tortoise.TurnLeft()
  ' Move the tortoise half of the current length
  Tortoise.Move(length / 2)
EndSub
'------------- End of DrawTreeTop recipe


'------------- Recipe for DrawTreeBody
Sub DrawTreeBody
  ' The current trun amount is 175
  turnAmount = 175
  ' The current scale is 1.1
  scale = 1.1
  ' Do the following 11 times
  For i = 1 To 11
    ' Turn the tortoise the current turn amount to the right
    Tortoise.Turn(turnAmount)
    ' Set the current length to the current length times the current scale
    length = length * scale
    ' Move the tortoise the current length
    Tortoise.Move(length)
    ' Turn the tortoise the current turn amount to the left
    Tortoise.Turn(-turnAmount)
    ' Set the current length to the current length times the current scale

    length = length * scale
    ' Move the tortoise the current length
    Tortoise.Move(length)
    ' Decrease the current turn amount by 1
    turnAmount = turnAmount - 1
    ' Repeat
  EndFor
EndSub
'------------- End of DrawTreeBody recipe


'------------- Recipe for DrawTreeTrunk
Sub DrawTreeTrunk
  ' Turn the tortoise 180 degrees to the right
  Tortoise.Turn(180)
  ' Move the tortoise half of the current length
  Tortoise.Move(length / 2)
  ' Change the tortoise so that it is pointing straight down
  Tortoise.SetAngle(180)
  ' Change the width of the line to the current length divided by 10
  Tortoise.SetPenWidth(length / 10)
  ' Change the color of the line the tortoise draws to brown
  Tortoise.SetPenColor(Colors.Brown)
  ' Move the tortoise a quarter the current length
  Tortoise.Move(length / 4)
EndSub
'------------- End of DrawTreeTrunk recipe
Copyright (c) Microsoft Corporation. All rights reserved.