ajoute la possiblilité d'ajouter des lignes de garbage

This commit is contained in:
2025-03-01 18:41:09 +01:00
parent 66c2cf1013
commit 03281a6d70
4 changed files with 40 additions and 4 deletions

View File

@@ -23,7 +23,7 @@ Board::Board(int width, int height) :
}
}
void Board::addBlock(const Position& position, Block block) {
void Board::changeBlock(const Position& position, Block block) {
// if the block is out of bounds we discard it
if (position.x < 0 || position.x >= this->width || position.y < 0) return;
@@ -37,6 +37,20 @@ void Board::addBlock(const Position& position, Block block) {
this->grid.at(position.y).at(position.x) = block;
}
void Board::insertRow(int height, int holePosition, Block blockType) {
std::vector<Block> insertedRow;
for (int i = 0; i < this->width; i++) {
if (i == holePosition) {
insertedRow.push_back(NOTHING);
}
else {
insertedRow.push_back(blockType);
}
}
this->grid.insert(this->grid.begin() + height, insertedRow);
}
int Board::clearRows() {
// check from top to bottom, so that erasing lines don't screw up the looping
int clearedLines = 0;