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)); } }
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(); } } }
public static void moveBug(Bug bug, int n) { for (int i = 0; i < n; i++) { if (bug.canMove()) { bug.move(); } else { bug.turn(); } } }
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(); }
/** * Moves to the next location of the square. */ public void act() { if (steps == turningList.length) { steps = 0; turn (turningList [steps]); steps++; super.act(); } }
public static void colorBug(Bug bug) { bug.getLocation(); bug.setColor(new Color(148, 0, 211)); }