🎉 Added previously forgotten bubbleRight function. Now it seems to be really done!

main
Isabell Pflug 1 year ago
parent 73a25cd618
commit f8d9eb1a50

@ -36,12 +36,19 @@ void MainWindow::refreshButtonGrid() {
} }
} }
void MainWindow::bubbleRight(int column) {
if (column < columns-1) {
for (int row = 0; row < rows; row++) {
QString tcolor = game->getCell(row, column);
game->setCell(row, column, game->getCell(row, column+1));
game->setCell(row, column+1, tcolor);
}
bubbleRight(column+1);
}
}
void MainWindow::bubbleUp(int row, int column) { void MainWindow::bubbleUp(int row, int column) {
if (row > 0) { if (row > 0) {
/*QPushButton *tbutton = std::move(buttonGrid[row][column]);
buttonGrid[row][column] = std::move(buttonGrid[row-1][column]);
buttonGrid[row-1][column] = std::move(tbutton);*/
QString tcolor = game->getCell(row, column); QString tcolor = game->getCell(row, column);
game->setCell(row, column, game->getCell(row-1, column)); game->setCell(row, column, game->getCell(row-1, column));
game->setCell(row-1, column, tcolor); game->setCell(row-1, column, tcolor);
@ -54,6 +61,16 @@ void MainWindow::bubbleBoxes(std::set<std::vector<int>> *connected) {
for (auto i = connected->begin(); i != connected->end(); i++) { for (auto i = connected->begin(); i != connected->end(); i++) {
bubbleUp((*i)[0], (*i)[1]); bubbleUp((*i)[0], (*i)[1]);
} }
bool isEmpty;
for (int j = 0; j < columns; j++) {
isEmpty = true;
for (int i = 0; i < rows; i++) {
if (game->getCell(i, j) != "")
isEmpty = false;
}
if (isEmpty)
bubbleRight(j);
}
refreshButtonGrid(); refreshButtonGrid();
} }

@ -32,6 +32,7 @@ public:
void clearConnected(std::set<std::vector<int>> *connected); void clearConnected(std::set<std::vector<int>> *connected);
void refreshButtonGrid(); void refreshButtonGrid();
void refreshSizes(); void refreshSizes();
void bubbleRight(int column);
void bubbleUp(int row, int column); void bubbleUp(int row, int column);
void bubbleBoxes(std::set<std::vector<int>> *connected); void bubbleBoxes(std::set<std::vector<int>> *connected);

Loading…
Cancel
Save