예제 #1
0
  public void setCurrentTetriminoCompositionToMatrix(TetrisMatrixModel tetrisMatrixModel) {
    TetrisBlockModel[][] tetriminoBlockComposition =
        tetrisMatrixModel.getCurrentTetromino().getTetrominoBlockComposition();
    for (int i = 0; i < tetriminoBlockComposition.length; i++) {
      for (int j = 0; j < tetriminoBlockComposition[i].length; j++) {
        TetrisBlockModel tetrisBlockModel = tetriminoBlockComposition[i][j];

        if (tetrisBlockModel != null) {
          System.out.println(
              "Set Current Tetrimino Composition To Matrix x: "
                  + tetrisBlockModel.getRectangle().x
                  + " y: "
                  + tetrisBlockModel.getRectangle().y);
          tetrisMatrixModel.addTetrisBlockToMatrix(tetrisBlockModel);
        }
      }
    }
  }
예제 #2
0
  public void clearCurrentTetriminoFromMatrix(TetrisMatrixModel tetrisMatrixModel) {
    TetrominoModel currentTetrominoModel = tetrisMatrixModel.getCurrentTetromino();

    TetrisBlockModel[][] tetriminoBlockComposition =
        currentTetrominoModel.getTetrominoBlockComposition();

    // clears current rotation on the tetrisMatrixModel
    for (int i = 0; i < tetriminoBlockComposition.length; i++) {
      for (int j = 0; j < tetriminoBlockComposition[i].length; j++) {
        TetrisBlockModel tetrisBlockModel = tetriminoBlockComposition[i][j];

        if (tetrisBlockModel != null) {
          int j1 = tetrisBlockModel.getRectangle().x;
          int i1 = tetrisBlockModel.getRectangle().y;

          tetrisMatrixModel.getTetrisBlockMatrix()[i1][j1] = null;
        }
      }
    }
  }