Tina’s Secrets¶
You might think you know a lot about Tina, but Tina actually has a lot of secrets. However, they are not very secret, because someone wrote them all down, in the Python Turtle Documentation.
If you want to know everything that Tina can do, you should read the documentation, but here are some of the most interesting things, with links to parts of the documentation.
Circles¶
See the documentation for the .circle()
function.
The .circle()
function can make a lot of diferent shapes, because it doesn’t
really draw a circle; it draws a polygon with a lot of sides and a hecatontagon
( thats a shape with 100 sides, obviously! ) looks a lot like a circle. You can
set the number of sides with the steps=
parameters. You can also set how far
Tina moves around the circle with the extent=
parameter.
With steps=6
you can draw a hexagon:
And with extent=180
you can draw a half circle:
You can use both steps
and extent
at the same time, to make a lot of different shapes. Try something
like tina.circle(130, steps=3, extent=180)
to see what happens.
( Hmmm … does steps have to be a whole number? What would a decimal number of steps, like 1.4, do? )
Heading¶
You can turn Tina with .left()
and .right()
, but you can also set the direction that Tina is facing with the .setheading()
function. The half circle we did above could have been a smile, if we use .setheading(90)
before drawing the circle.
Towards¶
The .towards()
function can be used to get the angle that Tina needs to turn to be facing another turtle. This can be useful if you want to make Tina follow another turtle.
Clicks and Keys¶
You can use the .onclick()
function to make Tina do something when you click on the screen. You can also use the .onkey()
function to make Tina do something when you press a key.
Here is a program that makes Tina move towards the place you click on the screen:
Here is an example of using .onkey()
to make Tina move with the arrow keys:
Run Away from Tony!¶
This program will make Tony follow Tina around the screen. You can use the arrow keys to move Tina, and Tony will try to follow her. The left and right arrows will turn Tina, and the up arrow will make her move forward. The down arrow will make her turn around.