ajoute la possiblilité d'ajouter des lignes de garbage
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user