HolidayCard() {
   tortoiseWindow = Tortoise.getBackgroundWindow();
   tortoiseWindow.addMouseListener(this);
   Tortoise.show();
   Tortoise.setSpeed(10);
   drawGreetingAndSing();
 }
 private static void drawStairRoof() {
   Tortoise.turn(90);
   Tortoise.move(30);
   Tortoise.turn(90);
   Tortoise.move(30);
   Tortoise.turn(90);
 }
 private static void drawPointRoof() {
   Tortoise.turn(45);
   Tortoise.move(10);
   Tortoise.turn(90);
   Tortoise.move(10);
   Tortoise.turn(45);
   // Tortoise.move(130);
 }
 void drawTree() {
   drawStar();
   drawTreeBody();
   drawTreeTrunk();
   treeWidth = 15;
   Tortoise.setAngle(0);
   Tortoise.setPenWidth(treeWidth / 5);
 }
 public static void drawLowerBranches(int branchLength) {
   Tortoise.turn(30);
   drawShorterBranches(branchLength);
   Tortoise.turn(-60);
   drawShorterBranches(branchLength);
   Tortoise.turn(30);
   adjustColor(branchLength);
   Tortoise.move(-branchLength);
 }
Exemplo n.º 6
0
  void drawStar() {
    // * Optional: Draw a red star on top of the tree. Hint: 144 degrees makes a star.
    Tortoise.setPenColor(Colors.Reds.IndianRed);
    for (int i = 0; i < 5; i++) {

      Tortoise.move(15);
      Tortoise.turn(144);
    }
  }
 private static void drawhousewithSlantyRoof(int height) {
   Tortoise.setPenColor(PenColors.Grays.LightGray);
   Tortoise.move(height);
   drawSlantyRoof();
   // Tortoise.move(120);
   Tortoise.turn(-90);
   Tortoise.move(20);
   Tortoise.turn(-90);
 }
  private void go() {

    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this);

    Paintable backgroundImage = new ImageBackground("http://s30.postimg.org/oi69jth7l/fetch1.jpg");

    Tortoise.getBackgroundWindow().addPaintable(backgroundImage);

    Tortoise.penUp();
  }
 public static void main(String[] args) {
   Tortoise.setSpeed(10);
   Tortoise.setX(200);
   int height = 60;
   // drawhousewithFlatRoof(height);
   drawhousewithSlantyRoof(140);
   drawhousewithFlatRoof(110);
   // drawhousewithStairRoof(120);
   drawhousewithPointRoof(130);
 }
  void drawStar() {
    // * Optional: Draw a red star on top of the tree. Hint: 144 degrees makes a star.
    Tortoise.setAnimal(Animals.Unicorn);
    for (int i = 0; i < 5; i++) {

      Tortoise.setPenColor(Colors.Reds.OrangeRed);
      Tortoise.setSpeed(10);
      Tortoise.move(20);
      Tortoise.turn(144);
    }
  }
Exemplo n.º 11
0
  /* 2. When the mouse is clicked draw a tree at that position. */
  public void mouseClicked(MouseEvent mouseEvent) {
    System.out.println("mouse clicked!");

    int mouseX = mouseEvent.getX();
    int mouseY = mouseEvent.getY();

    // Set the X position of the Tortoise to the X position of the mouse
    Tortoise.setX(mouseX);
    Tortoise.setY(mouseY);
    drawTree();
  }
Exemplo n.º 12
0
 void drawTreeTrunk() {
   // 1. Move the tortoise half the width of the tree
   Tortoise.move(treeWidth / 2);
   // 2. Change the tortoise so that it is pointing straight down
   Tortoise.turn(90);
   // 4. Set the pen width to the tree width divided by 10
   Tortoise.setPenWidth(treeWidth / 10);
   // 5. Change the color of the line the tortoise draws to brown
   Tortoise.setPenColor(Colors.Browns.Chocolate);
   // 3. Move the tortoise a quarter the tree width
   Tortoise.move(treeWidth / 4);
 }
 public static void drawBranch(int branchLength) {
   if (branchLength > 0) {
     adjustColor(branchLength);
     Tortoise.move(branchLength);
     drawLowerBranches(branchLength);
   }
 }
 public static void adjustColor(int branchLength) {
   HashMap<Integer, Color> colors = new HashMap<Integer, Color>();
   colors.put(30, PenColors.Greens.Olive);
   colors.put(40, PenColors.Browns.Sienna);
   colors.put(50, PenColors.Browns.SaddleBrown);
   Tortoise.setPenColor(colors.get(branchLength));
 }
