I've been trying to create my own minesweeper-game (for fun) for a couple months now. Only thing that I have really been stopped by is how to make recursive function (flood-fill) to fill the blank areas in the game.
The flood-fill works only partially. It does not extend to right or the bottom node from any clicked node.
FloodFill -part:
function floodFill(node) {
if (node < 0) {return};
if (document.getElementById("cell" + node).style.backgroundColor == "white") {return};
if (document.getElementById("cell" + node).classList.contains("nearby")) {return};
document.getElementById("cell" + node).style.backgroundColor = "white";
floodFill(node -= 1);
floodFill(node += 1);
floodFill(node -= 16);
floodFill(node += 16);
return
};
floodFill(here);
The "here" means the clicked node. The size of the grid is 16, so the bottom node is current node + 16.
This small game -project means a lot for me, so any help is greatly appreciated.