Skip to content

Instantly share code, notes, and snippets.

@KaidenP
Created November 2, 2015 17:47
Show Gist options
  • Save KaidenP/c63057d7fff2523331de to your computer and use it in GitHub Desktop.
Save KaidenP/c63057d7fff2523331de to your computer and use it in GitHub Desktop.
void board::incrementNotMines(point p) {
minesweeper::board b=*this;
point tmpPoint;
// Function that increments all nearby spots, unless it is a mine (-1)
for(int i=-1; i<=1; i++) {
for(int j=-1; j<=1; j++) {
tmpPoint.x=p.x+i, tmpPoint.y=p.y+j;
if(tmpPoint.chkValidPoint(b) && b.board[tmpPoint.x][tmpPoint.y] != -1) {
b.board[tmpPoint.x][tmpPoint.y]++;
}
}
}
}
bool point::chkValidPoint(board b) {
point p=*this;
return (p.x>=0 && p.y>=0 && p.x<b.height && p.y<b.width);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment