Skip to content

Commit 0428634

Browse files
committed
add spacebar
1 parent e03c4ac commit 0428634

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ <h2>Mines:</h2>
289289
background(255);
290290
game.drawGame();
291291
clickLogic();
292+
292293
if ((!mouseIsPressed || touches.count == 0) && lastClick) {
293294
buttonLogic();
294295
}
@@ -297,6 +298,18 @@ <h2>Mines:</h2>
297298
game.drawHUD();
298299
}
299300

301+
function keyPressed() {
302+
if (keyCode === 32) {
303+
let mX = Math.floor((mouseX - border) / cellSize);
304+
let mY = Math.floor((mouseY - headerSize - border) / cellSize);
305+
let cell = game.grid[mX + mY * game.width];
306+
307+
if (!cell.revealed) {
308+
game.flagCell(mX, mY);
309+
}
310+
}
311+
}
312+
300313
function clickLogic() {
301314
const shortcutsReveal = getPreferenceValue("shortcuts_reveal");
302315
const shortcutsFlag = getPreferenceValue("shortcuts_flag");

0 commit comments

Comments
 (0)