add music

This commit is contained in:
florian 2025-06-11 23:30:28 +02:00
parent 593a340b4a
commit 519014fb97
5 changed files with 10 additions and 1 deletions

View File

@ -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>

View File

@ -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(() => {

View File

@ -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');

View File

@ -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:');

Binary file not shown.