add music
This commit is contained in:
parent
593a340b4a
commit
519014fb97
@ -18,6 +18,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<audio id="background-music" src="./sounds/The Pixel Anthem.mp3" loop></audio>
|
||||||
<template id="high-score-template">
|
<template id="high-score-template">
|
||||||
<div class="high-score">
|
<div class="high-score">
|
||||||
<span class="high-score-name"></span>
|
<span class="high-score-name"></span>
|
||||||
|
@ -8,6 +8,9 @@ function initGame() {
|
|||||||
|
|
||||||
initOrChangeDropInterval(game.speed);
|
initOrChangeDropInterval(game.speed);
|
||||||
|
|
||||||
|
music.currentTime = 0; // (optionnel) Remet au début
|
||||||
|
music.play();
|
||||||
|
|
||||||
|
|
||||||
// On rafraichit le plateau toutes les 16ms (environ 60 FPS)
|
// On rafraichit le plateau toutes les 16ms (environ 60 FPS)
|
||||||
refreshInterval = setInterval(() => {
|
refreshInterval = setInterval(() => {
|
||||||
|
@ -26,4 +26,6 @@ const highScoresList = document.getElementById('high-scores-list');
|
|||||||
|
|
||||||
const resumeButton = document.getElementById('resume-button');
|
const resumeButton = document.getElementById('resume-button');
|
||||||
const mainMenuButton = document.getElementById('main-menu-button');
|
const mainMenuButton = document.getElementById('main-menu-button');
|
||||||
const mainMenuButtonBis = document.getElementById('main-menu-button2');
|
const mainMenuButtonBis = document.getElementById('main-menu-button2');
|
||||||
|
|
||||||
|
const music = document.getElementById('background-music');
|
@ -302,6 +302,9 @@ async function finishGame(sendScore = true, gameOver = true) {
|
|||||||
displayMainMenu();
|
displayMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
music.pause();
|
||||||
|
music.currentTime = 0; // Remet au début
|
||||||
|
|
||||||
if (sendScore) {
|
if (sendScore) {
|
||||||
const playerName = prompt('Enter your name:');
|
const playerName = prompt('Enter your name:');
|
||||||
|
|
||||||
|
BIN
public/sounds/The Pixel Anthem.mp3
Normal file
BIN
public/sounds/The Pixel Anthem.mp3
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user