Skip to content

Commit

Permalink
Merge pull request #100 from KOPO-DA5/99-feat-카운트-다운-화면-사운드-추가
Browse files Browse the repository at this point in the history
99 feat 카운트 다운 화면 사운드 추가
  • Loading branch information
wldnjs7064 authored Apr 30, 2024
2 parents 67ad0f5 + 95703fb commit f511632
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
Binary file added audios/else/countdown-sound.mp3
Binary file not shown.
4 changes: 4 additions & 0 deletions js/dinosaur/dinosaur.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ function updateGameContent() {
id="insertCoin"
src="audios/else/insert-coin.mp3"
></audio>
<audio
id="countdownSound"
src="audios/else/countdown-sound.mp3" loop
></audio>
<div id="game" class="game hide">
<br>
<spa style="font-size: 12px">Coin: </spa>
Expand Down
9 changes: 6 additions & 3 deletions js/dinosaur/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@
<p>INSERT COIN</p>
`;
count--;
playSound("countdownSound");
if (count === -1) {
clearInterval(countdownInterval);
// 10초 카운트가 끝나면 아래 코드 실행
document.removeEventListener("keydown", handleKeyDown);
document.removeEventListener("keydown", onJump);
document.removeEventListener("keydown", modalButtonSelection);
document.removeEventListener("keydown", handleInsertKeyPress);
pauseMusic("countdownSound");
// 화면 조정
mainPage.style.transform = "scale(1)"; // 줌 아웃
mainPage.style.transition = ".5s";
Expand All @@ -154,7 +156,7 @@

// 게임 선택 화면 보이기
const gameSelection = document.getElementById("content");
mainBgm.play();
playSound("mainBgm");
gameSelection.innerHTML = `
<div id="game-selection">
<p id="selected-game">← Dino →</p>
Expand All @@ -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 = `
<div id="game-selection">
<p id="selected-game">← Dino →</p>
Expand All @@ -199,7 +202,7 @@

GlobalState.isGameActive = false; // 게임 종료 상태로 설정
clearInterval(countdownInterval); // 카운트 다운 인터벌 중지

pauseMusic("countdownSound");
// 카운트 다운 화면 제거
if (countdown) {
countdown.remove();
Expand Down
8 changes: 5 additions & 3 deletions js/tetris/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,12 @@
<p>INSERT COIN</p>
`;
count--;
countdownSound.play();
if (count === -1) {
GlobalState.currentGame = null;
clearInterval(countdownInterval);
// 10초 카운트가 끝나면 아래 코드 실행
countdownSound.pause();

// 화면 조정
mainPage.style.transform = "scale(1)"; // 줌 아웃
Expand All @@ -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";
Expand Down Expand Up @@ -576,6 +577,7 @@

GlobalState.isGameActive = true; // 게임 종료 상태로 설정
clearInterval(countdownInterval); // 카운트 다운 인터벌 중지
countdownSound.pause();

// 카운트 다운 화면 제거
if (countdown) {
Expand Down
6 changes: 5 additions & 1 deletion js/tetris/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

0 comments on commit f511632

Please sign in to comment.