diff --git a/audios/else/countdown-sound.mp3 b/audios/else/countdown-sound.mp3 new file mode 100644 index 0000000..534eb42 Binary files /dev/null and b/audios/else/countdown-sound.mp3 differ diff --git a/js/dinosaur/dinosaur.js b/js/dinosaur/dinosaur.js index d51820e..64e15b5 100644 --- a/js/dinosaur/dinosaur.js +++ b/js/dinosaur/dinosaur.js @@ -42,6 +42,10 @@ function updateGameContent() { id="insertCoin" src="audios/else/insert-coin.mp3" > +

Coin: diff --git a/js/dinosaur/main.js b/js/dinosaur/main.js index 2eb7d55..eaf4b01 100644 --- a/js/dinosaur/main.js +++ b/js/dinosaur/main.js @@ -139,6 +139,7 @@

INSERT COIN

`; count--; + playSound("countdownSound"); if (count === -1) { clearInterval(countdownInterval); // 10초 카운트가 끝나면 아래 코드 실행 @@ -146,6 +147,7 @@ document.removeEventListener("keydown", onJump); document.removeEventListener("keydown", modalButtonSelection); document.removeEventListener("keydown", handleInsertKeyPress); + pauseMusic("countdownSound"); // 화면 조정 mainPage.style.transform = "scale(1)"; // 줌 아웃 mainPage.style.transition = ".5s"; @@ -154,7 +156,7 @@ // 게임 선택 화면 보이기 const gameSelection = document.getElementById("content"); - mainBgm.play(); + playSound("mainBgm"); gameSelection.innerHTML = `

← Dino →

@@ -174,12 +176,13 @@ // 화면 조정 mainPage.style.transform = "scale(1)"; // 줌 아웃 mainPage.style.transition = ".5s"; + pauseMusic("countdownSound"); gameStartDisplay.style.display = "block"; // 게임 선택 화면 보이기 const gameSelection = document.getElementById("content"); - mainBgm.play(); + playSound("mainBgm"); gameSelection.innerHTML = `

← Dino →

@@ -199,7 +202,7 @@ GlobalState.isGameActive = false; // 게임 종료 상태로 설정 clearInterval(countdownInterval); // 카운트 다운 인터벌 중지 - + pauseMusic("countdownSound"); // 카운트 다운 화면 제거 if (countdown) { countdown.remove(); diff --git a/js/tetris/main.js b/js/tetris/main.js index 7b42b7f..00d1397 100644 --- a/js/tetris/main.js +++ b/js/tetris/main.js @@ -517,10 +517,12 @@

INSERT COIN

`; count--; + countdownSound.play(); if (count === -1) { GlobalState.currentGame = null; clearInterval(countdownInterval); // 10초 카운트가 끝나면 아래 코드 실행 + countdownSound.pause(); // 화면 조정 mainPage.style.transform = "scale(1)"; // 줌 아웃 @@ -537,15 +539,14 @@ `; GlobalState.isGameActive = false; - countdown.remove(); - countdown.style.display = "none"; } }, 1000); const content = document.getElementById("content"); content.appendChild(countdown); } else { //countdown.style.display = "none"; - + document.removeEventListener("keydown", handleInsertKeyPress); + countdownSound.pause(); // 화면 조정 mainPage.style.transform = "scale(1)"; // 줌 아웃 mainPage.style.transition = ".5s"; @@ -576,6 +577,7 @@ GlobalState.isGameActive = true; // 게임 종료 상태로 설정 clearInterval(countdownInterval); // 카운트 다운 인터벌 중지 + countdownSound.pause(); // 카운트 다운 화면 제거 if (countdown) { diff --git a/js/tetris/sound.js b/js/tetris/sound.js index ecd68b1..32f8415 100644 --- a/js/tetris/sound.js +++ b/js/tetris/sound.js @@ -77,6 +77,10 @@ let sound = new Sound(document.querySelector("#sound-div")), escSound = sound.create("audios/else/esc-on.mp3", "esc_sound"), escMove = sound.create("audios/else/esc-move.mp3", "esc_move"), mainBgm = sound.create("audios/else/main-bgm.mp3", "main_bgm"), - insertCoin = sound.create("audios/else/insert-coin.mp3", "insert-coin"); + insertCoin = sound.create("audios/else/insert-coin.mp3", "insert-coin"), + countdownSound = sound.create( + "audios/else/countdown-sound.mp3", + "countdown-sound" + ); sound.muteToggle(); sound.soundSetting();