diff --git a/js/dinosaur/dinosaur.js b/js/dinosaur/dinosaur.js index 64e15b5..52d0974 100644 --- a/js/dinosaur/dinosaur.js +++ b/js/dinosaur/dinosaur.js @@ -114,10 +114,10 @@ function updateGameContent() {
- `; loadScript("js/dinosaur/main.js"); + loadScript('https://cdn.jsdelivr.net/npm/canvas-confetti@1.9.3/dist/confetti.browser.min.js'); } function loadScript(src) { diff --git a/js/dinosaur/main.js b/js/dinosaur/main.js index eaf4b01..a7d546e 100644 --- a/js/dinosaur/main.js +++ b/js/dinosaur/main.js @@ -9,6 +9,8 @@ const buttons = gameControls.querySelectorAll("button"); const coinDino = document.querySelector("#coin"); game.classList.remove("hide"); + + let dinoAccountValues = { score: 0, lines: 0, @@ -657,7 +659,12 @@ scoreElement.textContent = `${Math.round(score.score)} - ${score.name}`; rankingList.appendChild(scoreElement); if (index === 0 && isNewTopScore) { + console.log(isNewTopScore); scoreElement.classList.add("flash-effect"); + + confetti({ + particleCount: 130 + }); } }); @@ -702,6 +709,7 @@ break; case "Enter": // 선택된 버튼의 클릭 이벤트를 강제 실행 + confetti.reset(); modalButtons[modalCurrentButtonIndex].click(); break; }