Skip to content

Instantly share code, notes, and snippets.

@benfb
Last active October 10, 2015 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benfb/3762419 to your computer and use it in GitHub Desktop.
Save benfb/3762419 to your computer and use it in GitHub Desktop.
TurtleRunner
public class TurtleRunner
{
public static void main(String args[])
{
//create a world for your turtles
World turtleWorld = new World(600,800); //creates the turtle canvas
//create a picture
Picture turtle = new Picture("images.jpg"); //lets java know where the picture is
//create your first turtle
Turtle billy = new Turtle(turtleWorld); //creates billy at the middle of the canvas
Turtle bob = new Turtle(50, 50, turtleWorld); //creates bob at 50, 50
Turtle ben = new Turtle(100, 100, turtleWorld);
Turtle beatrice = new Turtle(200, 200, turtleWorld);
//move the turtled forward
billy.forward(200); //forward 200 pixels
billy.turn(45); //turn 45 degrees
//make a square
billy.clearPath(); //clears the turtle's path
billy.drawSquare(100); //calls the drawSquare method from the Turtle class
//billy.drop(turtle); //places the image "turtle" at billy's location
//make a triangle
billy.clearPath(); //clear's billy's path
billy.drawTriangle(50, 50, 50); //calls the drawTriangle method
//make a shape
billy.clearPath(); //clears path
billy.drawShape(3, 50); //draws a shape with three sides, 50 pixels each
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment