parent
18d17cbe3b
commit
e9b4f7749e
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minesweeper",
|
||||
"version": "0.0.9",
|
||||
"version": "0.0.10",
|
||||
"description": "Just Minesweeper!",
|
||||
"author": "Felix W. Dekker",
|
||||
"browser": "dist/bundle.js",
|
||||
|
|
|
@ -30,6 +30,9 @@ class Game {
|
|||
this.display = new Display(this.canvas, this.field);
|
||||
this.display.startDrawLoop();
|
||||
|
||||
this.leftDown = false;
|
||||
this.rightDown = false;
|
||||
|
||||
|
||||
this.solverForm.addEventListener(
|
||||
"submit",
|
||||
|
@ -57,7 +60,18 @@ class Game {
|
|||
);
|
||||
this.canvas.addEventListener(
|
||||
"mousedown",
|
||||
event => event.preventDefault()
|
||||
event => {
|
||||
event.preventDefault()
|
||||
|
||||
switch (event.button) {
|
||||
case 0:
|
||||
this.leftDown = true;
|
||||
break;
|
||||
case 2:
|
||||
this.rightDown = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
);
|
||||
this.canvas.addEventListener(
|
||||
"mouseup",
|
||||
|
@ -67,13 +81,23 @@ class Game {
|
|||
const square = this.display.posToSquare({x: event.clientX, y: event.clientY});
|
||||
switch (event.button) {
|
||||
case 0:
|
||||
square.uncover();
|
||||
if (this.leftDown && this.rightDown)
|
||||
square.chord();
|
||||
else
|
||||
square.uncover();
|
||||
|
||||
this.leftDown = false;
|
||||
break;
|
||||
case 1:
|
||||
square.chord();
|
||||
break;
|
||||
case 2:
|
||||
square.flag();
|
||||
if (this.leftDown && this.rightDown)
|
||||
square.chord();
|
||||
else
|
||||
square.flag();
|
||||
|
||||
this.rightDown = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue