17.9. The Turtle Stamp Procedure

You can change the shape of the turtle using the shape procedure. In the program below we set it to look more like a turtle.

A turtle can also stamp a copy of itself on the screen (turtle drawing area), and this will remain after the turtle has moved somewhere else. Do this with the stamp procedure. Stamping works even when the pen is up. You can ask the turtle to pick up the pen using the up procedure as shown below. When the pen is up the turtle will not draw a line when it moves.

Here is an example that shows off these new features.

Run the code to see what it draws.

The list of integers shown under the picture above is created by printing the range(5,60,2) result. This shows you the distances used to move the turtle forward each time through the for loop.

All except one of the shapes you see on the screen here are copies of the turtle shape created by stamp. But the program still only has one turtle instance — can you figure out which one is the real tess? (Hint: if you’re not sure, write a new line of code after the for loop to change tess’ color, or to put her pen down and draw a line, or to change her shape, etc.)

Mixed up program

The following program uses the stamp method to create a line of turtle shapes as shown below, but the lines are mixed up. The program should do all necessary set-up, create the turtle, set the shape to “turtle”, and pick up the pen. Then the turtle should repeat the following three times: go forward 50 pixels and leave a copy of the turtle at the current position. Drag the needed blocks of statements from the left column to the right column and put them in the right order with the correct indention. Click on Check to see if you are right. You will be told if any of the lines are in the wrong order or are the wrong blocks.

../_images/Turtle3Stamp.png

The following program uses the stamp method to create a circle of turtle shapes as shown to the left, but the lines are mixed up. The program should do all necessary set-up, create the turtle, set the shape to “turtle”, and pick up the pen. Then the turtle should repeat the following ten times: go forward 50 pixels, leave a copy of the turtle at the current position, reverse for 50 pixels, and then turn right 36 degrees. Drag the needed blocks of statements from the left column to the right column and put them in the right order with the correct indention. Click on Check to see if you are right. You will be told if any of the lines are in the wrong order or are the wrong blocks

../_images/TurtleCircle.png
You have attempted of activities on this page