Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. // This reveals the radial upwards
  2. while (countMine == 0 && row - k >= 0 && row - k < SIZE && k < SIZE ) {
  3. minefield[row - k][col] = VISIBLE_SAFE;
  4. if (count_mines(row - k - 1, col, SQUARE_SIZE_REVEAL, minefield) != 0) {
  5. minefield[row - k][col] = VISIBLE_SAFE;
  6. }
  7. countMine = count_mines(row - k, col, SQUARE_SIZE_REVEAL, minefield);
  8. k++;
  9. }
  10. k = 0;
  11. countMine = count_mines(row + k, col, SQUARE_SIZE_REVEAL, minefield);
  12. // This reveals the radial downwards.
  13. while (countMine == 0 && row + k >= 0 && row + k < SIZE && k < SIZE ) {
  14. minefield[row + k][col] = VISIBLE_SAFE;
  15. if (count_mines(row + k + 1, col, SQUARE_SIZE_REVEAL, minefield) != 0) {
  16. minefield[row + k][col] = VISIBLE_SAFE;
  17. }
  18. countMine = count_mines(row + k, col, SQUARE_SIZE_REVEAL, minefield);
  19. k++;
  20. }
  21. k = 0;
  22. countMine = count_mines(row , col - k, SQUARE_SIZE_REVEAL, minefield);
  23. // This reveals the radial to the left.
  24. while (countMine == 0 && col - k >= 0 && col - k < SIZE && k < SIZE ) {
  25. minefield[row][col - k] = VISIBLE_SAFE;
  26. if (count_mines(row , col - k - 1, SQUARE_SIZE_REVEAL, minefield) != 0) {
  27. minefield[row][col - k] = VISIBLE_SAFE;
  28. }
  29. countMine = count_mines(row , col - k, SQUARE_SIZE_REVEAL, minefield);
  30. k++;
  31. }
  32. k = 0;
  33. countMine = count_mines(row , col + k, SQUARE_SIZE_REVEAL, minefield);
  34. // This reveals the radial to the right.
  35. while (countMine == 0 && col + k >= 0 && col + k < SIZE && k < SIZE ) {
  36. minefield[row][col + k] = VISIBLE_SAFE;
  37. if (count_mines(row , col + k + 1, SQUARE_SIZE_REVEAL, minefield) != 0) {
  38. minefield[row][col + k] = VISIBLE_SAFE;
  39. }
  40. countMine = count_mines(row , col + k, SQUARE_SIZE_REVEAL, minefield);
  41. k++;
  42. }
  43. k = 0;
  44. countMine = count_mines(row - k, col + k, SQUARE_SIZE_REVEAL, minefield);
  45. // This reveals the radial to top right diagonal.
  46. while (countMine == 0 && col + k >= 0 && col + k < SIZE && k < SIZE
  47. && row - k >= 0 && row - k < SIZE) {
  48. minefield[row - k][col + k] = VISIBLE_SAFE;
  49. if (count_mines(row - k - 1, col + k + 1, SQUARE_SIZE_REVEAL, minefield) != 0) {
  50. minefield[row - k][col + k] = VISIBLE_SAFE;
  51. }
  52. countMine = count_mines(row - k, col + k, SQUARE_SIZE_REVEAL, minefield);
  53. k++;
  54. }
  55. k = 0;
  56. countMine = count_mines(row - k , col - k, SQUARE_SIZE_REVEAL, minefield);
  57. // This reveals the radial to top left diagonal.
  58. while (countMine == 0 && col - k >= 0 && col - k < SIZE && k < SIZE
  59. && row - k >= 0 && row - k < SIZE) {
  60. minefield[row - k][col - k] = VISIBLE_SAFE;
  61. if (count_mines(row - k - 1 , col - k - 1, SQUARE_SIZE_REVEAL, minefield) != 0) {
  62. minefield[row - k][col - k] = VISIBLE_SAFE;
  63. }
  64. countMine = count_mines(row - k, col - k, SQUARE_SIZE_REVEAL, minefield);
  65. k++;
  66. }
  67. k = 0;
  68. countMine = count_mines(row + k , col - k, SQUARE_SIZE_REVEAL, minefield);
  69. // This reveals the radial to bottom left diagonal.
  70. while (countMine == 0 && col - k >= 0 && col - k < SIZE && k < SIZE
  71. && row + k >= 0 && row + k < SIZE) {
  72. minefield[row + k][col - k] = VISIBLE_SAFE;
  73. if (count_mines(row + k + 1 , col - k - 1, SQUARE_SIZE_REVEAL, minefield) != 0) {
  74. minefield[row + k][col - k] = VISIBLE_SAFE;
  75. }
  76. countMine = count_mines(row + k, col - k, SQUARE_SIZE_REVEAL, minefield);
  77. k++;
  78. }
  79. k = 0;
  80. countMine = count_mines(row + k , col + k, SQUARE_SIZE_REVEAL, minefield);
  81. // This reveals the radial to bottom right diagonal.
  82. while (countMine == 0 && col + k >= 0 && col + k < SIZE && k < SIZE
  83. && row + k >= 0 && row + k < SIZE) {
  84. minefield[row + k][col + k] = VISIBLE_SAFE;
  85. if (count_mines(row + k + 1 , col + k + 1, SQUARE_SIZE_REVEAL, minefield) != 0) {
  86. minefield[row + k][col + k] = VISIBLE_SAFE;
  87. }
  88. countMine = count_mines(row + k, col + k, SQUARE_SIZE_REVEAL, minefield);
  89. k++;
  90. }
  91.  
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement