Microsoft Small Basic

Program Listing: TNS358
'Challenge Recipe
'Draw a shape with user provided input.
'Use recursion to draw circle
'Teaches variables, graphicswindow, geometry, and division

'Write a line of text using the textwindow that asks "What is your name?"
TextWindow.Write("What is your name? ")

'Set the variable "name" to the name entered on the line above.
name=TextWindow.Read()

'Write a line of text using the textwindow that asks "How many sides do you want you shape to have?"
TextWindow.Write("How many sides do you want your shape to have? ")

'Set the variable "sides" to the amount of sides entered on the line above.
sides=TextWindow.Read()

'Set the variable "angle" to the number of sides needed to create closed shape (cirle, square, trianlge, pentagon, ect....).
'HINT: You can use division in the code. Example for a square would be (360/4)
angle=(360/sides)

'Write a line of text using the textwindow that asks "How long do you want each line to be in pixels? "
TextWindow.Write("How long do you want each line to be? ")

'Set the variable "length" to the size entered on the line above
length=TextWindow.Read()

'Write a line of text using the textwindow that asks "How fast do you want YOUR NAME to move (1-10)? "
TextWindow.Write("How fast do you want "+name+" the Tortoise to move? ")

'Set the variable "speed" to the speed entered on the line above.
speed=TextWindow.Read()

'Set the Tortoise speed to the variable "speed"
Tortoise.SetSpeed(speed)

'Call the sub-routine named "Go"
Go()

'Write a sub-routine named "Go"
Sub Go

'Test to see if "sum_angle" >= 360

If sum_angle>=360 Then

'If "sum_angle" is >= 360 then display to the graphics window a message saying you are done.....
GraphicsWindow.DrawText(100,100,"Well Done "+name+" the Tortoise!!!")

'If "sum_angle is NOT >= 360 then have the Tortoise Move=length and Turn=angle

Else

Tortoise.Move(length)

Tortoise.Turn(angle)

'Increase the value of sum_angle by the value of angle

sum_angle=angle+sum_angle

'Call the recursive sub-routine Go
Go()
EndIf
EndSub