Examples of Vec2i


Examples of com.puzzlebazar.shared.util.Vec2i

  @Override
  public Vec2i pixelToCell(int x, int y) {
    updateGridInUiWidget();
    int dx = x - gridInUiWidget.x;
    int dy = y - gridInUiWidget.y;
    Vec2i result = new Vec2i(
        dx * gridPanel.getWidth() / gridInUiWidget.w,
        dy * gridPanel.getHeight() / gridInUiWidget.h);
    if (dx < 0) {
      result.x = -1;
    }
View Full Code Here

Examples of com.puzzlebazar.shared.util.Vec2i

    double dy = y - gridInUiWidget.y + pixelPerCellY / 2.0;
    if (dx < 0 || dy < 0) {
      return null;
    }

    Vec2i vertex = new Vec2i();
    Vec2i dist = new Vec2i();
    vertex.x = (int) (dx * gridPanel.getWidth() / gridInUiWidget.w);
    vertex.y = (int) (dy * gridPanel.getHeight() / gridInUiWidget.h);

    // The vertex position
    dist.x = Math.abs((int) (dx - vertex.x * pixelPerCellX - pixelPerCellX / 2.0));
View Full Code Here

Examples of com.puzzlebazar.shared.util.Vec2i

  }

  @Override
  public EdgeHitInfo pixelToEdge(int x, int y) {
    updateGridInUiWidget();
    Vec2i cell = pixelToCell(x, y);
    VertexHitInfo vertexHitInfo = pixelToVertex(x, y);
    if (vertexHitInfo == null || vertexHitInfo.getVertex().x < 0 ||  vertexHitInfo.getVertex().y < 0) {
      return null;
    }

    boolean vertical;
    Vec2i edge = new Vec2i();
    int dist;
    if (vertexHitInfo.getDist().y < vertexHitInfo.getDist().x) {
      // Select horizontal edge
      vertical = false;
      edge.x = cell.x;
View Full Code Here

Examples of com.puzzlebazar.shared.util.Vec2i

      for (int y = 0; y < getHeight(); ++y) {
        if (roomsPerCell[x][y] != 1) {
          if (result == null) {
            result = new PuzzleMessage(true, "Some cells are covered by more than one room.");
          }
          result.addErrorLocation(new Vec2i(x,y));
        }
      }
    }

    if (result != null) {
View Full Code Here

Examples of com.puzzlebazar.shared.util.Vec2i

    boolean visited[][] = new boolean[width][height];
    for (int i = 0; i < visited.length; ++i) {
      Arrays.fill(visited[i], false);
    }

    Vec2i loc = findValid(cellArray, valid);
    if (loc == null) {
      return null;
    }

    List<Vec2i> stack = new ArrayList<Vec2i>();
View Full Code Here

Examples of com.puzzlebazar.shared.util.Vec2i

   * Private method used by {@link #areCellsInAConnectedGroup(CellArray, boolean[][])}.
   */
  private static void checkAndAdd(boolean[][] visited, boolean[][] valid, Vec2i loc,
      List<Vec2i> stack) {
    if (!visited[loc.x][loc.y] && valid[loc.x][loc.y]) {
      stack.add(new Vec2i(loc));
      visited[loc.x][loc.y] = true;
    }
  }
View Full Code Here

Examples of com.puzzlebazar.shared.util.Vec2i

      boolean prevValid = false;
      for (int j = 0; j < valid[i].length; ++j) {
        if (valid[i][j]) {
          if (prevValid) {
            PuzzleMessage result = new PuzzleMessage(true);
            result.addErrorLocation(new Vec2i(i, j));
            result.addErrorLocation(new Vec2i(i, j - 1));
            return result;
          }
          prevValid = true;
          if (valid[i + 1][j]) {
            PuzzleMessage result = new PuzzleMessage(true);
            result.addErrorLocation(new Vec2i(i, j));
            result.addErrorLocation(new Vec2i(i + 1, j));
            return result;
          }
        } else {
          prevValid = false;
        }
View Full Code Here

Examples of com.puzzlebazar.shared.util.Vec2i

   *         state matches one of the desired states.
   */
  private static <S extends CellState> boolean[][] cellsMatching(CellArray<S> cellArray, CellStateCondition<S> condition) {

    boolean[][] result = new boolean[cellArray.getWidth()][cellArray.getHeight()];
    Vec2i loc = new Vec2i();
    for (int i = 0; i < result.length; ++i) {
      loc.x = i;
      for (int j = 0; j < result[i].length; ++j) {
        loc.y = j;
        result[i][j] = condition.doesCellVerifyCondition(cellArray.getCellState(loc));
View Full Code Here

Examples of com.puzzlebazar.shared.util.Vec2i

  private static <S extends CellState> Vec2i findValid(CellArray<S> cellArray, boolean[][] valid) {

    for (int i = 0; i < valid.length; ++i) {
      for (int j = 0; j < valid[i].length; ++j) {
        if (valid[i][j]) {
          return new Vec2i(i, j);
        }
      }
    }

    return null;
View Full Code Here

Examples of com.puzzlebazar.shared.util.Vec2i

      boolean valid,
      boolean visited,
      boolean[][] validCells,
      boolean[][] visitedCells) {

    Vec2i loc = new Vec2i();
    for (int i = 0; i < validCells.length; ++i) {
      loc.x = i;
      for (int j = 0; j < validCells[i].length; ++j) {
        loc.y = j;
        if ((validCells[i][j] ^ !valid) && (visitedCells[i][j] ^ !visited)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.