File size: 910 Bytes
910b729 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // Random flickering effect for horror atmosphere
document.addEventListener('DOMContentLoaded', () => {
// Randomly add flicker class to elements
const elements = document.querySelectorAll('.bg-dark-800, .bg-dark-700');
elements.forEach(el => {
if (Math.random() > 0.7) {
el.classList.add('flicker');
}
});
// Random creepy sound effect on page load (33% chance)
if (Math.random() > 0.66) {
const sounds = [
'https://assets.mixkit.co/sfx/preview/mixkit-creepy-laugh-1315.mp3',
'https://assets.mixkit.co/sfx/preview/mixkit-horror-laugh-1386.mp3',
'https://assets.mixkit.co/sfx/preview/mixkit-light-breath-1542.mp3'
];
const randomSound = sounds[Math.floor(Math.random() * sounds.length)];
const audio = new Audio(randomSound);
audio.volume = 0.3;
audio.play();
}
}); |