First published on MSDN on Jan 31, 2015
Authored by Ed Price
Let’s take a look at where the Small Basic Turtle object came from!
Turtle graphics were based on turtle robots, which were used in programming. In 1948, Grey Walter created his first robots, named Elmer and Elsie. People often thought his robots looked and moved like tortoises.
Years later, in 1967, two MIT professors (in Cambridge, Massachusetts) invented their PDP 1 computer. Kids from schools connected to it from phone lines. They didn’t have monitors, so they wanted the kids to see robotics as the result of the programming. That led to the return of the turtle! Only this turtle was more like R2D2:
In order to program for this physical turtle, they created this concept of the display turtle as part of their Logo programming language:
(Logo comes from the Greek word, logos, which means “thought” or “word”. They created the Logo programming language to differentiate that the language is based on words, graphics, and logic, and not just on numbers like most of the contemporary programming languages of that time.)
Before long, most modern implementation of Logo Turtle Graphics began to show the cursor as an actual turtle:
And that even extended to the turtle robots as well:
Similar to the Small Basic turtle, the Logo turtle included commands for relative movement and turning.
Finally, here is what the Turtle looks like in Small Basic:
Here are the methods of the Turtle object in Small Basic:
- Gets or sets the X location of the turtle. Setting this property changes the turtle’s horizontal location instantly without leaving any trace or turning its head.
- Gets or sets the Y location of the turtle. Setting this property changes its vertical location without leaving any trace or turning it direction.
- Gets or sets the angle of the turtle. Setting this property turns the turtle to the new angle.
- Turns and moves the turtle to the new location. If the pen’s down, the turtle draws a line as it moves.
- Moves your turtle a number of steps in its current direction. If the distance is negative, the turtle moves backwards. If the pen’s down, your turtle draws a line as it moves!
- Turns your turtle by an angle (in degrees) from its current direction. If the angle’s positive, the turtle turns to its right (clockwise). If the angle’s negative, your turtle turns to its left (counterclockwise).
- Turns your turtle 90 degrees to its right.
- Turns the turtle 90 degrees to its left.
The Small Basic Turtle has taken on a new life in the community! For example...
Nonki puts his turtle to use in a classic shooter, called Turtle Dodger:
Here's a tweet for Turtle Dodger:
Have a turtle-tastic day!
- Ninja Ed