public boolean moveDown() { for (Cell cell : tetromino.getCells(this)) { if (isOccupied(cell.getCol(), cell.getRow() + 1)) return false; } tetromino.fall(); return true; }
public Grid removeTetro() { if (tetromino != null) { tetromino.representation = new boolean[1][1]; tetromino.representation[0][0] = false; } return this; }
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; }
/** 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; }
private double landingHeight() { return tetromino.getHeightPosition() + tetromino.getHeigt() / 2; }
/** * 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)); }
/** Tourne le tetromino dans le sens hiraire inverse */ public void turnCounterClockwise() { tetromino.turnCounterClockwise(this); }