Example #1
0
 public boolean moveDown() {
   for (Cell cell : tetromino.getCells(this)) {
     if (isOccupied(cell.getCol(), cell.getRow() + 1)) return false;
   }
   tetromino.fall();
   return true;
 }
Example #2
0
 public Grid removeTetro() {
   if (tetromino != null) {
     tetromino.representation = new boolean[1][1];
     tetromino.representation[0][0] = false;
   }
   return this;
 }
Example #3
0
  public String toString() {
    String str = "\n";
    for (int row = 0; row < HEIGHT; row++) {
      str += "|";
      for (int col = 0; col < WIDTH; col++) {
        if (getCell(row, col).isOccupied()) str += " X ";
        else if (tetromino != null && tetromino.getCells(this).contains(getCell(row, col)))
          str += " O ";
        else str += " . ";
      }
      str += "|\n";
      if (row == HEIGHT - 1) str += "\\______________________________/";
    }

    return str;
  }
Example #4
0
 /** Déplace le tetromino vers la droite */
 public boolean moveRight() {
   for (Cell cell : tetromino.getCells(this))
     if (isOccupied(cell.getCol() + 1, cell.getRow())) return false;
   tetromino.moveRight();
   return true;
 }
Example #5
0
 private double landingHeight() {
   return tetromino.getHeightPosition() + tetromino.getHeigt() / 2;
 }
Example #6
0
 /**
  * Test si la case situ�e � la colonne col , ligne row est occup�
  *
  * @param col
  * @param row
  * @return true si la case est hors du jeu
  */
 private boolean occupied(int col, int row) {
   if (col < 0 || row < 0 || col >= WIDTH || row >= HEIGHT) return true;
   return board[col][row].isOccupied() || tetromino.getCells(this).contains(getCell(row, col));
 }
Example #7
0
 /** Tourne le tetromino dans le sens hiraire inverse */
 public void turnCounterClockwise() {
   tetromino.turnCounterClockwise(this);
 }