add background theme

This commit is contained in:
taylor berukoff 2025-11-14 09:47:12 -10:00
parent e1cdd4ea1f
commit ff972809ec
2 changed files with 15 additions and 0 deletions

BIN
static/audio/theme.ogg Normal file

Binary file not shown.

View File

@ -13,6 +13,18 @@ document.addEventListener('DOMContentLoaded', () => {
let tokensRemaining = 5;
let inStreak = false;
// Set up them track
const bgMusic = new Audio("static/audio/theme.ogg");
bgMusic.loop = true;
bgMusic.volume = 0.15; // adjust to taste
// Some browsers block autoplay unless user interacts first
document.addEventListener("click", () => {
if (bgMusic.paused) {
bgMusic.play();
}
}, { once: true });
// Generate the board
for (let i=0; i < 5; i++) {
for (let j = 0; j < 5; j++) {
@ -54,6 +66,9 @@ document.addEventListener('DOMContentLoaded', () => {
// check for the player grabbing the player icon
player_token.addEventListener('pointerdown', (e) => {
e.preventDefault();
if (bgMusic.paused) {
bgMusic.play();
}
player_token.style.zIndex = "9999";
const rect = player_token.getBoundingClientRect();
player_token.style.width = `${rect.width}px`;