minesweeper some progress

This commit is contained in:
Geir Okkenhaug Jerstad 2024-09-03 13:48:06 +02:00
parent 5f623b19cb
commit e30ed748ad
3 changed files with 175 additions and 1 deletions

View file

@ -111,7 +111,21 @@
}
function calculateNearByBombs() {
for (var rowCounter = 0; rowCounter < matrixModel.rows.length; rowCounter++) {
var modelRow = matrixModel.rows[rowCounter];
for (var cellCounter = 0; cellCounter < modelRow.cells.length; cellCounter++) {
var modelCell = modelRow.cells[cellCounter];
modelCell.bombsNearBy =
countBomb(rowCounter - 1, cellCounter - 1)
+ countBomb(rowCounter - 1, cellCounter)
+ countBomb(rowCounter - 1, cellCounter + 1)
+ countBomb(rowCounter, cellCounter - 1)
+ countBomb(rowCounter, cellCounter + 1)
+ countBomb(rowCounter + 1, cellCounter - 1)
+ countBomb(rowCounter + 1, cellCounter)
+ countBomb(rowCounter + 1, cellCounter + 1);
}
}
}
function handleClick(aMouseEvent) {