Microsoft Small Basic

Program Listing: GVG321
SetupTurtle()
Show()
ClosedSquares()

Sub ClosedSquares
SquareX = 320
SquareY = 320
X = SquareX
Y = SquareY
MoveTo()
For i = 5 To 205 Step 10
PenUp()
Y = SquareY + i/2
X = SquareX - i/2
MoveTo()
TAngle = 0
PenDown()
For n = 1 To 4 Step 1
Distance = i
Move()
Angle = 90
Turn()
EndFor
EndFor
EndSub

Sub SetupTurtle
TurtleImg = ImageList.LoadImage("https://lh4.googleusercontent.com/7egtfNcvskFmexSJsw54u-ZBF-IG1Preyps2f-oyLO1YaaZLfHHUyeGVHfFEvowkoMYF6xD4lW7PHI_ikRU5YDDuB5ypj1iLbzNhx6qq1xyeC5-zNBE")
Turtle = Shapes.AddImage(TurtleImg)
Width = ImageList.GetWidthOfImage(TurtleImg)
Height = ImageList.GetHeightOfImage(TurtleImg)
PenDown()
X = GraphicsWindow.Width/2
Y = GraphicsWindow.Height/2
MoveTo()
Hide()
EndSub

Sub AfterClear
Turtle = Shapes.AddImage(TurtleImg)
MoveTo()
EndSub

Sub Turn
TAngle = TAngle+Angle
Shapes.Rotate(Turtle,TAngle)
EndSub

Sub Move
If PenDown Then
GraphicsWindow.DrawLine(X,Y,X+Math.Cos(Math.GetRadians(TAngle-90))*Distance,Y+Math.Sin(Math.GetRadians(TAngle-90))*Distance)
EndIf
X = X+Math.Cos(Math.GetRadians(TAngle-90))*Distance
Y = Y+Math.Sin(Math.GetRadians(TAngle-90))*Distance
MoveTo()
EndSub

Sub MoveTo
Shapes.Move(Turtle,X-Width/2,Y-Width/2)
EndSub

Sub Hide
Shapes.HideShape(Turtle)
EndSub

Sub Show
Shapes.ShowShape(Turtle)
EndSub

Sub PenDown
PenDown = "True"
EndSub

Sub PenUp
PenDown = "False"
EndSub