0 Comments

// Definir posición inicial del jugador en la parte inferior let playerX = 275; let playerY = 750; const player = document.getElementById(“player”); function updatePlayerPosition() { player.style.left = Math.max(0, Math.min(550, playerX)) + “px”; player.style.top = Math.max(0, Math.min(750, playerY)) + “px”; } updatePlayerPosition(); // 🎨 Luces y efectos de concierto (Fondo parpadeante) function changeBackground() { const colors = [“gray”, “darkgray”, “black”, “#222”]; document.getElementById(“game-container”).style.backgroundColor = colors[Math.floor(Math.random() * colors.length)]; } setInterval(changeBackground, 500); // 💨 Animación de impacto (Sacudir pantalla) function shakeScreen() { let game = document.getElementById(“game-container”); game.style.transform = “translate(3px, 3px)”; setTimeout(() => { game.style.transform = “translate(-3px, -3px)”; }, 50); setTimeout(() => { game.style.transform = “translate(0, 0)”; }, 100); } // 🔥 Efectos de fuego al llegar al escenario function fireEffect() { let fire = document.createElement(“div”); fire.style.position = “absolute”; fire.style.width = “80px”; fire.style.height = “80px”; fire.style.left = playerX + “px”; fire.style.top = playerY + “px”; fire.style.background = “orange”; fire.style.borderRadius = “50%”; fire.style.opacity = “0.7”; document.getElementById(“game-container”).appendChild(fire); setTimeout(() => { fire.remove(); }, 500); } // 🧠 IA para obstáculos inteligentes function createObstacles() { for (let i = 0; i < 5; i++) { const obstacle = document.createElement("div"); obstacle.classList.add("obstacle"); document.getElementById("game-container").appendChild(obstacle); let startX = Math.random() * 550; let startY = Math.random() * 750; obstacle.style.left = startX + "px"; obstacle.style.top = startY + "px"; let velocityX = (Math.random() * 4) - 2; let velocityY = (Math.random() * 4) - 2; let vibrationDirection = Math.random() < 0.5 ? -1 : 1; function moveObstacle() { let currentX = parseInt(obstacle.style.left); let currentY = parseInt(obstacle.style.top); let targetX = playerX; let targetY = playerY; let moveX = (targetX - currentX) / 80; let moveY = (targetY - currentY) / 80; if (Math.random() < 0.1) { vibrationDirection *= -1; } obstacle.style.left = Math.max(0, Math.min(550, currentX + moveX + (Math.random() * 4 - 2))) + "px"; obstacle.style.top = Math.max(0, Math.min(750, currentY + moveY + (vibrationDirection * 2))) + "px"; if ( Math.abs(currentX - playerX) < 50 && Math.abs(currentY - playerY) < 50 ) { shakeScreen(); alert("¡Te derribaron en el mosh pit!"); location.reload(); } requestAnimationFrame(moveObstacle); } moveObstacle(); } } setInterval(createObstacles, 1000); // Generar obstáculos más rápido

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Post Relacionados