/* ----------------------------- Black Velvet Flower Respawn + Click Sound ------------------------------*/ (function(){ const flower = document.getElementById("velvetFlower"); // Load click sound const clickSound = new Audio("sounds/click.mp3"); function randomPos(){ const x = Math.random() * (window.innerWidth - 320); const y = Math.random() * (window.innerHeight - 320); flower.style.left = x + "px"; flower.style.top = y + "px"; } // Initial spawn randomPos(); // Gentle drifting animation setInterval(()=>{ const driftX = (Math.random() * 60) - 30; const driftY = (Math.random() * 60) - 30; flower.style.transform = `translate(${driftX}px, ${driftY}px)`; }, 2000); // Respawn + click sound flower.addEventListener("click", ()=>{ clickSound.currentTime = 0; // restart sound clickSound.play(); // play click flower.style.transform = "scale(0.7)"; setTimeout(()=>{ randomPos(); flower.style.transform = "scale(1)"; }, 300); }); })();