public static void main(String[] args) {
   RockHound rockHound = new RockHound();
   ActorWorld actorWorld = new ActorWorld();
   actorWorld.add(rockHound);
   actorWorld.add(new Rock());
   actorWorld.show();
 }
  public void addItem() {
    int pick = (int) (Math.random() * openSpaces.size());
    // System.out.println("openspaces is size " + openSpaces.size());
    Location l = openSpaces.get(pick);
    int choose = (int) (Math.random() * 3);
    // System.out.println(choose);
    switch (choose) {
      case 0:
        Apple a = new Apple();
        world.add(l, a);
        openSpaces.remove(l);

        break;
      case 1:
        GrimyFood f = new GrimyFood();
        world.add(l, f);
        openSpaces.remove(l);

        break;
      case 2:
        OranBerry o = new OranBerry();

        world.add(l, o);
        openSpaces.remove(l);

        break;
    }
  }
예제 #3
0
 public static void main(String[] args) {
   ActorWorld world = new ActorWorld();
   CircleBug alice = new CircleBug(6);
   alice.setColor(Color.ORANGE);
   CircleBug bob = new CircleBug(3);
   world.add(new Location(7, 8), alice);
   world.add(new Location(5, 5), bob);
   world.show();
 }
예제 #4
0
 public static void main(String[] args) {
   ActorWorld world = new ActorWorld();
   int num = 50;
   for (int i = 0; i < num; i++) {
     world.add(new Critter());
   }
   world.add(new BlusterCritter(15));
   world.show();
 }
 /**
  * Adds two different Jumpers to a world, one with its color changed to Orange
  *
  * @param args
  */
 public static void main(String[] args) {
   ActorWorld world = new ActorWorld();
   Jumper alpha = new Jumper();
   alpha.setColor(Color.ORANGE);
   Jumper beta = new Jumper();
   world.add(new Location(7, 8), alpha);
   world.add(new Location(5, 5), beta);
   world.show();
 }
 public static void main(String[] args) {
   ActorWorld world = new ActorWorld();
   world.add(new Location(7, 8), new Rock());
   world.add(new Location(3, 3), new Rock());
   world.add(new Location(2, 8), new Rock(Color.BLUE));
   world.add(new Location(5, 5), new Rock(Color.PINK));
   world.add(new Location(1, 5), new Rock(Color.RED));
   world.add(new Location(7, 2), new Rock(Color.YELLOW));
   world.add(new Location(4, 4), new BlusterCritter(10));
   world.add(new Location(5, 8), new BlusterCritter(3));
   world.show();
 }
예제 #7
0
 public static void main(String[] args) {
   ActorWorld world = new ActorWorld();
   world.addGridClass("SparseBoundedGrid");
   world.addGridClass("SparseBoundedGrid1");
   world.addGridClass("SparseBoundedGrid2");
   world.addGridClass("SparseBoundedGrid3");
   world.addGridClass("UnboundedGrid2");
   world.setGrid(new SparseBoundedGrid3<Actor>(10, 10));
   world.add(new Location(5, 6), new Bug());
   world.add(new Location(4, 3), new Critter());
   world.show();
 }
예제 #8
0
 public static void main(String[] args) {
   int[] turns = {5, 3, 7, 5, 9, 7, 11};
   ActorWorld world = new ActorWorld();
   DancingBug bob = new DancingBug(turns);
   world.add(new Location(5, 5), bob);
   world.show();
 }
예제 #9
0
 public static void main(String[] args) {
   ActorWorld player = new ActorWorld();
   CircleBug round = new CircleBug(3);
   round.setColor(Color.GREEN);
   player.add(new Location(5, 5), round);
   player.show();
 }
예제 #10
0
 public static void main(String[] args) {
   ActorWorld world = new ActorWorld();
   Jumper alice = new Jumper();
   alice.setColor(Color.ORANGE);
   world.add(new Location(5, 5), alice);
   world.show();
 }
예제 #11
0
  public static void main(String[] args) {
    // ActorWorld world = new ActorWorld(new UnboundedGrid2<Actor>());
    ActorWorld world = new ActorWorld(new SparseBoundedGrid<Actor>(30, 30));
    // ActorWorld world = new ActorWorld(new SparseBoundedGrid2<Actor>(30, 30));
    // ActorWorld world = new ActorWorld();
    world.addGridClass("SparseBoundedGrid");
    world.addGridClass("SparseBoundedGrid2");
    world.addGridClass("UnboundedGrid2");
    world.add(new Location(4, 4), new Bug());
    world.add(new Location(2, 2), new Bug());
    // world.remove(new Location(2, 2));
    world.add(new Location(3, 2), new Bug());
    world.show();

    // world.show();
  }
 public static void main(String[] args) {
   int[] directions = {2, 7, 9, 1, 5, 6, 3, 9, 4, 2, 1, 4, 3, 2};
   ActorWorld world = new ActorWorld();
   DancingBug alice = new DancingBug(directions);
   alice.setColor(Color.ORANGE);
   world.add(new Location(7, 8), alice);
   world.show();
 }
예제 #13
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();
  }
예제 #14
0
  @Test
  public void testBasicFeature() {
    ActorWorld world = new ActorWorld();
    Jumper a = new Jumper(Color.RED);
    Jumper b = new Jumper(Color.GREEN);
    Jumper c = new Jumper(Color.BLUE);

    world.add(new Location(2, 0), a);
    a.act();
    assertEquals(0, a.getLocation().getRow());
    assertEquals(0, a.getLocation().getCol());
    assertEquals(Location.NORTH, a.getDirection());

    world.add(new Location(1, 3), b);
    b.act();
    assertEquals(0, b.getLocation().getRow());
    assertEquals(3, b.getLocation().getCol());
    assertEquals(Location.NORTH, b.getDirection());
    b.act();
    assertEquals(0, b.getLocation().getRow());
    assertEquals(3, b.getLocation().getCol());
    assertEquals(Location.NORTHEAST, b.getDirection());
    b.act();
    assertEquals(0, b.getLocation().getRow());
    assertEquals(3, b.getLocation().getCol());
    assertEquals(Location.EAST, b.getDirection());
    b.act();
    assertEquals(0, b.getLocation().getRow());
    assertEquals(5, b.getLocation().getCol());
    assertEquals(Location.EAST, b.getDirection());

    world.add(new Location(0, 6), c);
    c.act();
    assertEquals(0, c.getLocation().getRow());
    assertEquals(6, c.getLocation().getCol());
    assertEquals(Location.NORTHEAST, c.getDirection());
    c.act();
    assertEquals(0, c.getLocation().getRow());
    assertEquals(6, c.getLocation().getCol());
    assertEquals(Location.EAST, c.getDirection());
    c.act();
    assertEquals(0, c.getLocation().getRow());
    assertEquals(8, c.getLocation().getCol());
    assertEquals(Location.EAST, c.getDirection());
  }
예제 #15
0
 public static void main(String[] args) {
   // UnboundedGrid ugr=new UnboundedGrid();
   ActorWorld world = new ActorWorld();
   /*world.add(new Location(-1,-1),new MazeBug());
   for(int i=0;i<=40;i++){
   	for(int j=0;j<=40;j+=40){
   		world.add(new Location(i,j),new Rock());
   	}
   }
   for(int i=0;i<=40;i+=40){
   	for(int j=0;j<=40;j++){
   		world.add(new Location(i,j),new Rock());
   	}
   }*/
   world.add(new Location(0, 0), new MazeBug());
   world.add(new Location(0, 1), new MazeBug2());
   world.add(new Location(1, 1), new Rock());
   world.show();
 }
예제 #16
0
 public static void main(String[] args) {
   // create a patten array
   int[] a = {1, 2, 3, 4, 5, 6, 7, 8};
   ActorWorld world = new ActorWorld();
   // creat a DancingBug with the patten array above
   DancingBug zyh = new DancingBug(a);
   zyh.setColor(Color.ORANGE);
   // add the bug into grid, and set the location initially
   world.add(new Location(5, 5), zyh);
   world.show();
 }
예제 #17
0
 public static void main(String[] args) {
   ActorWorld world = new ActorWorld();
   // DancingBug alice = new DancingBug(6);
   // alice.setColor(Color.ORANGE);
   Random r = new Random();
   int[] array = new int[100];
   for (int i = 0; i < array.length; i++) {
     array[i] = r.nextInt(5);
   }
   DancingBug bob = new DancingBug(array);
   // world.add(new Location(7, 8), alice);
   world.add(new Location(5, 5), bob);
   world.show();
 }
예제 #18
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));
    }
  }
  public void startGame() {
    JOptionPane.showMessageDialog(
        null, "Welcome to Pokemon Mystery Dungeon! Reach the 6th stage to beat the game!");
    //			if (!firstStage)
    //				this.getInfo().writeText("You moved to the next stage!");
    //			else
    //				firstStage = false;
    //			boolean check = false;
    Dungeon d;

    d = new Dungeon(60, 60); // creates a dungeon
    ArrayList<Room> roo = d.getRooms();
    boolean reDo = d.checkRooms();
    while (reDo == true) {
      d = new Dungeon(50, 50);
      reDo = d.checkRooms();
    }

    land = d.getDungeon(); // / change to land
    openSpaces = openLocations(); // gets locations of the rooms/corridors
    grid = new BoundedGrid<>(land.length, land[1].length);
    world = new ActorWorld(grid);

    int counter = 0;
    for (int i = 0; i < numEnemies * floorLevel; i++) {
      addEnemy();
      counter++;
    }
    for (int i = 0; i < numItems + floorLevel; i++) {
      addItem();
    }
    PersonalityTest t = new PersonalityTest(land);
    Pokemon z = t.chooseCharacter(this);
    hero = new Hero(z, land, this);
    Location l = (openSpaces.get((int) (Math.random() * openSpaces.size())));
    world.add(openSpaces.get((int) (Math.random() * openSpaces.size())), hero.main);
    hero.setGrid(grid);
    hero.setPanel(this);

    addStairs();

    ArrayList<ArrayList<Location>> a = d.getCorridors();
    for (ArrayList<Location> lo : a) {
      for (int i = 0; i < lo.size(); i++) {
        openSpaces.add(lo.get(i));
      }
    }
    repaint();
  }
  public void nextLevel() {
    //		if (!firstStage)
    this.getInfo().writeText("You moved to the next stage!");
    //		else
    //			firstStage = false;
    //		boolean check = false;
    Dungeon d;
    floorLevel++;
    if (floorLevel == 6)
      JOptionPane.showMessageDialog(
          null, "Great Job! You beat the game (as it is right now). If you want you can continue.");
    d = new Dungeon(60, 60); // creates a dungeon
    ArrayList<Room> roo = d.getRooms();
    boolean reDo = d.checkRooms();
    while (reDo == true) {
      d = new Dungeon(50, 50);
      reDo = d.checkRooms();
    }

    land = d.getDungeon(); // / change to land
    openSpaces = openLocations(); // gets locations of the rooms/corridors
    hero.setLand(this.land);
    grid = new BoundedGrid<>(land.length, land[1].length);
    world = new ActorWorld(grid);

    int counter = 0;
    for (int i = 0; i < numEnemies * floorLevel; i++) {
      addEnemy();
      counter++;
    }
    for (int i = 0; i < numItems + floorLevel; i++) {
      addItem();
    }

    Location l = (openSpaces.get((int) (Math.random() * openSpaces.size())));
    world.add(openSpaces.get((int) (Math.random() * openSpaces.size())), hero.main);
    hero.setGrid(grid);
    hero.setPanel(this);

    addStairs();

    ArrayList<ArrayList<Location>> a = d.getCorridors();
    for (ArrayList<Location> lo : a) {
      for (int i = 0; i < lo.size(); i++) {
        openSpaces.add(lo.get(i));
      }
    }
    repaint();
  }
