add background theme
This commit is contained in:
parent
e1cdd4ea1f
commit
ff972809ec
Binary file not shown.
|
|
@ -13,6 +13,18 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
let tokensRemaining = 5;
|
let tokensRemaining = 5;
|
||||||
let inStreak = false;
|
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
|
// Generate the board
|
||||||
for (let i=0; i < 5; i++) {
|
for (let i=0; i < 5; i++) {
|
||||||
for (let j = 0; j < 5; j++) {
|
for (let j = 0; j < 5; j++) {
|
||||||
|
|
@ -54,6 +66,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
// check for the player grabbing the player icon
|
// check for the player grabbing the player icon
|
||||||
player_token.addEventListener('pointerdown', (e) => {
|
player_token.addEventListener('pointerdown', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
if (bgMusic.paused) {
|
||||||
|
bgMusic.play();
|
||||||
|
}
|
||||||
player_token.style.zIndex = "9999";
|
player_token.style.zIndex = "9999";
|
||||||
const rect = player_token.getBoundingClientRect();
|
const rect = player_token.getBoundingClientRect();
|
||||||
player_token.style.width = `${rect.width}px`;
|
player_token.style.width = `${rect.width}px`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue