-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnekoatsume.js
77 lines (62 loc) · 2.04 KB
/
nekoatsume.js
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//Author vyclu20
const button1 = document.getElementById("button1");
const button2 = document.getElementById("button2");
const button3 = document.getElementById("button3");
const button4 = document.getElementById("button4");
const gif = document.getElementById("gif");
const musicCat = document.getElementById("music-cat");
const closeBtn = document.getElementById("closeBtn");
let isMusicPlaying = false;
let audio = new Audio('bgmusic.mp3');
button1.addEventListener("click", function() {
gif.src = "bandit.png";
});
button2.addEventListener("click", function() {
gif.src = "peaches.png";
});
button3.addEventListener("click", function() {
gif.src = "sunny.png";
});
button4.addEventListener("click", function() {
gif.src = "ginger.png";
});
function showPopup() {
var popup = document.getElementById("popup");
popup.style.display = "block";
}
function hidePopup() {
var popup = document.getElementById("popup");
popup.style.display = "none";
}
gif.addEventListener("click", showPopup);
closeBtn.addEventListener("click", hidePopup);
function toggleMusic() {
if (!isMusicPlaying) {
audio.play();
musicCat.src = "musiccat2.png";
isMusicPlaying = true;
} else {
audio.pause();
musicCat.src = "musiccat.png";
isMusicPlaying = false;
}
}
//This is to change the png images to gifs when firing the go button
const goButton = document.getElementById("go-button");
goButton.addEventListener("click", function() {
const numLoops = document.getElementById("loops").value;
let imageSrc = "";
if (gif.src.includes("bandit.png")) {
imageSrc = "bandit.gif";
} else if (gif.src.includes("peaches.png")) {
imageSrc = "peaches.gif";
} else if (gif.src.includes("sunny.png")) {
imageSrc = "sunny.gif";
} else if (gif.src.includes("ginger.png")) {
imageSrc = "ginger.gif";
}
gif.src = imageSrc;
setTimeout(function() {
gif.src = gif.src.replace(".gif", ".png");
}, numLoops * 1690); //duration of gif, of each loop
});