예제 #21
0
 public static void main(String[] args) {
   int[] i = {
     2, 5, 6, 8, 14, 56, 5, 1, 5, 4, 52, 52, 5, 87, 85, 542, 1, 2, 6, 8, 4, 5, 5, 2, 1, 5, 4, 5, 2,
     1, 5, 4, 87, 5, 1, 2, 4, 85, 52, 7, 4, 76, 36, 35, 6
   };
   ActorWorld world = new ActorWorld();
   BoxBug alice = new BoxBug(6);
   DancingBug b = new DancingBug(i);
   alice.setColor(Color.ORANGE);
   BoxBug bob = new BoxBug(3);
   // world.add(new Location(7, 8), alice);
   // world.add(new Location(5, 5), bob);
   world.add(new Location(4, 3), b);
   world.show();
 }
 private void addEnemy() {
   int pick = (int) (Math.random() * openSpaces.size());
   // System.out.println("openspaces is size " + openSpaces.size());
   Location l = openSpaces.get(pick);
   // System.out.println(l);
   int choose = (int) (Math.random() * 4);
   // System.out.println(choose);
   switch (choose) {
     case 0:
       Cyndaquil a = new Cyndaquil(true, land, this);
       world.add(l, a);
       openSpaces.remove(l);
       enemies.add(a);
       break;
     case 1:
       Mudkip m = new Mudkip(true, land, this);
       world.add(l, m);
       // System.out.println("Pokemon here");
       openSpaces.remove(l);
       enemies.add(m);
       break;
     case 2:
       Munchlax mu = new Munchlax(true, land, this);
       world.add(l, mu);
       // System.out.println("Pokemon here");
       openSpaces.remove(l);
       enemies.add(mu);
       break;
     case 3:
       Pichu p = new Pichu(true, land, this);
       world.add(l, p);
       openSpaces.remove(l);
       enemies.add(p);
       break;
   }
 }
예제 #23
0
  public static void main(String[] args) {

    ActorWorld world = new ActorWorld();
    // 在world中添加actors
    world.add(new Flower());
    world.add(new Location(4, 4), new MazeBug1());
    world.add(new Location(5, 3), new Rock());
    world.add(new Location(4, 3), new Rock());
    world.add(new Location(3, 3), new Rock());
    world.add(new Location(2, 4), new Rock());
    world.add(new Location(6, 5), new Rock());
    world.add(new Location(5, 5), new Rock());
    world.add(new Location(5, 6), new Rock());
    world.add(new Location(3, 5), new Rock());
    world.add(new Location(3, 6), new Rock());
    world.add(new Location(4, 7), new Rock());
    world.add(new Location(7, 4), new Rock());
    world.add(new Location(6, 3), new Rock());
    // 显示world
    world.show();
  }
예제 #24
0
  public static void main(String[] args) {
    Grid<Actor> grid = new BoundedGrid<Actor>(20, 20);
    ActorWorld world = new ActorWorld(grid);
    world.add(new Location(9, 9), new BeMeCritter());
    world.add(new Location(2, 5), new BeMeCritter(Color.green));
    world.add(new Critter());
    world.add(new Location(2, 10), new Rock());

    world.add(new Location(10, 10), new BeMeCritter());

    world.add(new Location(10, 9), new Critter());

    world.show();
  }
예제 #25
0
  /**
   * Test if the jumper meets the requirement of given test data
   *
   * @param jumperBeginLocations
   * @param jumperBeginDirections
   * @param jumperEndLocations
   * @param jumperEndDirections
   * @param flowerLocations nullable
   * @param flowerSupposedExistences nullable
   * @param rockLocations nullable
   * @throws Exception
   */
  public Test(JumperInfo[] jumperInfo, FlowerInfo[] flowerInfo, Location rockLocations[]) {
    world = new ActorWorld();
    runned = false;

    // initialize actors
    jumperToTest = new JumperToTest[jumperInfo.length];
    for (int i = 0; i < jumperInfo.length; ++i) {
      jumperToTest[i] = new JumperToTest(jumperInfo[i]);
    }

    if (flowerToTest != null) {
      flowerToTest = new FlowerToTest[flowerInfo.length];
      for (int i = 0; i < flowerInfo.length; ++i) {
        flowerToTest[i] = new FlowerToTest(flowerInfo[i]);
      }
    }

    if (rockLocations != null) {
      for (int i = 0; i < rockLocations.length; ++i) world.add(rockLocations[i], new Rock());
    }
  }
 /**
  * Adds an occupant at a random location.
  *
  * @param occupant the occupant to add
  */
 public void add(Actor occupant) {
   Location loc = getRandomEmptyLocation();
   if (loc != null) add(loc, occupant);
 }