Bugfixes: Now Always deploys 99 Bombs and doesnt print random number in [0][0]
This commit is contained in:
parent
ebb8e43e32
commit
e95f7f74d2
@ -18,14 +18,19 @@ struct MineSweeperBoard {
|
|||||||
}
|
}
|
||||||
void spreadBombs() {
|
void spreadBombs() {
|
||||||
while (bombCounter < 99) {
|
while (bombCounter < 99) {
|
||||||
field[getRandomNumberInRange(0,15)][getRandomNumberInRange(0,15)] = "x";
|
short x = getRandomNumberInRange(0,15);
|
||||||
bombCounter++;
|
short y = getRandomNumberInRange(0,15);
|
||||||
|
if (field[x][y] != "x") {
|
||||||
|
field[x][y] = "x";
|
||||||
|
bombCounter++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string countNeighbourBombs(int i, int j) {
|
std::string countNeighbourBombs(int i, int j) {
|
||||||
i--;
|
i--;
|
||||||
j--;
|
j--;
|
||||||
int counter;
|
int counter = 0;
|
||||||
|
// int counter; // Not setting this nerd to 0 can cause a bug
|
||||||
for (int k = 0; k < 3; k++) {
|
for (int k = 0; k < 3; k++) {
|
||||||
for (int l = 0; l < 3; l++) {
|
for (int l = 0; l < 3; l++) {
|
||||||
if ((i+k < 16) && (j+l < 16) && (i-l >= 0) && (j-l >= 0)) {
|
if ((i+k < 16) && (j+l < 16) && (i-l >= 0) && (j-l >= 0)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user