Turtles & the Graphics Window
As a change to working with the TextWindow, this page introduces the Graphics Window and Turtle Graphics. You may be familiar with a programming language called Logo or you my have used turtle type graphics programs in the past. This page introduces the Small Basic Turtle.
As with all Small Basic programming the Turtle is an object that has Properties and Methods that make it possible to find out about it and make it do things. See the ‘Properties ‘ and ‘Methods’ for the Turtle in the column on the right (below if using a small screen).
To make the Turtle visible (and make the GraphicsWindow visible as well), use the command Turtle.Show(). This displays the Turtle in the middle of the graphics window. When starting off, your Turtle points up the screen – this is direction 0. To move forward, the command is:
Turtle.Move( distance )
The Small Basic Graphics Window is 624 pixels wide and 441 pixels tall (but some of this is taken up with the title bar. To keep the turtle on screen you need to move no more than 200 ‘steps’ upwards or downwards from his starting position, and no more than 300 ‘steps’ horizontally.
To turn the turtle, there are two methods – Turtle.TurnLeft() & Turtle.TurnRight() that turn the turtle through 90 degrees left or right; and the command Turtle.Turn( angle ) which uses angles.
Finally, you can move the Turtle to a now position using the command Turtle.MoveTo( X, Y ).
The Turtle Pen
Normally, the Turtle’s pen is down so that it draws lines as it moves. If you want to move to a new location without drawing lines then use the Turtle command Turtle.PenUp(). Conversely, to start drawing again, use Turtle.PenDown().