The command setXY moves the turtle to a specific point on the (x, y) plane. For example, if you wanted to move the turtle to the coordinates (4, 5), then you would use this code:
If the pen is down, then the turtle will draw a line from its original location to the new one set by setXY. The turtle's heading does not change as it moves to its new spot.
You can make the turtle move horizontally with the command setX. This command is used to change only the x-coordinate of the turtle's location. The y-coordinate stays the same. If you wanted to move the turtle to a point where x = 6, then this code would do that:
The turtle will draw along its journey if the pen is down, and, again the turtle will not spin as it moves.
Use the command setY to move the turtle up or down. This command will change only the y-coordinate of the turtle's location. To move the turtle to a point where y = -4, use this code:
Again, there is not spinning during movement, and drawing only happens if the pen is down.
The loop code cycles only once. At its start the graph is prepared, and the turtle is sent to the origin with the home command. Then the turtle is moved about using setXY, setX, and setY.