Pattern Weaver
Finish the pattern • Which One Belongs?
Leaderboard
You: 0
Best Streak
0
Icons
0
Pattern Weaver
Which One Belongs?
Pattern:
Choose next block
Next Pattern
Quick Controls
Next Question
Reset Score
Audio setup ------------------------------------------------------- */ const MUSIC=new Audio("assets/soft_loop1.wav"); MUSIC.loop=true; MUSIC.volume=0.22; const SFX={ click:new Audio("assets/button_click.wav"), jewels:new Audio("assets/jewels_01.wav"), level:new Audio("assets/level_up.wav"), over:new Audio("assets/game_over.mp3") }; const VOICE_LINES = [ new Audio("assets/ui/adorable.mp3"), new Audio("assets/ui/cute.mp3"), new Audio("assets/ui/goodchoice.mp3") ]; function playRandomVoiceLine(){ if(!VOICE_LINES.length) return; const i = Math.floor(Math.random()*VOICE_LINES.length); const a = VOICE_LINES[i]; try{ a.currentTime = 0; a.play(); }catch{} } let muted=false; let musicStarted=false; let userInteracted=false; /* helper: attempt music start */ function tryStartMusic(){ if(musicStarted || muted) return; musicStarted = true; try{ MUSIC.currentTime=0; MUSIC.play(); }catch(e){ // autoplay might still block, we'll retry after click musicStarted=false; } } /* global click sound + start music on first interaction */ document.addEventListener("click",(e)=>{ if(e.button===0){ userInteracted=true; // click sfx try{ SFX.click.currentTime=0; SFX.click.play(); }catch{} // music fallback: if we're in game, start bg music now if(viewGame.classList.contains('active') && !musicStarted && !muted){ tryStartMusic(); } } }); /* mute toggle */ btnMute.onclick=()=>{ muted=!muted; MUSIC.muted=muted; btnMute.textContent=muted?"🔇":"🔊"; if(!muted){ // if they unmute while in game, try to start if(viewGame.classList.contains('active')){ tryStartMusic(); } } };