Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Tetris::findLowestCopmpleteLine() {
- for(size_t y = Y_GLASS_SIZE; y != 0; --y) {
- bool completeLine = true;
- for(size_t x = 1; x<= X_GLASS_SIZE ; ++x) {
- if (GetChar(x, y) == kEmptySymbol) {
- completeLine = false;
- break;
- }
- }
- if (completeLine) {
- return y;
- }
- }
- return -1;
- }
- bool Tetris::tryRemoveCompleteLine() {
- int complete_line = findLowestCopmpleteLine()
- if (complete_line != -1) {
- for (size_t y = complete_line; y!= 1; --y) {
- for (size_t x = 1; x <= X_GLASS_SIZE; ++x) {
- upper_row_symbol = GetChar(x, y-1);;
- SetChar(x, y, upper_row_symbol);
- }
- for (size_t x = 1; x <= X_GLASS_SIZE; ++x) {
- SetChar(x, 1, kEmptySymbol);
- }
- }
- return true;
- } else {
- return false;
- }
- }
- int Tetris::removeCompleteLinesAndDownCells() {
- score = 0;
- while (tryRemoveCompleteLine()) ++score;
- return score;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement