Microsoft Small Basic

Program Listing: DPD960
'Published ID#
'Make the tortoise go as fast as possible --#26
Tortoise.SetSpeed(10)
'Turn the background black --#28
ProgramWindow.SetBackgroundColor(Colors.Black)
'The current branch length = 60 --#1.1
branch = 60
'CreateBranchColors (recipe below) --#6
CreateBranchColors()
'DrawBranch(recipe below) --#11
DrawBranch()

'------------- Recipe for CreateBranchColors --#5
Sub CreateBranchColors
' A 10 pixel long branch is lime --#21
branchColors[10] = Colors.Lime
' A 20 pixel long branch is forest green --#20
branchColors[20] = Colors.ForestGreen
' A 30 pixel long branch is dark green --#19
branchColors[30] = Colors.DarkGreen
' A 40 pixel long branch is olive --#18
branchColors[40] = Colors.Olive
' A 50 pixel long branch is sienna --#14
branchColors[50] = Colors.Sienna
' A 60 pixel long branch is saddle brown --#2.2
branchColors[60] = Colors.SaddleBrown
'------------- End of CreateBranchColors recipe --#5
endsub

'------------- Recipe for AdjustColor --#3
Sub AdjustColor
' Change the current color to the current BRANCH color for the current BRANCH length --#2.1
color = branchColors[branch]
' Change the color of the line the Tortoise draws to the current color --#2
Tortoise.SetPenColor(color)
'------------- End of AdjustColor recipe --#3
EndSub

'------------- Recipe for DrawBranch --#10
Sub DrawBranch
'If the current branch length is greater than zero --#17
If (branch > 0) then
' AdjustColor (recipe above) --#4
AdjustColor()
' Move the tortoise the length of the current branch --#1
Tortoise.Move(branch)
' DrawLowerBranches (recipe below) --#9
DrawLowerBranches()
' AdjustColor (recipe above) --#25
AdjustColor()
' Move the tortoise backward the length of the current branch --#23
Tortoise.Move(-branch)
endif
'------------- End of DrawBranch recipe --#10
endsub

'------------- Recipe for DrawLowerBranches --#8
Sub DrawLowerBranches
' Turn the Tortoise 30 degrees to the right --#7
Tortoise.Turn(30)
' DrawShorterBranch (recipe below) --#16
DrawShorterBranch()
' Turn the Tortoise 60 degrees to the left --#22
Tortoise.Turn(-60)
' DrawShorterBranch (recipe below) --#27
DrawShorterBranch()
' Turn the Tortoise 30 degrees to the right --#24
Tortoise.Turn(30)
'------------- End of DrawLowerBranches recipe --#8
EndSub

'------------- Recipe for DrawShorterBranch --#15
Sub DrawShorterBranch
' Decrease the length of the current branch by 10 pixels --#13
branch = branch - 10
' DrawBranch (recipe above) --#12
DrawBranch()
' Increase the length of the current branch by 10 pixels --#23
branch = branch + 10
'------------- End of DrawShorterBranch recipe --#15
EndSub