makeWorld
| makeWorld(width, height): width: the width for your new world height: the height for your new world Returns a new world, where you can put turtles. You can leave out width andheight. For example, these both work:
earth = makeWorld()
mars = makeWorld(500, 500)
|
makeTurtle
| makeTurtle(world): world: a world to put the turtle in Makes a turtle and returns itw = makeWorld(500, 500)
myTurtle = makeTurtle(w)
myTurtle.penUp()
myTurtle.moveTo(int(500/3), 250)
myTurtle.penDown()
for i in range(0, 360):
myTurtle.turn(1)
myTurtle.forward(3) |
forward
| turtle.forward(distance): turtle: the turtle to use distance: how far to go, in pixels Moves the turtle in the direction it's facingw = makeWorld(500, 500)
myTurtle = makeTurtle(w)
myTurtle.forward(100) |
backward
| turtle.backward(distance): turtle: the turtle to use distance: how far back to go Moves the turtle backwards (relative to where it's facing)w = makeWorld(500, 500)
myTurtle = makeTurtle(w)
myTurtle.backward(40) |
turnLeft
| turtle.turnLeft(): turtle: the turtle to use Turns the turtle left 90 degreesw = makeWorld(300, 200)
myTurtle = makeTurtle(w)
myTurtle.turnLeft()
myTurtle.forward(30) |
turnRight
| turtle.turnRight(): turtle: the turtle to use Turns the turtle right 90 degreesw = makeWorld(300, 200)
myTurtle = makeTurtle(w)
myTurtle.turnRight()
myTurtle.forward(30) |
turn
| turtle.turn(degrees): turtle: the turtle to use degrees: how many degrees to turn Turns the turtle; positive numbers of degrees mean turning to the turtle'sright.w = makeWorld(500, 500)
myTurtle = makeTurtle(w)
myTurtle.turn(30)
myTurtle.forward(100) |
moveTo
| turtle.moveTo(x, y): turtle: the turtle to use x: the X coordinate in the world y: the Y coordinate in the world Moves the turtle to the specified location. If the turtle's pen is down, it draws a line from its old position to the new one.w = makeWorld(500, 500)
myTurtle = makeTurtle(w)
myTurtle.moveTo(150, 150) |
turnToFace
| turtle.turnToFace(x, y): turtle: the turtle to use x: the X coordinate in the world y: the Y coordinate in the world Makes the turtle look towards (x, y)w = makeWorld(500, 500)
myTurtle = makeTurtle(w)
myTurtle.turn(63)
myTurtle.backward(40)
myTurtle.turnToFace(200, 100)
myTurtle.forward(300)
myTurtle.moveTo(150, 150) |
penUp
| turtle.penUp(): turtle: the turtle to use Makes the turtle pick up its pen, so doesn't leave a trail when it moves.w = makeWorld(300, 200)
myTurtle = makeTurtle(w)
myTurtle.penUp()
myTurtle.forward(50)
myTurtle.turnRight()
myTurtle.penDown()
myTurtle.forward(30) |
penDown
| turtle.penDown(): turtle: the turtle to use Makes the turtle put its pen on the world, so leaves a trail when it moves.w = makeWorld(300, 200)
myTurtle = makeTurtle(w)
myTurtle.penUp()
myTurtle.forward(50)
myTurtle.turnRight()
myTurtle.penDown()
myTurtle.forward(30) |
drop
| turtle.drop(picture): turtle: the turtle who will do the dropping picture: the picture that the turtle will drop The turtle drops a picture where it is currently sitting, rotated so that the top of the picture points where the turtle is facing. (this, for example, is one way to flip a picture upside-down)w = makeWorld()
myTurtle = makeTurtle(w)
pic = makePicture("adorable-kitten.jpg")
myTurtle.turn(180)
myTurtle.drop(pic) |
getTurtleList
| getTurtleList(world): world: the world to get the turtles from Returns a list of all turtles in the specified world. (You could, for example, tell each one to do something) |