BUG
mousePressed() and drawCells()
Flagged cells can display both 'F' and a number/mine color, creating visual overlap. If a flagged mine is revealed, both the 'F' and red mine color appear simultaneously.
💡 In drawCells(), draw the flag INSTEAD of the background color when flagged, not in addition to it. Change the flagged block to draw its own background: if (c.flagged) { fill(200); square(x, y, cellSize); fill(0); text('F', ...); }
FEATURE
mousePressed()
The restart button is a text label in the footer but has no visual button styling, making it unclear that it's clickable
💡 Draw a visible button rectangle in drawFooter() before drawing the text. Use: fill(200); rect(mapSize - 80, mapSize + 5, 70, 20); to create a button background.
BUG
placeMines()
The safety zone check uses abs(i - avoidI) <= 1 && abs(j - avoidJ) <= 1, which allows mines to be placed immediately adjacent (distance 1) to the first click. The comment says '3x3 area' but the actual safe zone is correct—this is misleading documentation.
💡 The code is correct (3x3 includes the clicked cell and 8 surrounding cells), but the placement loop could theoretically infinite-loop on very small grids if not enough safe spaces exist. Add a maximum iteration count to placeMines() to prevent hangs: let attempts = 0; while (placed < mineCount && attempts < 1000) { ... attempts++; }
STYLE
drawCells() and drawFooter()
Magic numbers like 0.6 (text scaling), 16 (footer text size), and 48 (message text size) are hardcoded throughout the code, making it hard to maintain consistent styling
💡 Define constants at the top: const CELL_TEXT_SIZE_RATIO = 0.6; const FOOTER_TEXT_SIZE = 16; const MESSAGE_TEXT_SIZE = 48; Then use these throughout.