Exemplo n.º 15
0
  /* 1. Paste your methods from the Christmas Tree Recipe here. */
  void drawTreeBody() {
    // 8. Change the color of the line the tortoise draws to forest green
    Tortoise.setSpeed(10);
    Tortoise.setPenColor(Colors.Greens.Chartreuse);

    // 1. Make a variable for turnAmount and set it to 175
    int turnAmount = 175;
    // 2. Start the Tortoise facing to the right
    Tortoise.turn(90);
    // 5. Repeat steps 3 through 11, 11 times
    for (int i = 0; i < 11; i++) {
      // 3. Move the tortoise the width of the tree
      Tortoise.move(treeWidth);
      // 4. Turn the tortoise the current turnAmount to the right
      Tortoise.turn(turnAmount);
      // 6. Set the treeWidth to the current treeWidth times the scale
      treeWidth = treeWidth * scale;
      // 7. Move the tortoise the width of a tree again
      Tortoise.move(treeWidth);
      // 9. Turn the tortoise the current turn amount to the LEFT
      Tortoise.turn(-turnAmount);
      // 10. Set the treeWidth to the current treeWidth times the scale again
      treeWidth = treeWidth * scale;
      // 11. Decrease turnAmount by 1
      turnAmount--;
    }
  }
Exemplo n.º 16
0
  private void spaceBarWasPressed() {

    int tortoiseLocationX = Tortoise.getX();

    int tortoiseLocationY = Tortoise.getY();

    System.out.println(tortoiseLocationX);

    System.out.println(tortoiseLocationY);

    clue.findTheGirl(tortoiseLocationX, tortoiseLocationY);

    clue.findTheDino(tortoiseLocationX, tortoiseLocationY);

    clue.findTheBirds(tortoiseLocationX, tortoiseLocationY);

    clue.findTheT(tortoiseLocationX, tortoiseLocationY);
  }
 /**
  * Makes a cool shape fast <div><b>Example: </b> {@code tortoise.drawShape(6,PenColors.Reds.Red,
  * 50, 20)}</div>
  *
  * @param sides the number of sides
  * @param color a snazzy line color
  * @param length the bigger the better
  * @param width make a thick line - it's cool
  */
 public static void drawShape(int sides, Color color, int length, int width) {
   Tortoise.show();
   Tortoise.setSpeed(7);
   Tortoise.getBackgroundWindow().setBackground(PenColors.Yellows.Goldenrod);
   new Text("TKP Java - Make Some Shapes!")
       .setTopLeft(225, 50)
       .addTo(Tortoise.getBackgroundWindow());
   for (int i = 0; i < sides; i++) {
     Tortoise.setPenColor(color);
     Tortoise.setPenWidth(width);
     Tortoise.move(length);
     Tortoise.turn(360 / sides);
   }
   VirtualProctor.setClassName("Grace Hopper's Class");
   VirtualProctor.setName("Jean Bartik");
 }
 private static void drawhousewithPointRoof(int height) {
   Tortoise.setPenColor(PenColors.Grays.LightGray);
   Tortoise.move(height);
   drawPointRoof();
   Tortoise.turn(360);
   Tortoise.move(130);
   Tortoise.turn(-90);
   Tortoise.move(10);
 }
 public static void main(String[] args) {
   Tortoise.show();
   Tortoise.getBackgroundWindow().setBackground(Grays.Black);
   Tortoise.setPenWidth(20);
   Tortoise.setSpeed(10);
   for (int i = 55; i < 999999999; i++) {
     Tortoise.setPenColor(PenColors.getRandomColor());
     length = length + 1;
     drawTriangle();
     Tortoise.turn(1000000000 / 20000);
   }
 }
 public static void main(String[] args) {
   Tortoise.setSpeed(10);
   Tortoise.getBackgroundWindow().setBackground(PenColors.Yellows.Goldenrod);
   int branchLength = 65;
   Tortoise.setX(175);
   Tortoise.setY(350);
   drawBranch(branchLength);
   drawBranch(branchLength - 1);
   Tortoise.setX(450);
   Tortoise.setY(350);
   drawBranch(branchLength);
   drawBranch(branchLength - 1);
 }
  void drawTreeTrunk() {
    // 1. Move the tortoise half the width of the tree
    Tortoise.setAnimal(Animals.Spider);
    Tortoise.move(treeWidth / 2);

    // 2. Change the tortoise so that it is pointing straight down
    Tortoise.setAngle(180);

    // 4. Set the pen width to the tree width divided by 10
    Tortoise.setPenWidth(treeWidth / 10);

    // 5. Change the color of the line the tortoise draws to brown
    Tortoise.setPenColor(Colors.Browns.DarkGoldenrod);

    // 3. Move the tortoise a quarter the tree width
    Tortoise.move(treeWidth / 4);
  }
