CSE 113 - Spring 2009 - Banner
UB -
University at Buffalo, The State University of New York Computer Science and Engineering
  • CSE 113 - Spring 2009
CSE 113 - Spring 2009 - Navigation
CSE 113 - Spring 2009 - Announcements

Turtle Methods

CSE 113 - Spring 2009 - Announcements

Here is a listing of methods that you can use when working with a Turtle object.

backward() Moves the turtle backwards 100 pixels.
backward(int pixels) Moves the turtle backwards the number of pixels passed in as an argument.
forward() Moves the turtle forward 100 pixels.
forward(int pixels) Moves the turtle forward the number of pixels passed in as an argument.
getHeading() Returns an int representing the heading of the turtle in terms of degrees.
hide() Makes the turtle body disappear from the screen, but does impact whether the pen is up or down.
moveTo(int x, int y) Move the turtle to the x and y coordinate passed in as an argument.
penDown() Put down the pen so that the turtle draws lines when it moves.
penUp() Pick up the pen so that the turtle does not draw lines when it moves.
setColor(java.awt.Color color) Sets the color of the turtle's body as well as the pen color.
setHeading(int degrees) Set the heading of the turtle based on the integer (degrees) passed in as an argument.
setPenColor(java.awt.Color color) Set the color of the pen of the turtle so that lines will be drawn in that specific color.
setPenWidth(int pixels) Set the width of the line the pen will draw in terms of pixels.
show() Makes the turtle body appear on the screen, but does not impact whether the pen is up or down.
turn(int degrees) Turns the turtle a specified number of degrees relative to the turtle's current position.
turnLeft() Turn the turtle 90 degrees to the left.
turnRight() Turn the turtle 90 degrees to the right.
turnToFace(int x, int y) Turn the turtle so it faces the point (x,y).
turnToFace(Turtle other) Turn the turtle so that it faces the turtle passed in as an argument.

 

CSE 113 - Spring 2009 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@cse.buffalo.edu | 130 Bell Hall | (716)645-3180 x 161