Advertisement
Amorf

Untitled

Dec 14th, 2021
1,125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. int Level::clearRows()
  2. {
  3.     bool isComplete;
  4.     int rows = 0;
  5.     for (int i = 0; i < height; i++)
  6.     {
  7.         for (int j = 0; j < width; j++)
  8.         {
  9.             if (board[j][i] == RGB(0,0,0))
  10.             {
  11.                 isComplete = false;
  12.                 break;
  13.             }
  14.             // The row is full
  15.             if (j == width - 1)
  16.                 isComplete = true;
  17.         }
  18.         // If the row is full, clear it (fill with black)
  19.         if (isComplete)
  20.         {
  21.             for (int j = 0; j < width; j++)
  22.                 board[j][i] = RGB(0,0,0);
  23.                
  24.             // Move rows down
  25.             for (int k = i; k < height - 1; k++)
  26.             {
  27.                 for (int m = 0; m < width; m++)
  28.                     board[m][k] = board[m][k+1];
  29.             }
  30.             i = -1;
  31.             rows++;
  32.         }
  33.     }
  34.     return rows;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement