The turtle's home is the origin, point (0, 0). The command **home**
sends the turtle to the origin and aims it at a heading of 0 degrees. This
heading points the turtle directly right, or straight down the x-axis toward
increasing positive values.

The **home** command is useful for setting the initial state of
the turtle at the start of a turtle graphics drawing. The code for **
home** looks like this:

home();

The example program sends the turtle home and then moves it forward and backward.

The command **forward** moves the turtle a certain distance in the
direction in which it is aimed.

Usually, the turtle is set up to draw on the graph as it moves. When the
turtle draws, we say that 'its pen is down'. The turtle's pen is down by
default. So, by default it will draw when it is moved with the **
forward** command.

This is the code to move the turtle 7 units:

forward(7);

If the turtle was aimed up (90 degrees heading), then the turtle would draw a line segment 7 units long. The segment would stretch from the turtle's starting point to a point 7 units directly above the starting point. This would be a vertical line. We would imagine the turtle at the top of it, aimed up.

Code such as this:

home(); forward(6);

Would do the following:

- The command
**home**would place the turtle at (0, 0) and aim it right.- Aimed to the right is a heading of 0 degrees.
- The turtle is aimed down the x-axis toward positive numbers.

- The command
**forward**would move the turtle 6 units.- The turtle moves from (0, 0) to (6, 0).
- A line segment is drawn from (0, 0) to (6, 0).
- The pen is down by default.

- The turtle ends up at (6, 0), aimed right.

The command **back** works just like **forward**,
except it moves the turtle backward, as if it were a car in reverse.

* The turtle does not change its direction when it moves backward.*
It does not turn around and then go forward.

This code:

home(); back(6);

Would have the turtle end up at (-6, 0), aimed right. A line segment would be drawn from (0, 0) to (-6, 0).

The program sends the turtle home, then walks it forward down the x-axis a ways, then walks it backward over its forward path and then some. The turtle ends up on the negative x-axis, aimed right.

The turtle draws as it moves, but this may be a bit hard to see since the line segment is drawn directly over the x-axis. We need to learn how to turn the turtle so we can move it off of the x-axis. That is in the next tutorial.

Bounds:

Printer

Edit:
Runtime
View:
Starter
Suggestion

To runtime:

Storage:

Editor width: Normal Wide

To runtime:

Storage:

Editor width: Normal Wide

Custom Search

Name:

Domain:

Name

0

Name:

Name

0