示例#1
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--;
    }
  }
 HolidayCard() {
   tortoiseWindow = Tortoise.getBackgroundWindow();
   tortoiseWindow.addMouseListener(this);
   Tortoise.show();
   Tortoise.setSpeed(10);
   drawGreetingAndSing();
 }
 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);
    }
  }
 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);
 }
 /**
  * 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");
 }
 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();
 }