Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void deleteAllMatchesOfType(int crystalType)
- {
- vector<gridCoordinate> crystalCoordinatesToClear;
- for (int row = 0; row < gridSize; row++)
- {
- for (int column = 0; column < gridSize; column++)
- {
- bool excludeHorizontalCheck = false, excludeVerticalCheck = false;
- if (row == 0 || row == (gridSize - 1)) // If it is the top or bottom row do not check above or bellow.
- excludeVerticalCheck = true;
- if (column == 0 || column == (gridSize - 1)) // If it is the left or right edge do not check horizontally for matches.
- excludeHorizontalCheck = true;
- if (grid[row][column] = crystalType) // Check for only this type of crystal.
- {
- if (excludeVerticalCheck == false)
- {
- if (grid[row][column] == grid[row - 1][column] && grid[row][column] == grid[row + 1][column]) // If above and bellow crystal have same value as crystal consider this a match.
- {
- gridCoordinate top, mid, bot;
- top.row = row - 1;
- top.column = column;
- mid.row = row;
- mid.column = column;
- bot.row = row + 1;
- bot.column = column;
- crystalCoordinatesToClear.push_back(top);
- crystalCoordinatesToClear.push_back(mid);
- crystalCoordinatesToClear.push_back(bot);
- }
- }
- if (excludeHorizontalCheck == false)
- {
- if (grid[row][column] == grid[row][column - 1] && grid[row][column] == grid[row][column + 1]) // If left and right crystal have same value as crystal consider this a match.
- {
- gridCoordinate left, mid, right;
- left.row = row;
- left.column = column - 1;
- mid.row = row;
- mid.column = column;
- right.row = row;
- right.column = column + 1;
- crystalCoordinatesToClear.push_back(left);
- crystalCoordinatesToClear.push_back(mid);
- crystalCoordinatesToClear.push_back(right);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement