Click 'Run' to go.
Here we will see the basic commands within turtle graphics that aim and move the turtle. We will move the turtle forward and turn it left and right.
Here are our first three turtle commands:
fd - Means 'forward'. Follow this command with an expression, usually a number. That value represents how far the turtle should move forward.
Example: fd 5
The above command tells the turtle to move 5 units forward. It does not change the turtle's direction.
lt - Means 'left'. Follow this command with an expression, usually a number. That value represents the number of degrees that the turtle should spin toward its left.
Example: lt 90
The above tells the turtle to spin 90 degrees to its left. It does not move the turtle any distance.
rt - Means 'right'. Follow this command with an expression, usually a number. That value represents the number of degrees that the turtle should spin toward its right.
Example: rt 45
The above tells the turtle to spin 45 degrees to its right. This command does not move the turtle through a distance.
Although it is not shown in this demo, turtle graphics systems usually have a 'back' (or bk) command that makes the turtle move in reverse.
Be sure to understand that when the turtle turns, it does not move across the (x, y) graph. It spins to the left or right in place. Therefore, we say it rotates without translating.
Also, when the turtle moves forward or backward across the graph it does not change the direction in which it is pointing. So, we say it translates without rotating.
Combinations of forward and backward movements along with turns to the left and right can be used to make the turtle draw both simple and complicated diagrams.
Here's what a flowchart for this turtle demo looks like:
An imaginary computer language might put things this way:
fd(4); lt(90); fd(4); rt(90); fd(4);
Suggested next article: