allow resetting games
This commit is contained in:
@@ -16,11 +16,7 @@ Board::Board(int width, int height) :
|
||||
this->emptyRow.push_back(NOTHING);
|
||||
}
|
||||
|
||||
// initialize grid
|
||||
this->grid.clear();
|
||||
for (int j = 0; j < height; j++) {
|
||||
this->grid.push_back(this->emptyRow);
|
||||
}
|
||||
this->clearBoard();
|
||||
}
|
||||
|
||||
void Board::changeBlock(const Position& position, Block block) {
|
||||
@@ -76,6 +72,13 @@ int Board::clearRows() {
|
||||
return clearedLines;
|
||||
}
|
||||
|
||||
void Board::clearBoard() {
|
||||
this->grid.clear();
|
||||
for (int j = 0; j < height; j++) {
|
||||
this->grid.push_back(this->emptyRow);
|
||||
}
|
||||
}
|
||||
|
||||
Block Board::getBlock(const Position& position) const {
|
||||
if (position.x < 0 || position.x >= this->width || position.y < 0) return OUT_OF_BOUNDS;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user