Exemplo n.º 22
0
  public static void main(String[] args) {

    int turn = 90;

    Tortoise.move(200);
    Tortoise.turn(turn);
    Tortoise.move(100);
    Tortoise.turn(turn);
    Tortoise.move(200);
    Tortoise.turn(turn);
    Tortoise.move(200);
    Tortoise.turn(turn);
    Tortoise.move(200);
    Tortoise.turn(turn);
    Tortoise.move(200);
    Tortoise.turn(turn);
    Tortoise.move(100);
    Tortoise.turn(turn);
    Tortoise.move(200);
  }
 @Test
 public void getTheWindow() throws Exception {
   Tortoise.___().setCursor(Cursor.CROSSHAIR_CURSOR);
   Assert.assertEquals(getCursor(), Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
 }
 private static void drawhousewithStairRoof(int height) {
   Tortoise.setPenColor(PenColors.Grays.LightGray);
   Tortoise.move(height);
   drawStairRoof();
 }
 //  Step 1: SELECT the method name (changeThePointerToAHand on line 27), then click the Run Button
 //            Keyboard shortcut to run ->  PC: Ctrl+F11 or Mac: Command+fn+F11
 //  Step 2: READ the name of the method that failed
 //  Step 3: FILL IN the blank (___) to make that method pass
 //  Step 4: SAY at least one thing you just learned
 //  Step 5: GO to the next method
 //  IMPORTANT - Do NOT change anything except the blank (___)//
 //
 @Test
 public void changeThePointerToAHand() throws Exception {
   Tortoise.getBackgroundWindow().___();
   Assert.assertEquals(getCursor(), Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
 }
 public static void drawTortoise() {
   Tortoise.show();
   Tortoise.setSpeed(9);
   Tortoise.getBackgroundWindow().setBackground(PenColors.Greens.DarkSeaGreen);
   new Text("TKP Java - It's the Tortoise!")
       .setTopLeft(200, 75)
       .addTo(Tortoise.getBackgroundWindow());
   Tortoise.setPenColor(PenColors.Greens.Green);
   Tortoise.setPenWidth(3);
   makeTortoiseBody();
   Tortoise.setPenColor(PenColors.Browns.Brown);
   Tortoise.turn(-65);
   Tortoise.makeTortoiseLeg();
   Tortoise.turn(90);
   Tortoise.move(150);
   Tortoise.turn(-90);
   Tortoise.makeTortoiseLeg();
 }
 private static void drawSlantyRoof() {
   Tortoise.turn(45);
   Tortoise.move(30);
   Tortoise.turn(135);
   Tortoise.move(160);
 }
 private static void makeTortoiseBody() {
   Tortoise.turn(-90);
   Tortoise.move(255);
   Tortoise.turn(135);
   Tortoise.move(135);
   Tortoise.turn(45);
   Tortoise.move(120);
   Tortoise.turn(45);
   Tortoise.move(70);
   Tortoise.turn(-90);
   Tortoise.move(35);
   Tortoise.turn(45);
   Tortoise.move(60);
   Tortoise.turn(65);
   Tortoise.move(50);
   Tortoise.turn(115);
   Tortoise.move(65);
   Tortoise.turn(-25);
   Tortoise.move(65);
 }
Exemplo n.º 29
0
  public static void main(String[] args) {

    // 3. ask the user what color they would like the tortoise to draw
    String color = JOptionPane.showInputDialog("What color do you want the pen color to be");
    // 4. use an if/else statement to set the pen color that the user
    // requested
    for (int i = 0; i < 5; ) {
      if (color.equals("Blue")) {
        Tortoise.setPenColor(Color.blue);
      }
      if (color.equals("Red")) {
        Tortoise.setPenColor(Color.red);
      }
      if (color.equals("Green")) {
        Tortoise.setPenColor(Color.green);
      }

      // 5. if the user doesn’t enter anything, choose a random color
      Colors.getRandomColor();
      // 6. put a loop around your code so that you keep asking the user for
      // more colors & drawing them

      // 2. set the pen width to 10
      Tortoise.setPenWidth(10);
      // 1. make the tortoise draw a shape (this will take more than one line
      // of code)
      Tortoise.penDown();
      Tortoise.move(100);
      Tortoise.turn(90);
      Tortoise.move(100);
      Tortoise.turn(90);
      Tortoise.move(100);
      Tortoise.turn(90);
      Tortoise.move(100);
    }
  }
 private static void makeTortoiseLeg() {
   for (int i = 0; i < 4; i++) {
     Tortoise.move(35);
     Tortoise.turn(90);
   }
 }