-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWaM.js
More file actions
54 lines (50 loc) · 1.28 KB
/
Copy pathWaM.js
File metadata and controls
54 lines (50 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
function toggleMole(att = this) {
if ($(att).attr("src") == "noMole.svg") {
$(att).attr("src", "mole.svg");
} else {
$(att).attr("src", "noMole.svg");
}
}
function randomToggler() {
let i = Math.floor(9 * Math.random());
let img = $(`img:eq(${i})`);
const moleUp = setTimeout(function () {
toggleMole(img);
}, 300);
const moleDown = setTimeout(function () {
if ($(img).attr("src") == "mole.svg") {
toggleMole(img);
missedCount++;
}
}, 900);
}
//$(".stop").toggle();
function startGame() {
const toggler = setInterval(randomToggler, 700);
$(".stop").toggle();
$(".start").toggle();
$(".points").text(0);
$(".game").removeClass("blur");
$(".stop").click(function stopGame() {
clearInterval(toggler);
$(".stop").hide();
$(".start").show();
$(".game").addClass("blur");
});
}
$(".start").click(startGame);
let missedCount = 0;
$(".game").mousedown(function slam() {
$(this).addClass("cursor90");
});
$(".game").mouseup(function slam() {
$(this).removeClass("cursor90");
});
$("img").click(function () {
if ($(this).attr("src") == "mole.svg") {
$(".points").text(function (i, value) {
return Number(value) + 1;
});
$(this).attr("src", "noMole.svg");
}
});