September 2018
Intermediate to advanced
328 pages
9h 10m
English
The third section of code contains logic to unite a piece with the top row when it comes to rest:
void Board::unite(const Piece &piece) { for (int column = 0; column < PieceSize; ++column) { for (int row = 0; row < PieceSize; ++row) { if (piece.isBlock(column, row)) { int columnTarget = piece.getColumn() + column; int rowTarget = piece.getRow() + row; cells_[columnTarget][rowTarget] = true; } } } // Continuously loops through each of the rows until no full rows are // detected and ensures the full rows are collapsed and non-full rows // are shifted accordingly: while (areFullRowsPresent()) { for (int row = BoardRows - 1; row >= 0; --row) { if (isRowFull(row)) { updateOffsetRow(row); currentScore_ += 1; for (int column ...Read now
Unlock full access