hasCollision method

bool hasCollision(
  1. Tetromino piece,
  2. BoardState board
)

Returns true if piece overlaps any filled cell or is out of bounds.

Implementation

bool hasCollision(Tetromino piece, BoardState board) {
  for (final pos in piece.cells) {
    if (_outOfBounds(pos, board)) return true;
    if (board.cellAt(pos.row, pos.col).filled) return true;
  }
  return false;
}