Exemplo n.º 1
0
  /**
   * Method that surrounds whole Arena with 4 rectangles, one for each side of Arena, that blocks
   * objects in Arena from falling out of it. The walls are placed outside the Arena so that they
   * won't reduce the space in Arena with their bodies.
   *
   * @param thickness Width of the walls.
   */
  private void encloseWithWalls(int thickness) {

    Fixed northWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(0, -thickness, screenWidth, thickness), "FixedObstacle", 1, this);
    Fixed southWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(0, screenHeight, screenWidth, thickness), "FixedObstacle", 1, this);
    Fixed eastWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(screenWidth, 0, thickness, screenHeight), "FixedObstacle", 1, this);
    Fixed westWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(-thickness, 0, thickness, screenHeight), "FixedObstacle", 1, this);

    walls.add(northWall);
    walls.add(southWall);
    walls.add(eastWall);
    walls.add(westWall);

    world.add(northWall.getBody());
    world.add(southWall.getBody());
    world.add(eastWall.getBody());
    world.add(westWall.getBody());

    isEnclosedWithWalls = true;
  }
Exemplo n.º 2
0
  /**
   * Method that surrounds whole Arena with 4 rectangles, one for each side of Arena, that blocks
   * objects in Arena from falling out of it. The walls are placed outside the Arena so that they
   * won't reduce the space in Arena with their bodies.
   *
   * @param thickness Width of the walls.
   */
  private void encloseWithWalls(int thickness) {

    Fixed northWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(0, -thickness, screenWidth, thickness), "FixedObstacle", 1, this);
    Fixed southWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(0, screenHeight, screenWidth, thickness), "FixedObstacle", 1, this);
    Fixed eastWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(screenWidth, 0, thickness, screenHeight), "FixedObstacle", 1, this);
    Fixed westWall =
        (Fixed)
            ArenaPartsGenerator.createPart(
                new Rectangle(-thickness, 0, thickness, screenHeight), "FixedObstacle", 1, this);

    //        addPassive((FixedObstacle) northWall);
    //        addPassive((FixedObstacle) southWall);
    //        addPassive((FixedObstacle) eastWall);
    //        addPassive((FixedObstacle) westWall);

    walls.add(northWall);
    walls.add(southWall);
    walls.add(eastWall);
    walls.add(westWall);

    world.add(northWall.getBody());
    world.add(southWall.getBody());
    world.add(eastWall.getBody());
    world.add(westWall.getBody());

    isEnclosedWithWalls = true;

    // Logger.getLogger("vivae").info("Enclosing with walls.");
  }