-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
87 lines (82 loc) · 2.8 KB
/
index.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
78
79
80
81
82
83
84
85
86
87
//Creates a listener to the page and the buttons
document.addEventListener("DOMContentLoaded", function() {
document.getElementById("miku").addEventListener("click", mikudayo);
document.getElementById("dance").addEventListener("click", dance);
document.getElementById("pan").addEventListener("click", pan);
document.getElementById("gasolina").addEventListener("click", gasolina);
document.getElementById("scream").addEventListener("click", scream);
var miku = document.getElementById('miku-img');
var isBusy = false; //Variable made to verify if Miku is doing something or not
var audio = null;
//Resets to the original image
function reiniciarImagem() {
miku.src = "./imgs/miku_standing.png"
isBusy = false;
}
//This function and onwards are functions called by the buttons on the page
function mikudayo() {
if(!isBusy) {
if(audio) {
audio.pause();
audio.currentTime = 0;
miku.src = "./imgs/miku_standing.png";
}
audio = new Audio('./sounds/mikudayo.mp3');
miku.src = "./imgs/miku_icon.png";
audio.play();
setTimeout(reiniciarImagem, 1500)
}
}
function dance() {
if(!isBusy) {
if(audio) {
audio.pause();
audio.currentTime = 0;
miku.src = "./imgs/miku_standing.png";
}
audio = new Audio("./sounds/sekai_de.mp3");
miku.src = "./imgs/miku_dancing.gif";
audio.play();
setTimeout(reiniciarImagem, 254000);
}
}
function pan() {
if(!isBusy) {
if(audio) {
audio.pause();
audio.currentTime = 0;
miku.src = "./imgs/miku_standing.png";
}
audio = new Audio("./sounds/pan.mp3");
miku.src = "./imgs/miku_bread.png";
audio.play();
setTimeout(reiniciarImagem, 800);
}
}
function gasolina() {
if(!isBusy) {
if(audio) {
audio.pause();
audio.currentTime = 0;
miku.src = "./imgs/miku_standing.png";
}
audio = new Audio("./sounds/gasolina.mp3");
miku.src = "./imgs/miku_dance_meme.gif";
audio.play();
setTimeout(reiniciarImagem, 5000);
}
}
function scream() {
if(!isBusy) {
if(audio) {
audio.pause();
audio.currentTime = 0;
miku.src = "./imgs/miku_standing.png";
}
audio = new Audio("./sounds/scream.mp3");
miku.src = "./imgs/miku_dying.png";
audio.play();
setTimeout(reiniciarImagem, 2500);
}
}
});