Example #1
0
  public static void makeBugs(ActorWorld world, int n) {

    for (int i = 0; i < n; i++) {

      Bug coloredBug = new Bug();

      world.add(coloredBug);

      int x = coloredBug.getLocation().getCol();
      int y = coloredBug.getLocation().getRow();

      coloredBug.setColor(new Color(25 * y, 0, 25 * x));
    }
  }
Example #2
0
  public static void randomBug(Bug bug, int n) {

    for (int i = 0; i < n; i++) {

      int randomDirection = (int) (4 * Math.random()) * 90;

      bug.setDirection(randomDirection);

      if (bug.canMove()) {

        bug.move();
      }
    }
  }
Example #3
0
  public static void moveBug(Bug bug, int n) {

    for (int i = 0; i < n; i++) {

      if (bug.canMove()) {

        bug.move();

      } else {

        bug.turn();
      }
    }
  }
Example #4
0
  public static void main(String[] args) {

    Color purple = new Color(148, 0, 211);
    ActorWorld world = new ActorWorld();
    Bug redBug = new Bug();
    world.add(redBug);
    System.out.println(redBug.getLocation());

    makeBugs(world, 10);
    // colorBug(redBug);
    // moveBug(redBug, 5);

    // randomBug(redBug, 10000);

    world.add(new Rock());
    world.show();
  }
Example #5
0
 /**
  * Moves to the next location of the square.
  */
 public void act()
 {
    if (steps == turningList.length) {
       steps = 0;
       turn (turningList [steps]);
       steps++;
       super.act();
    }
 }
Example #6
0
  public static void colorBug(Bug bug) {

    bug.getLocation();
    bug.setColor(new Color(148, 0, 211));
  }