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);
 }
Ejemplo n.º 2
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();
  }