Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Level::clearRows()
- {
- bool isComplete;
- int rows = 0;
- for (int i = 0; i < height; i++)
- {
- for (int j = 0; j < width; j++)
- {
- if (board[j][i] == RGB(0,0,0))
- {
- isComplete = false;
- break;
- }
- // The row is full
- if (j == width - 1)
- isComplete = true;
- }
- // If the row is full, clear it (fill with black)
- if (isComplete)
- {
- for (int j = 0; j < width; j++)
- board[j][i] = RGB(0,0,0);
- // Move rows down
- for (int k = i; k < height - 1; k++)
- {
- for (int m = 0; m < width; m++)
- board[m][k] = board[m][k+1];
- }
- i = -1;
- rows++;
- }
- }
- return rows;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement