Last active
October 10, 2015 22:38
-
-
Save benfb/3762419 to your computer and use it in GitHub Desktop.
TurtleRunner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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