-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.js
29 lines (26 loc) · 882 Bytes
/
script.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
var b=document.querySelector('.start');
var btn2 = document.querySelector('.hide-reload')
var count = -1;
let getTime = Date.now();
window.onload=(event)=>{
setInterval(function(){
b.style.transform="translate("+(Math.floor(Math.random()*100)-50)+"vw,"+(Math.floor(Math.random()*100)-50)+"vh)"
}, 1075);
}
b.onclick = function () {
document.querySelector('audio').play();
count++;
document.querySelector('h3').innerHTML=count;
setInterval(function checkTime() {
let gameTime = Date.now() - getTime;
if (gameTime > 3000) {
result = document.querySelector('h3');
result.innerHTML = "You Have Lost";
b.classList.add('hide-ball')
btn2.classList.remove('hide-reload')
btn2.classList.add('show-reload')
}
}, 3000)
getTime = Date.now();
}
btn2.addEventListener('click', () => location.reload());