feat: add sounds after game end

This commit is contained in:
chocomett 2025-12-15 22:22:03 +07:00
parent 326f313a0e
commit ca7ee140fb
4 changed files with 9 additions and 7 deletions

View File

@ -1,4 +1,5 @@
@import url('https://fonts.googleapis.com/css2?family=Jersey+15&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Jersey+15&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&display=swap');
*{ *{
font-family: "Jersey 15", sans-serif; font-family: "Jersey 15", sans-serif;
margin: 0; margin: 0;

View File

@ -16,6 +16,7 @@
<audio id="bgm" src="/assets/music/game.mp3" loop autoplay></audio> <audio id="bgm" src="/assets/music/game.mp3" loop autoplay></audio>
<audio id="sfx" src="/assets/music/slash.mp3"></audio> <audio id="sfx" src="/assets/music/slash.mp3"></audio>
<audio id="sfxhrt" src="/assets/music/hurt.mp3"></audio> <audio id="sfxhrt" src="/assets/music/hurt.mp3"></audio>
<audio id="win" src="/assets/music/Super Mario Bros. Music - Level Complete.mp3"></audio>
<div class="container-first"> <div class="container-first">
<div class="content"> <div class="content">
<div class="boss"> <div class="boss">

View File

@ -107,9 +107,7 @@ function selectAnswer(e){
bgm.play() bgm.play()
if(wrongCount >= maxWrong){ if(wrongCount >= maxWrong){
setTimeout(()=>{ showScore();
showScore();
}, 500);
return; return;
} }
} }
@ -127,13 +125,15 @@ function showScore(){
document.getElementById("h1").remove(); document.getElementById("h1").remove();
document.getElementById("h2").remove(); document.getElementById("h2").remove();
document.getElementById("h3").remove(); document.getElementById("h3").remove();
const bgm = document.getElementById("win");
bgm.play()
setTimeout(()=> { setTimeout(()=> {
const bgm = document.getElementById("sfxhrt");
bgm.play()
const alerts = document.getElementById("scoreAlert") const alerts = document.getElementById("scoreAlert")
alerts.textContent = `you scored ${score} out of 200 !`; alerts.textContent = `you scored ${score} out of 200 !`;
}, 600); }, 200);
postScore(score); setTimeout(()=> {
postScore(score);
}, 3200);
} }
function handleNextBtn(){ function handleNextBtn(){