Skip to content

Commit

Permalink
fix bug play and reset
Browse files Browse the repository at this point in the history
  • Loading branch information
manu-cj committed May 2, 2024
1 parent 6bc9677 commit 665729e
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,50 @@ let play = document.querySelector('#play');
let stop = document.querySelector('#stop');
let reset = document.querySelector('#reset');

let timeOne = false;
let on = false;
let sound;
let score = 0;
let winPoint = 0;

function interval() {
on = true;
let interval = setInterval(() => {
let rand = Math.floor(Math.random(0) * divs.length);
timeOut(rand)
stop.addEventListener('click', () => {
clearInterval(interval);
second = 60;
score = 0;
one = false;
});
reset.addEventListener('click', () => {
clearInterval(interval);
second = 60;
score = 0;
on = false;
});
if (second === 1) {
clearInterval(interval);
}
}, 2000);
}, 1000);
}

play.addEventListener('click', () => {
interval();
timerPlay();
second = 60;
score = 0;
})
reset.addEventListener('click', () => {
interval();
timerPlay();
second = 60;
score = 0;
});

play.addEventListener('click', () => {
if(on === false) {
interval();
}
if (timeOne === false) {
timerPlay();
}
second = 60;
score = 0;
})







Expand Down Expand Up @@ -73,13 +81,14 @@ function timeOut(params) {
winPoint = 0;
}, 1000);
img.style.animationName = 'tomOut';
}, 1000);
}, 500);
}, 500);
}

let timer = document.getElementById('timer');
let second = 60;
function timerPlay() {
timeOne = true;
let time = setInterval(() => {
second--;
timer.innerText = `Timer : ${second} Secondes`;
Expand All @@ -90,7 +99,20 @@ function timerPlay() {
clearInterval(interval);
timer.innerText = `Timer : Temps écoulé`;
clearInterval(time);
timeOne = false;
on = false;
}

stop.addEventListener('click', () => {
clearInterval(time);
second = 60;
timer.innerText = `Timer : 60 Secondes`;
})
reset.addEventListener('click', () => {
clearInterval(time);
second = 60;
timer.innerText = `Timer : 60 Secondes`;
})
}, 1000);

}

0 comments on commit 665729e

Please sign in to comment.