diff --git a/WebGames-master/WebGames-master/index.html b/WebGames-master/WebGames-master/index.html index d42df5b0..a6bedc08 100644 --- a/WebGames-master/WebGames-master/index.html +++ b/WebGames-master/WebGames-master/index.html @@ -919,6 +919,28 @@ }); } }; + + // Check if music is enabled + const musicEnabled = getCookie('backgroundMusic') === 'true'; + const backgroundMusic = document.getElementById('backgroundMusic'); + + if (musicEnabled) { + backgroundMusic.volume = 0.5; // Set volume to 50% + backgroundMusic.play(); // Play the music + } else { + backgroundMusic.pause(); // Pause the music + } + + // Function to toggle music + function toggleMusic() { + const musicEnabled = getCookie('backgroundMusic') === 'true'; + setCookie('backgroundMusic', !musicEnabled, 30); // Toggle music state + if (!musicEnabled) { + backgroundMusic.play(); + } else { + backgroundMusic.pause(); + } + } \ No newline at end of file diff --git a/index.html b/index.html index ac97cd21..a72672e6 100644 --- a/index.html +++ b/index.html @@ -119,6 +119,9 @@
+ + +