This article introduces Turtle in Microsoft Small Basic programming language.

In this article:

What is a Turtle?

Turtle comes from Logo programming language. It's called Turtle Graphics. Basically to turn and to move the turtle causes graphic shapes.  Details about Turtle history is written in a TechNet Wiki article.


This one-line code above shows the turtle like following picture.

Turtle Object

The Turtle object provides functionality do draw shapes like Logo programming language.


There are following four properties in Turtle object.

  • Angle - gets and sets the angle [degree] of the turtle.  The default value is 0.
  • Speed - gets and sets the speed (1 to 10) of the turtle.  The default value is 5.
  • X - gets and sets the X location of the turtle.  The default value is 320.
  • Y - gets and sets the Y location of the turtle.  The default value is 240.


There are following nine operations in Turtle object.  These operations don't return any values.

  • Hide() - hides the turtle.
  • Move(distance) - moves the turtle to a specified distance [pixel].
  • MoveTo(x, y) - turns and moves the turtle to the specified location.
  • PenDown() - sets the pen down.
  • PenUp() - sets the pen up.
  • Show() - shows the turtle.
  • Turn(angle) - turns the turtle by the specified angle [degree].
  • TurnLeft() - turns the turtle 90 degrees to the left.
  • TurnRight() - turns the turtle 90 degrees to the right.

Known Issues

There was a know issue that the turtle can't be shown if once hided.  This means that also the turtle graphics (trails) could be cleared only one time with GraphicsWindow.Clear().  But still remains an issue that there is no standard way to remove turtle trials only.  To remove turtle trails, there is a workaround which detail is written in a blog article.

Sample Code

' Turtle Object Code Sample
' Turtle.Show() operation
' Turtle.PenUp() and Turtle.MoveTo() operations
x = 320
y = 400
Turtle.MoveTo(x, y)
' Turtle.Angle property
Turtle.Angle = 45
' show properties
GraphicsWindow.BrushColor = "Gray"
GraphicsWindow.DrawText(10, 10, "Turtle.X=" + Turtle.X)
GraphicsWindow.DrawText(10, 30, "Turtle.Y=" + Turtle.Y)
GraphicsWindow.DrawText(10, 50, "Turtle.Angle=" + Turtle.Angle)
GraphicsWindow.DrawText(10, 70, "Turtle.Speed=" + Turtle.Speed)
' Turtle.PenDown() operation
GraphicsWindow.PenColor = "Red"
' Turtle.Move() operation
distance = 130
' Turtle.Turn() and Turtle.Move operations
angle = -90
' Turtle.TurnRight() and Turtle.Move operations
' Turtle.TurnLeft() and Turtle.Move operations
' Turtle.Hide() operation

Sample Programs

  • Another Turtle Graphics 0.5b (XVK119-3) - simple LOGO program
  • Brownian Motion (RFV485) - is a Brownian motion demo
  • Dragon and Turtle 0.6b (HMP803-5) - a fighting game
  • Hilbert Curve (CMN910) - draws a Hilbert curve
  • One Stroke Solver 0.2 (FST624-0) - solves one stroke path problem
  • Turtle Brick 0.1 (KDH145) - brick building with Turtle
  • Turtle Dodger 0.5b (QZN342-3) - simple game
  • Turtle Flash 0.3 (RBN002-1) - just shows flash animation
  • Turtle Maze 1.62 (PNC833-19) - maze game
  • Optical Illusion #01 (TQH071) - doesn't use Turtle object but image
  • Turtle Marionette (VTD423-0) - doesn't use Turtle object but image

Additional Resources

See Also

Other Languages