Ejemplo n.º 1
0
  /**
   * Returns the location, in pixels, of the centre of a tile at a given location, taking the walls
   * into account.
   */
  private Location<Float> centreForTileAtLocation(
      Location<Integer> location, Board board, double startX, double startY, double tileSize) {
    double tileCentreX = tileSize / 2.0;
    double tileCentreY = tileSize / 2.0;

    if (board.hasWallBetween(location, location.locationInDirection(Direction.Up))) {
      tileCentreY += WallWidth / 4.0;
    }

    if (board.hasWallBetween(location, location.locationInDirection(Direction.Down))) {
      tileCentreY -= WallWidth / 4.0;
    }

    if (board.hasWallBetween(location, location.locationInDirection(Direction.Left))) {
      tileCentreX += WallWidth / 4.0;
    }
    if (board.hasWallBetween(location, location.locationInDirection(Direction.Right))) {
      tileCentreX -= WallWidth / 4.0;
    }

    return new Location<>(
        (float) (startX + tileSize * location.x + tileCentreX),
        (float) (startY + tileSize * location.y + tileCentreY));
  }