turtle methods
Here is a nearly complete list of turtle methods. We have excluded the really dangerous ones that would require you to understand how Java draws stuff on displays. (Jython is written in Java).
The method names below are taken from the Java code that implements the JES media library. There are always an even number of words in parentheses in the pattern type/name, type/name. If there are two words in parentheses, the first is the TYPE of the variable and the second is a NAME for that formal parameter.
- E.g. setBodyColor(Color color) means that setBodyColor is a turtle method that takes a Color (that's a type of data) called "color". When you call it to change the body color of the turtle ted, you would say something like ted.setBodyColor(green) or ted.setBodyColor(makeColor(255, 0, 127)).
- E.g, turnToFace(Turtle turtle) is a method that makes the turtle in question face another Turtle called turtle. So to make ted face terry, you say ted.turnToFace(terry). Alternatively, there is another method with the same name: turnToFace(int x, int y). That turns the turtle in question to face a given location. So to make ted face the top left corner, you would say ted.turnToFace(0,0).
Some of the methods return a value. It should be obvious which (i.e. the "get..." and "is...." methods).
- E.g. getWidth() returns the width in pixels of a turtle, as in ted.getWidth()
- E.g. isVisible() returns 0 or 1 (false or true) depending on whether you have previously hidden the turtle.
getDistance(int x, int y)
turnToFace(SimpleTurtle turtle)
turnToFace(int x, int y)
getPicture()
setPicture(Picture pict)
getShellColor()
setShellColor(Color color)
getBodyColor()
setBodyColor(Color color)
setColor(Color color)
getWidth()
getHeight()
setWidth(int theWidth)
setHeight(int theHeight)
getXPos()
getYPos()
getPen()
setPen(Pen thePen)
setPenDown(boolean value)
penUp()
penDown()
getPenColor()
setPenColor(Color color)
setPenWidth(int width)
getPenWidth()
clearPath()
getHeading()
setHeading(double heading)
getName()
setName(String theName)
isVisible()
hide()
show()
forward() # By 100 pixels
forward(int pixels)
backward()
backward(int pixels)
moveTo(int x, int y)
turnLeft() # by 90
turnRight()
turn(int degrees)
drop(Picture dropPicture)
toString()
Links to this Page