예제 #1
0
  /*
  ****************** CHECKLIST ******************************
  [x] the size of the scribble MUST be controlled linearly by the value of scale
  [x] use tu.moveTo()

  */
  boolean scrible(int xPos, int yPos, double scale) {
    Turtle tu = new Turtle(this);

    tu.penUp();
    tu.moveTo(xPos, yPos);
    tu.penDown();

    int size = (int) scale;

    tu.penUp();
    tu.forward(size / 2);
    tu.penDown();
    tu.turn(-90);
    for (int i = 0; i < 28; i++) {
      size = size - 10;
      tu.forward(size);
      tu.turn(-90);
      tu.forward(size);
      tu.turn(-90);
    }

    return true;
  }
예제 #2
0
  public void run() {
    // initialize variables
    double angRad = 0;
    int x = 0;
    int y = 0;

    mars.setPicture(new Picture("Proj01.jpg"));

    mars.getPicture().addMessage("Charles Combs", 10, 20);

    // this code does the turtle dancing seen in the penguin example
    joe.setName("joe");

    joe.setBodyColor(Color.YELLOW);
    joe.setShellColor(Color.RED);

    joe.setPenColor(Color.YELLOW);
    joe.setPenWidth(3);
    joe.forward();

    joe.turn(+90);

    joe.setPenColor(Color.RED);
    joe.setPenWidth(1);

    // at the top of the 100 pixel run, now red and one wide, facing east
    for (int ang = 180; ang < 274; ang += 1) {

      angRad = Math.toRadians(ang);

      x = (96) + (int) (Math.sin(angRad) * (96));

      y = (100) + (int) (Math.cos(angRad) * (100));

      joe.moveTo(x + 99, y + 46);
    } // end for loop

    joe.setPenColor(Color.GREEN);
    joe.setPenWidth(3);

    for (int ang = 274; ang < 361; ang += 1) {

      angRad = Math.toRadians(ang);

      x = (100) + (int) (Math.sin(angRad) * (100));

      y = (100) + (int) (Math.cos(angRad) * (100));

      joe.moveTo(x + 99, y + 38);
    } // end for loop

    joe.moveTo(197, 237);

    sue.setName("sue");

    sue.setPenWidth(2);
    sue.setPenColor(Color.BLUE);

    sue.moveTo(237, 187);
    sue.setPenDown(false);

    sue.moveTo(277, 227);
    sue.setPenDown(true);

    sue.moveTo(317, 267);
  } // end run method