Hi, I am making a minesweeper game, and have made the bombs and other things. But I have a problem with getting the numbers of bombs next to it. With this code it does not check the tiles above it and I can not figure out why.
Here is my code:
1. You check to see if the row is out of bounds, but you never check if the column is out of bounds.
2. Line 22 always evaluates to false.
Lines 16-18 are unnecessary because that is the cell you're on, not its neighbor.
You should use embedded for or while loops for this.
1 2 3 4 5 6 7 8 9 10
for(row - 1 to row + 1)
{
for(col - 1 to col + 1)
{
if(row is valid and col is valid)
{
miner + 1
}
}
}
When you place each bomb, update the number of bombs next to the cell in each cell next to the bomb. Assuming there are any blank spaces, this will make the processing take less time.