Learn to Code via Tutorials on Repl.it!

← Back to all posts
making a simple python game (part two: creating the player turtle)
gatorade322 (120)
1. #Create the player turtle
2. player = turtle.Turtle()
3. player.color("blue")
4. player.shape("triangle")
5. player.penup()
6. player.speed(0)

The player will have quite a few properties. First, we will need to declare the turtle. That is used with player = turtle.Turtle(). Notice the indent and capitalization. Player is the turtle. The first turtle (without the capital t), shows that it’s using the module “turtle”. The second one (with a capital T), is sort of the class “Turtle.” That is really all that you need to know about that line.
The second line (player.color(“blue”)), declares that the turtle's visual color is going to be blue. It will also draw a line that’s blue. Very simple.
The third line (player.shape(“triangle”)), makes it a triangle. That’s it.
The fourth line makes it not draw a line. We don’t want that.
The fifth line is to make it the fastest speed. Not the movement speed, but the animation speed. It’s pretty complicated. I can’t explain it that well. All I can say is that it’s the fastest speed the player moves on the screen.