private void makePrettyThings() {
    // 1. Create a new Robot
    Robot bolbi = new Robot();
    // 3. Put the robot's pen down
    bolbi.penDown();
    // 8. Make the robot go at maximum speed (10)
    bolbi.setSpeed(10);
    // 9. Set the pen to a color that you like for the shape
    bolbi.setPenColor(0, 200, 255);
    // 4. Make a variable for the number of sides you want (can’t test this one)
    int mySides = 55;
    // 5. Make a variable for the angle you want the robot to turn. Hint: you can divide in Java
    // using "/". Can’t test until step 6.
    int angle = 360 / 55;
    // 7. Do steps #2 to #11, 200 times. When this is done you should see a pentagon.
    for (int i = 0; i < 200; i++) {
      bolbi.setRandomPenColor();
      // 2. Move the robot 200 pixels
      bolbi.move(15);
      // 10. Make the robot move "i" pixels instead of 200 (don’t need new line of code for this,
      // just change previous one)

      // 6. Turn the robot the amount in your angle variable
      bolbi.turn(angle);
      // 11. Turn the robot one more degree

    }
  }
Ejemplo n.º 2
0
 public static void main(String[] args) {
   Robot Maria = new Robot("batman");
   Maria.setWindowColor(Color.RED.darker());
   Maria.setPenColor(Color.white);
   Maria.penDown();
   Maria.sparkle();
   for (int i = 0; i < 4; i++) {
     Maria.move(50);
     Maria.turn(90);
   }
 }
Ejemplo n.º 3
0
  public static void main(String[] args) {
    Robot the = new Robot();
    the.penDown();
    the.setSpeed(300);
    the.setPenWidth(50);

    the.setPenColor(Color.PINK);
    for (int i = 0; i < 4; i++) {
      the.move(101);
      the.turn(630);
    }
  }
Ejemplo n.º 4
0
 public static void main(String[] args) {
   // TODO Auto-generated method stub
   Robot URobot = new Robot("batman");
   String y = JOptionPane.showInputDialog("What shape");
   if (y.equals("octogon")) {
     for (int i = 0; i < 8; i++) {
       URobot.penDown();
       URobot.move(100);
       URobot.turn(360 / 8);
     }
   }
   if (y.equals("Pentagon")) {
     URobot.penDown();
     URobot.move(100);
     URobot.turn(360 / 5);
   }
   if (y.equals("haha")) {
     URobot.penDown();
     URobot.move(100);
     URobot.turn(360 / 100);
   }
 }
  void go() {
    // 4. Make the robot move as fast as possible
    Chas.setSpeed(10);
    Chas.penDown();
    // 5. Set the pen width to 5
    Chas.setPenWidth(5);
    // 6. Do steps #7 to #8 four times...
    for (int i = 0; i < 4; i++) {

      // 7. Set the pen color to random
      Chas.setRandomPenColor();
      // 1. Call the drawSquare() method
      drawSquare();
      // 8. Turn the robot 90 degrees to the right
      Chas.turn(90);
    }
  }
  void go() {

    // 6. Make the robot go as fast as possible
    Shinton.setSpeed(10);
    // 4. make a variable to hold the length of the triangle and set it to
    // 50
    int legnth = 50;
    // 7. Do the following (up to step 10) 60 times

    // 9. Change the color of the pen to a random color
    Shinton.penDown();
    for (int a = 1; a <= 60; a++) {
      Shinton.setRandomPenColor();
      legnth += 10;
      drawTriangle(legnth);
      Shinton.turn(6);
    }
  }
Ejemplo n.º 7
0
  public static void main(String[] args) {
    // 1. Create a new Robot
    Robot Dalek = new Robot();
    // 5. Set your robot's pen to the down position
    Dalek.penDown();
    // 3. Set the robot to go at max speed (10)
    Dalek.setSpeed(20);
    // 4. Do the following (steps 5-8) 75 times
    for (int i = 0; i < 150; i++) {

      // 7. Change the pen color to random
      Dalek.setRandomPenColor();
      // 6. Move the robot 5 times the current line number you are drawing (5*i)
      Dalek.move(5 * i);
      // 2. Turn the robot 1/3 of 360 degrees to the right
      Dalek.turn(150);
      // 8. Change the number of sides to 7 (don’t add a new line of code for this one!)

      // 9. Set the pen width to i
      Dalek.setPenWidth(i);
    }
  }