// Funciones de verificación
function checkLyrics(answer) {
const input = document.getElementById('lyricsInput').value.toLowerCase();
const result = document.getElementById('lyricsResult');
// Función mejorada para generar nuevos juegos
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame(),
createUnscrambleGame(),
createTimelineGame()
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
initializeTimeline();
}
// Sistema de logros
const achievements = {
perfectStreak: { name: "Racha Perfecta", description: "Obtén una racha de 10 respuestas correctas", unlocked: false },
highScore: { name: "Alta Puntuación", description: "Alcanza 5000 puntos", unlocked: false },
masterLevel: { name: "Nivel Maestro", description: "Alcanza el nivel 5", unlocked: false }
};
function checkAchievements() {
if (gameState.streak >= 10 && !achievements.perfectStreak.unlocked) {
unlockAchievement('perfectStreak');
}
if (gameState.score >= 5000 && !achievements.highScore.unlocked) {
unlockAchievement('highScore');
}
if (gameState.level >= 5 && !achievements.masterLevel.unlocked) {
unlockAchievement('masterLevel');
}
}
function unlockAchievement(achievementId) {
achievements[achievementId].unlocked = true;
createConfetti();
alert(`¡Logro Desbloqueado! ${achievements[achievementId].name}\n${achievements[achievementId].description}`);
}
// Inicialización mejorada
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
}; corrige el codigo
Assistant
To enhance the clarity and functionality of your code, I've made essential corrections and optimizations. I focused on ensuring that the game initializes correctly, improves the script load process, and organizes the logic within the script. Here is the revised JavaScript part:
html
User
podemos agregar mas juegos?
Assistant
¡Por supuesto! Puedes expandir tu juego añadiendo nuevas categorías o tipos de minijuegos. Aquí tienes algunas ideas para nuevos juegos que podrías implementar:
1. Juego de Sopa de Letras
Objetivo: Encontrar palabras relacionadas con Taylor Swift en una sopa de letras.
Objetivo: Responder si los enunciados sobre Taylor Swift son verdaderos o falsos.
javascript
User
code
Assistant
Cuando los nuevos juegos no funcionan como esperas, es fundamental revisar varios aspectos del código para identificar posibles problemas. A continuación, identificaré algunas mejoras para las funciones de los nuevos juegos que implementaste.
1. Revisión de funciones y eventos
Los nuevos juegos deben estar bien integrados y definidos. Aquí tienes algunos puntos para revisar y corregir:
Juego de Sopa de Letras
Por ahora, esta función solo genera una tabla con letras, pero no permite la interacción del usuario. Te recomiendo empezar con un juego básico y luego añadir características interactivas.
Juego de Verdadero/Falso
Asegúrate de que las funciones checkTrueFalse están correctamente conectadas. La función de verificación parece estar bien, solo revisa que cada juego tenga un elemento id único dentro del HTML para el resultado, como trueFalseResult.
Juego de Preguntas con Tiempo
El juego de preguntas con tiempo necesita manejar correctamente un intervalo global. Aquí podemos introducir una mejora:
javascript
function createTimedQuizGame() {
let timeRemaining = 30; // 30 seconds
const question = { question: "¿Cuál es el álbum más vendido de Taylor Swift?", answer: "1989" };
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Quiz de Tiempo</h2>
<p>${question.question}</p>
<input type="text" id="timedQuizInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTimedQuiz('${question.answer}')">Verificar</button>
<div id="timedQuizResult" class="result"></div>
<div id="timerDisplay">Tiempo: ${timeRemaining} segundos</div>
`;
let timerInterval = setInterval(() => {
if (timeRemaining > 0) {
timeRemaining--;
document.getElementById('timerDisplay').textContent = `Tiempo: ${timeRemaining} segundos`;
} else {
clearInterval(timerInterval);
document.getElementById('timedQuizResult').textContent = "¡Tiempo agotado! 😊";
}
}, 1000);
gameCard.timerInterval = timerInterval; // Store it on the gameCard for later reference
return gameCard;
}
function checkTimedQuiz(answer) {
const input = document.getElementById('timedQuizInput').value.toLowerCase();
const result = document.getElementById('timedQuizResult');
// Ensure that the correct timer is cleared
const gameCard = input.closest('.game-card');
clearInterval(gameCard.timerInterval);
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
User
te comparto el codigo corrigelo
code
Assistant
Al revisar el código HTML y JavaScript proporcionado, me he asegurado de corregir algunos errores comunes y sugerir mejoras para que los juegos nuevos funcionen correctamente. Aquí tienes el código corregido con comentarios sobre los ajustes realizados:
html
User
Al siguiente codigo corrige la sopa de letras para qeu funcione correctamente, añade mas preguntas en el quiz de tiempo en todos los demas juegos, y agrega mas juegos y agrega un boton que refresque la pagina una vesz resuelvan bien todos los juegos
code
Assistant
Vamos a corregir y mejorar la funcionalidad del código para asegurarnos de que los juegos se ejecutan correctamente. Aquí se presentan las modificaciones solicitadas, incluidas mejoras en la sopa de letras, más preguntas para el quiz de tiempo en otros juegos, agregar más juegos y un botón para refrescar la página después de completar todos los juegos exitosamente.
Código Corregido y Mejorado:
html
User
corrige el codigo para que funcione bien la sopa de letras
code
Assistant
Vamos a mejorar el juego de la Sopa de Letras para que sea interactivo. Para lograr que funcione correctamente, debemos permitir a los usuarios seleccionar letras para formar las palabras, y luego comprobar si las palabras seleccionadas son correctas.
A continuación, encontrarás el código corregido y mejorado para el juego de Sopa de Letras, con funcionalidades básicas de selección e interacción:
html
User
pero muestrame como querdaria todo el codigo con los demas juegos todo
Assistant
¡Por supuesto! Aquí tienes el código completo con la funcionalidad mejorada para la Sopa de Letras y los otros juegos incluidos. El juego de la Sopa de Letras ahora permite seleccionar letras y verificar si forman palabras válidas. También he mantenido e integrado el resto de los juegos:
<script>
// Banco de preguntas y respuestas
const questionBank = {
lyrics: [
{ lyric: "Cause baby I'm a _________", answer: "nightmare" },
{ lyric: "Are we out of the _________?", answer: "woods" },
{ lyric: "I stay up too _________ ", answer: "late" },
{ lyric: "Nice to meet you, where you _________", answer: "been" },
{ lyric: "We are never ever ever getting back _________", answer: "together" },
{ lyric: "I knew you were _________ when you walked in", answer: "trouble" },
{ lyric: "Shake it _________, shake it off", answer: "off" },
{ lyric: "Look what you made me _________", answer: "do" },
{ lyric: "Baby just say _________", answer: "yes" },
{ lyric: "I'm feeling twenty-_________ everything", answer: "two" },
{ lyric: "All of the _________ (all of the _________)", answer: "lights" },
{ lyric: "Out of the _________, into the rain", answer: "dark" },
{ lyric: "Meet me at _________ ", answer: "midnight" },
{ lyric: "Karma is my _________ star", answer: "lucky" },
{ lyric: "It's me, hi, I'm the _________", answer: "problem" },
{ lyric: "Draw the _________ wide", answer: "curtains" },
{ lyric: "Paint the town _________ ", answer: "red" },
{ lyric: "Dancing with our hands _________", answer: "tied" },
{ lyric: "I had a marvelous _________", answer: "time" },
{ lyric: "Welcome to New _________ ", answer: "york" }
],
albums: [
{ song: "Love Story", album: "fearless" },
{ song: "Shake It Off", album: "1989" },
{ song: "Cardigan", album: "folklore" },
{ song: "Anti-Hero", album: "midnights" },
{ song: "Cruel Summer", album: "lover" },
{ song: "All Too Well", album: "red" },
{ song: "Enchanted", album: "speak now" },
{ song: "Tim McGraw", album: "taylor swift" },
{ song: "August", album: "folklore" },
{ song: "Karma", album: "midnights" },
{ song: "You Belong With Me", album: "fearless" },
{ song: "Blank Space", album: "1989" },
{ song: "Willow", album: "evermore" },
{ song: "Lavender Haze", album: "midnights" },
{ song: "Lover", album: "lover" }
],
trivia: [
{ question: "¿En qué año nació Taylor Swift?", answer: "1989" },
{ question: "¿Cuál fue su primer álbum de estudio?", answer: "taylor swift" },
{ question: "¿En qué ciudad nació Taylor?", answer: "reading" },
{ question: "¿Cuál es el nombre de su gato blanco?", answer: "benjamin button" },
{ question: "¿Qué número considera Taylor su favorito?", answer: "13" },
{ question: "¿En qué año lanzó '1989'?", answer: "2014" },
{ question: "¿Qué instrumento tocaba Taylor en sus inicios?", answer: "guitarra" },
{ question: "¿Cuál fue su primer sencillo número 1 en Billboard Hot 100?", answer: "shake it off" },
{ question: "¿En qué estado creció Taylor?", answer: "pennsylvania" },
{ question: "¿Cuántos álbumes ha regrabado hasta 2024?", answer: "4" }
],
unscramble: [
{ word: "FEARLESS", hint: "Álbum que incluye 'Love Story'" },
{ word: "SWIFTIE", hint: "Nombre que reciben los fans de Taylor" },
{ word: "FOLKLORE", hint: "Álbum sorpresa lanzado en 2020" },
{ word: "REPUTATION", hint: "Álbum con serpientes como símbolo" },
{ word: "ENCHANTED", hint: "Canción de Speak Now que se hizo viral en TikTok" }
],
timeline: [
{ event: "Lanzamiento de Taylor Swift", year: 2006 },
{ event: "Lanzamiento de Fearless", year: 2008 },
{ event: "Lanzamiento de Speak Now", year: 2010 },
{ event: "Lanzamiento de Red", year: 2012 },
{ event: "Lanzamiento de 1989", year: 2014 }
],
memoryPairs: [
"1989", "Red", "Fearless", "Speak Now",
"Folklore", "Evermore", "Midnights", "Lover",
"Reputation", "Taylor Swift"
]
};
// Estado del juego
let gameState = {
level: 1,
score: 0,
streak: 0,
highScore: parseInt(localStorage.getItem('taylorHighScore')) || 0,
usedQuestions: {
lyrics: [],
albums: [],
trivia: [],
unscramble: [],
timeline: []
},
memoryGame: {
flippedCards: [],
matchedPairs: 0
}
};
// Funciones auxiliares
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function createConfetti() {
for(let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.backgroundColor = ['#ff8fab', '#ffc2d1', '#ffb3c6', '#ff69b4'][Math.floor(Math.random() * 4)];
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
function updateStats() {
document.getElementById('level').textContent = gameState.level;
document.getElementById('score').textContent = gameState.score;
document.getElementById('streak').textContent = gameState.streak;
document.getElementById('highScore').textContent = gameState.highScore;
}
function correctAnswer() {
const points = 100 * gameState.level;
gameState.score += points;
gameState.streak++;
if(gameState.score > gameState.highScore) {
gameState.highScore = gameState.score;
localStorage.setItem('taylorHighScore', gameState.highScore);
}
if(gameState.streak % 3 === 0) {
gameState.level++;
createConfetti();
setTimeout(generateNewGames, 1500);
}
updateStats();
document.dispatchEvent(new Event('scoreUpdate'));
return points;
}
function wrongAnswer() {
gameState.streak = 0;
updateStats();
}
// Creación de juegos
function createLyricsGame() {
const unusedLyrics = questionBank.lyrics.filter(q => !gameState.usedQuestions.lyrics.includes(q.lyric));
if (unusedLyrics.length === 0) {
gameState.usedQuestions.lyrics = [];
}
const question = getRandomItem(unusedLyrics);
gameState.usedQuestions.lyrics.push(question.lyric);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Completa la Letra</h2>
<p>${question.lyric}</p>
<input type="text" id="lyricsInput" placeholder="Completa la letra">
<button class="btn" onclick="checkLyrics('${question.answer}')">Verificar</button>
<div id="lyricsResult" class="result"></div>
`;
return gameCard;
}
function createAlbumGame() {
const unusedAlbums = questionBank.albums.filter(q => !gameState.usedQuestions.albums.includes(q.song));
if (unusedAlbums.length === 0) {
gameState.usedQuestions.albums = [];
}
const question = getRandomItem(unusedAlbums);
gameState.usedQuestions.albums.push(question.song);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>¿De Qué Álbum Es?</h2>
<p>¿En qué álbum aparece "${question.song}"?</p>
<input type="text" id="albumInput" placeholder="Nombre del álbum">
<button class="btn" onclick="checkAlbum('${question.album}')">Verificar</button>
<div id="albumResult" class="result"></div>
`;
return gameCard;
}
function createTriviaGame() {
const unusedTrivia = questionBank.trivia.filter(q => !gameState.usedQuestions.trivia.includes(q.question));
if (unusedTrivia.length === 0) {
gameState.usedQuestions.trivia = [];
}
const question = getRandomItem(unusedTrivia);
gameState.usedQuestions.trivia.push(question.question);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Trivia Swiftie</h2>
<p>${question.question}</p>
<input type="text" id="triviaInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTrivia('${question.answer}')">Verificar</button>
<div id="triviaResult" class="result"></div>
`;
return gameCard;
}
function createMemoryGame() {
const gameCard = document.createElement('div');
gameCard.className = 'game-card memory-game';
gameCard.innerHTML = `
<h2>Memoria Taylor</h2>
<div class="memory-grid" id="memoryGrid"></div>
<div id="memoryResult" class="result"></div>
`;
return gameCard;
}
// Funciones de verificación
function checkLyrics(answer) {
const input = document.getElementById('lyricsInput').value.toLowerCase();
const result = document.getElementById('lyricsResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkAlbum(answer) {
const input = document.getElementById('albumInput').value.toLowerCase();
const result = document.getElementById('albumResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkTrivia(answer) {
const input = document.getElementById('triviaInput').value.toLowerCase();
const result = document.getElementById('triviaResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
// Juego de memoria
function startMemoryGame() {
const grid = document.getElementById('memoryGrid');
if (!grid) return;
// Crear pares de cartas
const pairs = [...questionBank.memoryPairs];
const cards = [...pairs, ...pairs];
cards.sort(() => Math.random() - 0.5);
grid.innerHTML = cards.map((card, index) => `
<div class="memory-card" data-index="${index}" data-value="${card}">
<div class="memory-card-inner">
<div class="memory-card-front">?</div>
<div class="memory-card-back">${card}</div>
</div>
</div>
`).join('');
// Agregar eventos
grid.querySelectorAll('.memory-card').forEach(card => {
card.addEventListener('click', handleMemoryCardClick);
});
}
function handleMemoryCardClick() {
const card = this;
if (
card.classList.contains('flipped') ||
gameState.memoryGame.flippedCards.length >= 2
) return;
card.classList.add('flipped');
gameState.memoryGame.flippedCards.push(card);
if (gameState.memoryGame.flippedCards.length === 2) {
setTimeout(checkMemoryMatch, 1000);
}
}
function checkMemoryMatch() {
const [card1, card2] = gameState.memoryGame.flippedCards;
const match = card1.dataset.value === card2.dataset.value;
if (match) {
gameState.memoryGame.matchedPairs++;
const points = correctAnswer();
document.getElementById('memoryResult').textContent = `¡Par encontrado! +${points} puntos 🎉`;
if (gameState.memoryGame.matchedPairs === questionBank.memoryPairs.length) {
document.getElementById('memoryResult').textContent = "¡Juego completado! 🎉";
setTimeout(generateNewGames, 1500);
}
} else {
card1.classList.remove('flipped');
card2.classList.remove('flipped');
wrongAnswer();
}
gameState.memoryGame.flippedCards = [];
}
// Sistema de guardado
function saveProgress() {
const saveData = {
gameState: gameState,
timestamp: Date.now()
};
localStorage.setItem('taylorGameState', JSON.stringify(saveData));
}
function loadProgress() {
const saved = localStorage.getItem('taylorGameState');
if (saved) {
const saveData = JSON.parse(saved);
if (Date.now() - saveData.timestamp < 24 * 60 * 60 * 1000) { // 1 day
gameState = saveData.gameState;
} else {
localStorage.removeItem('taylorGameState');
}
}
updateStats();
}
// Función mejorada para generar nuevos juegos
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame()
// Note: You must ensure that functions like createUnscrambleGame() and createTimelineGame() exist if used.
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
// Add initializations for other game types here
}
// Sistema de logros
const achievements = {
perfectStreak: { name: "Racha Perfecta", description: "Obtén una racha de 10 respuestas correctas", unlocked: false },
highScore: { name: "Alta Puntuación", description: "Alcanza 5000 puntos", unlocked: false },
masterLevel: { name: "Nivel Maestro", description: "Alcanza el nivel 5", unlocked: false }
};
function checkAchievements() {
if (gameState.streak >= 10 && !achievements.perfectStreak.unlocked) {
unlockAchievement('perfectStreak');
}
if (gameState.score >= 5000 && !achievements.highScore.unlocked) {
unlockAchievement('highScore');
}
if (gameState.level >= 5 && !achievements.masterLevel.unlocked) {
unlockAchievement('masterLevel');
}
}
function unlockAchievement(achievementId) {
achievements[achievementId].unlocked = true;
createConfetti();
alert(`¡Logro Desbloqueado! ${achievements[achievementId].name}\n${achievements[achievementId].description}`);
}
// Inicialización mejorada
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
};
</script>
Key Changes:
Initialization and Event Binding: Ensuring onclick and addEventListener are correctly set up post DOM readiness.
Dynamic Elements: Created functions to handle dynamic game creation and manage events carefully.
Game State Management: Improved logic to save and load game progress with expiry.
Completeness Check: Function calls like generateNewGames() were completed to make sure they initialize the expected games.
Make sure to replace placeholders and ensure all functions that are referred within comments (for unsolved parts) are correctly defined in your actual HTML file where this script will be integrated.
function createTrueFalseGame() {
const questions = [
{ question: "Taylor Swift tiene un álbum llamado 'Midnights'", correct: true },
{ question: "Taylor nació en California", correct: false }
// Add more questions
];
const question = getRandomItem(questions);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Verdadero o Falso</h2>
<p>${question.question}</p>
<button class="btn" onclick="checkTrueFalse(${question.correct}, true)">Verdadero</button>
<button class="btn" onclick="checkTrueFalse(${question.correct}, false)">Falso</button>
<div id="trueFalseResult" class="result"></div>
`;
return gameCard;
}
function checkTrueFalse(correct, answer) {
const result = document.getElementById('trueFalseResult');
if (correct === answer) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
3. Juego de Quiz de Tiempo
Objetivo: Responder preguntas antes de que se acabe el tiempo.
javascript
function createTimedQuizGame() {
let timeRemaining = 30; // 30 seconds
const question = { question: "¿Cuál es el álbum más vendido de Taylor Swift?", answer: "1989" };
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Quiz de Tiempo</h2>
<p>${question.question}</p>
<input type="text" id="timedQuizInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTimedQuiz('${question.answer}')">Verificar</button>
<div id="timedQuizResult" class="result"></div>
<div id="timerDisplay">Tiempo: ${timeRemaining} segundos</div>
`;
const timerInterval = setInterval(() => {
if (timeRemaining > 0) {
timeRemaining--;
document.getElementById('timerDisplay').textContent = `Tiempo: ${timeRemaining} segundos`;
} else {
clearInterval(timerInterval);
document.getElementById('timedQuizResult').textContent = "¡Tiempo agotado! 😊";
}
}, 1000);
return gameCard;
}
function checkTimedQuiz(answer) {
const input = document.getElementById('timedQuizInput').value.toLowerCase();
const result = document.getElementById('timedQuizResult');
if (input === answer.toLowerCase()) {
clearInterval(timerInterval); // stop the timer
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
To Implement:
Add these functions to your existing generateNewGames or similar initialization function.
Make sure to appropriately initialize any necessary variables or DOM elements for these games.
This approach can create a robust, engaging mini-game platform centered around Taylor Swift for fans to enjoy. You can customize, expand, and add more features as you progress.
<div class="stats">
<div>Nivel: <span id="level">1</span></div>
<div>Puntos: <span id="score">0</span></div>
<div>Racha: <span id="streak">0</span></div>
<div>Mejor Puntuación: <span id="highScore">0</span></div>
</div>
<div class="games-container" id="gamesContainer"></div>
<script>
// Banco de preguntas y respuestas
const questionBank = {
lyrics: [
{ lyric: "Cause baby I'm a _________", answer: "nightmare" },
{ lyric: "Are we out of the _________?", answer: "woods" },
{ lyric: "I stay up too _________ ", answer: "late" },
{ lyric: "Nice to meet you, where you _________", answer: "been" },
{ lyric: "We are never ever ever getting back _________", answer: "together" },
{ lyric: "I knew you were _________ when you walked in", answer: "trouble" },
{ lyric: "Shake it _________, shake it off", answer: "off" },
{ lyric: "Look what you made me _________", answer: "do" },
{ lyric: "Baby just say _________", answer: "yes" },
{ lyric: "I'm feeling twenty-_________ everything", answer: "two" },
{ lyric: "All of the _________ (all of the _________)", answer: "lights" },
{ lyric: "Out of the _________, into the rain", answer: "dark" },
{ lyric: "Meet me at _________ ", answer: "midnight" },
{ lyric: "Karma is my _________ star", answer: "lucky" },
{ lyric: "It's me, hi, I'm the _________", answer: "problem" },
{ lyric: "Draw the _________ wide", answer: "curtains" },
{ lyric: "Paint the town _________ ", answer: "red" },
{ lyric: "Dancing with our hands _________", answer: "tied" },
{ lyric: "I had a marvelous _________", answer: "time" },
{ lyric: "Welcome to New _________ ", answer: "york" }
],
albums: [
{ song: "Love Story", album: "fearless" },
{ song: "Shake It Off", album: "1989" },
{ song: "Cardigan", album: "folklore" },
{ song: "Anti-Hero", album: "midnights" },
{ song: "Cruel Summer", album: "lover" },
{ song: "All Too Well", album: "red" },
{ song: "Enchanted", album: "speak now" },
{ song: "Tim McGraw", album: "taylor swift" },
{ song: "August", album: "folklore" },
{ song: "Karma", album: "midnights" },
{ song: "You Belong With Me", album: "fearless" },
{ song: "Blank Space", album: "1989" },
{ song: "Willow", album: "evermore" },
{ song: "Lavender Haze", album: "midnights" },
{ song: "Lover", album: "lover" }
],
trivia: [
{ question: "¿En qué año nació Taylor Swift?", answer: "1989" },
{ question: "¿Cuál fue su primer álbum de estudio?", answer: "taylor swift" },
{ question: "¿En qué ciudad nació Taylor?", answer: "reading" },
{ question: "¿Cuál es el nombre de su gato blanco?", answer: "benjamin button" },
{ question: "¿Qué número considera Taylor su favorito?", answer: "13" },
{ question: "¿En qué año lanzó '1989'?", answer: "2014" },
{ question: "¿Qué instrumento tocaba Taylor en sus inicios?", answer: "guitarra" },
{ question: "¿Cuál fue su primer sencillo número 1 en Billboard Hot 100?", answer: "shake it off" },
{ question: "¿En qué estado creció Taylor?", answer: "pennsylvania" },
{ question: "¿Cuántos álbumes ha regrabado hasta 2024?", answer: "4" }
],
unscramble: [
{ word: "FEARLESS", hint: "Álbum que incluye 'Love Story'" },
{ word: "SWIFTIE", hint: "Nombre que reciben los fans de Taylor" },
{ word: "FOLKLORE", hint: "Álbum sorpresa lanzado en 2020" },
{ word: "REPUTATION", hint: "Álbum con serpientes como símbolo" },
{ word: "ENCHANTED", hint: "Canción de Speak Now que se hizo viral en TikTok" }
],
timeline: [
{ event: "Lanzamiento de Taylor Swift", year: 2006 },
{ event: "Lanzamiento de Fearless", year: 2008 },
{ event: "Lanzamiento de Speak Now", year: 2010 },
{ event: "Lanzamiento de Red", year: 2012 },
{ event: "Lanzamiento de 1989", year: 2014 }
],
memoryPairs: [
"1989", "Red", "Fearless", "Speak Now",
"Folklore", "Evermore", "Midnights", "Lover",
"Reputation", "Taylor Swift"
]
};
// Estado del juego
let gameState = {
level: 1,
score: 0,
streak: 0,
highScore: parseInt(localStorage.getItem('taylorHighScore')) || 0,
usedQuestions: {
lyrics: [],
albums: [],
trivia: [],
unscramble: [],
timeline: []
},
memoryGame: {
flippedCards: [],
matchedPairs: 0
}
};
// Funciones auxiliares
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function createConfetti() {
for(let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.backgroundColor = ['#ff8fab', '#ffc2d1', '#ffb3c6', '#ff69b4'][Math.floor(Math.random() * 4)];
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
function updateStats() {
document.getElementById('level').textContent = gameState.level;
document.getElementById('score').textContent = gameState.score;
document.getElementById('streak').textContent = gameState.streak;
document.getElementById('highScore').textContent = gameState.highScore;
}
function createWordSearchGame() {
const words = ["SWIFT", "LOVE", "FOLKLORE", "REPUTATION"];
const wordSearchGrid = [
['S', 'W', 'I', 'F', 'T', 'E'],
['L', 'O', 'V', 'E', 'R', 'T'],
['F', 'O', 'L', 'K', 'L', 'O'],
['R', 'E', 'P', 'U', 'T', 'A']
// Expand with more rows/letters
];
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Sopa de Letras</h2>
<table class="wordsearch-table">
${wordSearchGrid.map(row => `
<tr>${row.map(letter => `<td>${letter}</td>`).join('')}</tr>
`).join('')}
</table>
<p>Encuentra las palabras: ${words.join(', ')}</p>
<div id="wordSearchResult" class="result"></div>
`;
return gameCard;
}
function createTrueFalseGame() {
const questions = [
{ question: "Taylor Swift tiene un álbum llamado 'Midnights'", correct: true },
{ question: "Taylor nació en California", correct: false }
// Add more questions
];
const question = getRandomItem(questions);
function checkTrueFalse(correct, answer) {
const result = document.getElementById('trueFalseResult');
if (correct === answer) {
const points = correctAnswer();
result.textContent = ¡Correcto! +${points} puntos 🎉;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function createTimedQuizGame() {
let timeRemaining = 30; // 30 seconds
const question = { question: "¿Cuál es el álbum más vendido de Taylor Swift?", answer: "1989" };
function correctAnswer() {
const points = 100 * gameState.level;
gameState.score += points;
gameState.streak++;
if(gameState.score > gameState.highScore) {
gameState.highScore = gameState.score;
localStorage.setItem('taylorHighScore', gameState.highScore);
}
if(gameState.streak % 3 === 0) {
gameState.level++;
createConfetti();
setTimeout(generateNewGames, 1500);
}
updateStats();
document.dispatchEvent(new Event('scoreUpdate'));
return points;
}
function wrongAnswer() {
gameState.streak = 0;
updateStats();
}
// Creación de juegos
function createLyricsGame() {
const unusedLyrics = questionBank.lyrics.filter(q => !gameState.usedQuestions.lyrics.includes(q.lyric));
if (unusedLyrics.length === 0) {
gameState.usedQuestions.lyrics = [];
}
const question = getRandomItem(unusedLyrics);
gameState.usedQuestions.lyrics.push(question.lyric);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Completa la Letra</h2>
<p>${question.lyric}</p>
<input type="text" id="lyricsInput" placeholder="Completa la letra">
<button class="btn" onclick="checkLyrics('${question.answer}')">Verificar</button>
<div id="lyricsResult" class="result"></div>
`;
return gameCard;
}
function createAlbumGame() {
const unusedAlbums = questionBank.albums.filter(q => !gameState.usedQuestions.albums.includes(q.song));
if (unusedAlbums.length === 0) {
gameState.usedQuestions.albums = [];
}
const question = getRandomItem(unusedAlbums);
gameState.usedQuestions.albums.push(question.song);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>¿De Qué Álbum Es?</h2>
<p>¿En qué álbum aparece "${question.song}"?</p>
<input type="text" id="albumInput" placeholder="Nombre del álbum">
<button class="btn" onclick="checkAlbum('${question.album}')">Verificar</button>
<div id="albumResult" class="result"></div>
`;
return gameCard;
}
function createTriviaGame() {
const unusedTrivia = questionBank.trivia.filter(q => !gameState.usedQuestions.trivia.includes(q.question));
if (unusedTrivia.length === 0) {
gameState.usedQuestions.trivia = [];
}
const question = getRandomItem(unusedTrivia);
gameState.usedQuestions.trivia.push(question.question);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Trivia Swiftie</h2>
<p>${question.question}</p>
<input type="text" id="triviaInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTrivia('${question.answer}')">Verificar</button>
<div id="triviaResult" class="result"></div>
`;
return gameCard;
}
function createMemoryGame() {
const gameCard = document.createElement('div');
gameCard.className = 'game-card memory-game';
gameCard.innerHTML = `
<h2>Memoria Taylor</h2>
<div class="memory-grid" id="memoryGrid"></div>
<div id="memoryResult" class="result"></div>
`;
return gameCard;
}
// Funciones de verificación
function checkLyrics(answer) {
const input = document.getElementById('lyricsInput').value.toLowerCase();
const result = document.getElementById('lyricsResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkAlbum(answer) {
const input = document.getElementById('albumInput').value.toLowerCase();
const result = document.getElementById('albumResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkTrivia(answer) {
const input = document.getElementById('triviaInput').value.toLowerCase();
const result = document.getElementById('triviaResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
// Juego de memoria
function startMemoryGame() {
const grid = document.getElementById('memoryGrid');
if (!grid) return;
// Crear pares de cartas
const pairs = [...questionBank.memoryPairs];
const cards = [...pairs, ...pairs];
cards.sort(() => Math.random() - 0.5);
grid.innerHTML = cards.map((card, index) => `
<div class="memory-card" data-index="${index}" data-value="${card}">
<div class="memory-card-inner">
<div class="memory-card-front">?</div>
<div class="memory-card-back">${card}</div>
</div>
</div>
`).join('');
// Agregar eventos
grid.querySelectorAll('.memory-card').forEach(card => {
card.addEventListener('click', handleMemoryCardClick);
});
}
function handleMemoryCardClick() {
const card = this;
if (
card.classList.contains('flipped') ||
gameState.memoryGame.flippedCards.length >= 2
) return;
card.classList.add('flipped');
gameState.memoryGame.flippedCards.push(card);
if (gameState.memoryGame.flippedCards.length === 2) {
setTimeout(checkMemoryMatch, 1000);
}
}
function checkMemoryMatch() {
const [card1, card2] = gameState.memoryGame.flippedCards;
const match = card1.dataset.value === card2.dataset.value;
if (match) {
gameState.memoryGame.matchedPairs++;
const points = correctAnswer();
document.getElementById('memoryResult').textContent = `¡Par encontrado! +${points} puntos 🎉`;
if (gameState.memoryGame.matchedPairs === questionBank.memoryPairs.length) {
document.getElementById('memoryResult').textContent = "¡Juego completado! 🎉";
setTimeout(generateNewGames, 1500);
}
} else {
card1.classList.remove('flipped');
card2.classList.remove('flipped');
wrongAnswer();
}
gameState.memoryGame.flippedCards = [];
}
// Sistema de guardado
function saveProgress() {
const saveData = {
gameState: gameState,
timestamp: Date.now()
};
localStorage.setItem('taylorGameState', JSON.stringify(saveData));
}
function loadProgress() {
const saved = localStorage.getItem('taylorGameState');
if (saved) {
const saveData = JSON.parse(saved);
if (Date.now() - saveData.timestamp < 24 * 60 * 60 * 1000) { // 1 day
gameState = saveData.gameState;
} else {
localStorage.removeItem('taylorGameState');
}
}
updateStats();
}
// Función mejorada para generar nuevos juegos
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame()
// Note: You must ensure that functions like createUnscrambleGame() and createTimelineGame() exist if used.
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
// Add initializations for other game types here
}
// Sistema de logros
const achievements = {
perfectStreak: { name: "Racha Perfecta", description: "Obtén una racha de 10 respuestas correctas", unlocked: false },
highScore: { name: "Alta Puntuación", description: "Alcanza 5000 puntos", unlocked: false },
masterLevel: { name: "Nivel Maestro", description: "Alcanza el nivel 5", unlocked: false }
};
function checkAchievements() {
if (gameState.streak >= 10 && !achievements.perfectStreak.unlocked) {
unlockAchievement('perfectStreak');
}
if (gameState.score >= 5000 && !achievements.highScore.unlocked) {
unlockAchievement('highScore');
}
if (gameState.level >= 5 && !achievements.masterLevel.unlocked) {
unlockAchievement('masterLevel');
}
}
function unlockAchievement(achievementId) {
achievements[achievementId].unlocked = true;
createConfetti();
alert(`¡Logro Desbloqueado! ${achievements[achievementId].name}\n${achievements[achievementId].description}`);
}
// Inicialización mejorada
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
};
</script>
por que no funcionan los nuevos juegos?
2. Verificar Errores de JavaScript
Debes verificar si hay errores en la consola del navegador. Errores como funciones no definidas o elementos no encontrados pueden ser detectados rápidamente con la consola de herramientas de desarrollo (F12 en mayoría de navegadores).
3. Inicialización de Juegos
Asegúrate de que las funciones de creación de juego están llamadas dentro de generateNewGames().
javascript
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame(),
createWordSearchGame(), // Asegúrate que está definida o elimina si no está implementada completamente
createTrueFalseGame(),
createTimedQuizGame()
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
}
Una vez verificados y ajustados estos aspectos, deberías poder ver los nuevos juegos funcionando adecuadamente en tu página. Además, revisa que cada función necesaria está correctamente implementada y esté vinculada correctamente a su interacción respectiva en HTML.
<div class="stats">
<div>Nivel: <span id="level">1</span></div>
<div>Puntos: <span id="score">0</span></div>
<div>Racha: <span id="streak">0</span></div>
<div>Mejor Puntuación: <span id="highScore">0</span></div>
</div>
<div class="games-container" id="gamesContainer"></div>
<script>
// Banco de preguntas y respuestas
const questionBank = {
lyrics: [
{ lyric: "Cause baby I'm a _________", answer: "nightmare" },
{ lyric: "Are we out of the _________?", answer: "woods" },
{ lyric: "I stay up too _________ ", answer: "late" },
{ lyric: "Nice to meet you, where you _________", answer: "been" },
{ lyric: "We are never ever ever getting back _________", answer: "together" },
{ lyric: "I knew you were _________ when you walked in", answer: "trouble" },
{ lyric: "Shake it _________, shake it off", answer: "off" },
{ lyric: "Look what you made me _________", answer: "do" },
{ lyric: "Baby just say _________", answer: "yes" },
{ lyric: "I'm feeling twenty-_________ everything", answer: "two" },
{ lyric: "All of the _________ (all of the _________)", answer: "lights" },
{ lyric: "Out of the _________, into the rain", answer: "dark" },
{ lyric: "Meet me at _________ ", answer: "midnight" },
{ lyric: "Karma is my _________ star", answer: "lucky" },
{ lyric: "It's me, hi, I'm the _________", answer: "problem" },
{ lyric: "Draw the _________ wide", answer: "curtains" },
{ lyric: "Paint the town _________ ", answer: "red" },
{ lyric: "Dancing with our hands _________", answer: "tied" },
{ lyric: "I had a marvelous _________", answer: "time" },
{ lyric: "Welcome to New _________ ", answer: "york" }
],
albums: [
{ song: "Love Story", album: "fearless" },
{ song: "Shake It Off", album: "1989" },
{ song: "Cardigan", album: "folklore" },
{ song: "Anti-Hero", album: "midnights" },
{ song: "Cruel Summer", album: "lover" },
{ song: "All Too Well", album: "red" },
{ song: "Enchanted", album: "speak now" },
{ song: "Tim McGraw", album: "taylor swift" },
{ song: "August", album: "folklore" },
{ song: "Karma", album: "midnights" },
{ song: "You Belong With Me", album: "fearless" },
{ song: "Blank Space", album: "1989" },
{ song: "Willow", album: "evermore" },
{ song: "Lavender Haze", album: "midnights" },
{ song: "Lover", album: "lover" }
],
trivia: [
{ question: "¿En qué año nació Taylor Swift?", answer: "1989" },
{ question: "¿Cuál fue su primer álbum de estudio?", answer: "taylor swift" },
{ question: "¿En qué ciudad nació Taylor?", answer: "reading" },
{ question: "¿Cuál es el nombre de su gato blanco?", answer: "benjamin button" },
{ question: "¿Qué número considera Taylor su favorito?", answer: "13" },
{ question: "¿En qué año lanzó '1989'?", answer: "2014" },
{ question: "¿Qué instrumento tocaba Taylor en sus inicios?", answer: "guitarra" },
{ question: "¿Cuál fue su primer sencillo número 1 en Billboard Hot 100?", answer: "shake it off" },
{ question: "¿En qué estado creció Taylor?", answer: "pennsylvania" },
{ question: "¿Cuántos álbumes ha regrabado hasta 2024?", answer: "4" }
],
unscramble: [
{ word: "FEARLESS", hint: "Álbum que incluye 'Love Story'" },
{ word: "SWIFTIE", hint: "Nombre que reciben los fans de Taylor" },
{ word: "FOLKLORE", hint: "Álbum sorpresa lanzado en 2020" },
{ word: "REPUTATION", hint: "Álbum con serpientes como símbolo" },
{ word: "ENCHANTED", hint: "Canción de Speak Now que se hizo viral en TikTok" }
],
timeline: [
{ event: "Lanzamiento de Taylor Swift", year: 2006 },
{ event: "Lanzamiento de Fearless", year: 2008 },
{ event: "Lanzamiento de Speak Now", year: 2010 },
{ event: "Lanzamiento de Red", year: 2012 },
{ event: "Lanzamiento de 1989", year: 2014 }
],
memoryPairs: [
"1989", "Red", "Fearless", "Speak Now",
"Folklore", "Evermore", "Midnights", "Lover",
"Reputation", "Taylor Swift"
]
};
// Estado del juego
let gameState = {
level: 1,
score: 0,
streak: 0,
highScore: parseInt(localStorage.getItem('taylorHighScore')) || 0,
usedQuestions: {
lyrics: [],
albums: [],
trivia: [],
unscramble: [],
timeline: []
},
memoryGame: {
flippedCards: [],
matchedPairs: 0
}
};
// Funciones auxiliares
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function createConfetti() {
for(let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.backgroundColor = ['#ff8fab', '#ffc2d1', '#ffb3c6', '#ff69b4'][Math.floor(Math.random() * 4)];
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
function updateStats() {
document.getElementById('level').textContent = gameState.level;
document.getElementById('score').textContent = gameState.score;
document.getElementById('streak').textContent = gameState.streak;
document.getElementById('highScore').textContent = gameState.highScore;
}
function createWordSearchGame() {
const words = ["SWIFT", "LOVE", "FOLKLORE", "REPUTATION"];
const wordSearchGrid = [
['S', 'W', 'I', 'F', 'T', 'E'],
['L', 'O', 'V', 'E', 'R', 'T'],
['F', 'O', 'L', 'K', 'L', 'O'],
['R', 'E', 'P', 'U', 'T', 'A']
// Expand with more rows/letters
];
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Sopa de Letras</h2>
<table class="wordsearch-table">
${wordSearchGrid.map(row => `
<tr>${row.map(letter => `<td>${letter}</td>`).join('')}</tr>
`).join('')}
</table>
<p>Encuentra las palabras: ${words.join(', ')}</p>
<div id="wordSearchResult" class="result"></div>
`;
return gameCard;
}
function createTrueFalseGame() {
const questions = [
{ question: "Taylor Swift tiene un álbum llamado 'Midnights'", correct: true },
{ question: "Taylor nació en California", correct: false }
// Add more questions
];
const question = getRandomItem(questions);
function checkTrueFalse(correct, answer) {
const result = document.getElementById('trueFalseResult');
if (correct === answer) {
const points = correctAnswer();
result.textContent = ¡Correcto! +${points} puntos 🎉;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function createTimedQuizGame() {
let timeRemaining = 30; // 30 seconds
const question = { question: "¿Cuál es el álbum más vendido de Taylor Swift?", answer: "1989" };
function correctAnswer() {
const points = 100 * gameState.level;
gameState.score += points;
gameState.streak++;
if(gameState.score > gameState.highScore) {
gameState.highScore = gameState.score;
localStorage.setItem('taylorHighScore', gameState.highScore);
}
if(gameState.streak % 3 === 0) {
gameState.level++;
createConfetti();
setTimeout(generateNewGames, 1500);
}
updateStats();
document.dispatchEvent(new Event('scoreUpdate'));
return points;
}
function wrongAnswer() {
gameState.streak = 0;
updateStats();
}
// Creación de juegos
function createLyricsGame() {
const unusedLyrics = questionBank.lyrics.filter(q => !gameState.usedQuestions.lyrics.includes(q.lyric));
if (unusedLyrics.length === 0) {
gameState.usedQuestions.lyrics = [];
}
const question = getRandomItem(unusedLyrics);
gameState.usedQuestions.lyrics.push(question.lyric);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Completa la Letra</h2>
<p>${question.lyric}</p>
<input type="text" id="lyricsInput" placeholder="Completa la letra">
<button class="btn" onclick="checkLyrics('${question.answer}')">Verificar</button>
<div id="lyricsResult" class="result"></div>
`;
return gameCard;
}
function createAlbumGame() {
const unusedAlbums = questionBank.albums.filter(q => !gameState.usedQuestions.albums.includes(q.song));
if (unusedAlbums.length === 0) {
gameState.usedQuestions.albums = [];
}
const question = getRandomItem(unusedAlbums);
gameState.usedQuestions.albums.push(question.song);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>¿De Qué Álbum Es?</h2>
<p>¿En qué álbum aparece "${question.song}"?</p>
<input type="text" id="albumInput" placeholder="Nombre del álbum">
<button class="btn" onclick="checkAlbum('${question.album}')">Verificar</button>
<div id="albumResult" class="result"></div>
`;
return gameCard;
}
function createTriviaGame() {
const unusedTrivia = questionBank.trivia.filter(q => !gameState.usedQuestions.trivia.includes(q.question));
if (unusedTrivia.length === 0) {
gameState.usedQuestions.trivia = [];
}
const question = getRandomItem(unusedTrivia);
gameState.usedQuestions.trivia.push(question.question);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Trivia Swiftie</h2>
<p>${question.question}</p>
<input type="text" id="triviaInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTrivia('${question.answer}')">Verificar</button>
<div id="triviaResult" class="result"></div>
`;
return gameCard;
}
function createMemoryGame() {
const gameCard = document.createElement('div');
gameCard.className = 'game-card memory-game';
gameCard.innerHTML = `
<h2>Memoria Taylor</h2>
<div class="memory-grid" id="memoryGrid"></div>
<div id="memoryResult" class="result"></div>
`;
return gameCard;
}
// Funciones de verificación
function checkLyrics(answer) {
const input = document.getElementById('lyricsInput').value.toLowerCase();
const result = document.getElementById('lyricsResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkAlbum(answer) {
const input = document.getElementById('albumInput').value.toLowerCase();
const result = document.getElementById('albumResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkTrivia(answer) {
const input = document.getElementById('triviaInput').value.toLowerCase();
const result = document.getElementById('triviaResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
// Juego de memoria
function startMemoryGame() {
const grid = document.getElementById('memoryGrid');
if (!grid) return;
// Crear pares de cartas
const pairs = [...questionBank.memoryPairs];
const cards = [...pairs, ...pairs];
cards.sort(() => Math.random() - 0.5);
grid.innerHTML = cards.map((card, index) => `
<div class="memory-card" data-index="${index}" data-value="${card}">
<div class="memory-card-inner">
<div class="memory-card-front">?</div>
<div class="memory-card-back">${card}</div>
</div>
</div>
`).join('');
// Agregar eventos
grid.querySelectorAll('.memory-card').forEach(card => {
card.addEventListener('click', handleMemoryCardClick);
});
}
function handleMemoryCardClick() {
const card = this;
if (
card.classList.contains('flipped') ||
gameState.memoryGame.flippedCards.length >= 2
) return;
card.classList.add('flipped');
gameState.memoryGame.flippedCards.push(card);
if (gameState.memoryGame.flippedCards.length === 2) {
setTimeout(checkMemoryMatch, 1000);
}
}
function checkMemoryMatch() {
const [card1, card2] = gameState.memoryGame.flippedCards;
const match = card1.dataset.value === card2.dataset.value;
if (match) {
gameState.memoryGame.matchedPairs++;
const points = correctAnswer();
document.getElementById('memoryResult').textContent = `¡Par encontrado! +${points} puntos 🎉`;
if (gameState.memoryGame.matchedPairs === questionBank.memoryPairs.length) {
document.getElementById('memoryResult').textContent = "¡Juego completado! 🎉";
setTimeout(generateNewGames, 1500);
}
} else {
card1.classList.remove('flipped');
card2.classList.remove('flipped');
wrongAnswer();
}
gameState.memoryGame.flippedCards = [];
}
// Sistema de guardado
function saveProgress() {
const saveData = {
gameState: gameState,
timestamp: Date.now()
};
localStorage.setItem('taylorGameState', JSON.stringify(saveData));
}
function loadProgress() {
const saved = localStorage.getItem('taylorGameState');
if (saved) {
const saveData = JSON.parse(saved);
if (Date.now() - saveData.timestamp < 24 * 60 * 60 * 1000) { // 1 day
gameState = saveData.gameState;
} else {
localStorage.removeItem('taylorGameState');
}
}
updateStats();
}
// Función mejorada para generar nuevos juegos
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame()
// Note: You must ensure that functions like createUnscrambleGame() and createTimelineGame() exist if used.
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
// Add initializations for other game types here
}
// Sistema de logros
const achievements = {
perfectStreak: { name: "Racha Perfecta", description: "Obtén una racha de 10 respuestas correctas", unlocked: false },
highScore: { name: "Alta Puntuación", description: "Alcanza 5000 puntos", unlocked: false },
masterLevel: { name: "Nivel Maestro", description: "Alcanza el nivel 5", unlocked: false }
};
function checkAchievements() {
if (gameState.streak >= 10 && !achievements.perfectStreak.unlocked) {
unlockAchievement('perfectStreak');
}
if (gameState.score >= 5000 && !achievements.highScore.unlocked) {
unlockAchievement('highScore');
}
if (gameState.level >= 5 && !achievements.masterLevel.unlocked) {
unlockAchievement('masterLevel');
}
}
function unlockAchievement(achievementId) {
achievements[achievementId].unlocked = true;
createConfetti();
alert(`¡Logro Desbloqueado! ${achievements[achievementId].name}\n${achievements[achievementId].description}`);
}
// Inicialización mejorada
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
};
</script>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Juegos de Taylor Swift - Edición Deluxe Plus</title>
<style>
:root {
--primary: #ff8fab;
--secondary: #ffc2d1;
--background: #ffe1e8;
--text: #2d3436;
}
body {
font-family: 'Arial', sans-serif;
background-color: var(--background);
margin: 0;
padding: 20px;
color: var(--text);
}
.header {
text-align: center;
background: linear-gradient(135deg, var(--primary), var(--secondary));
padding: 20px;
border-radius: 15px;
margin-bottom: 20px;
color: white;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.stats {
display: flex;
justify-content: space-around;
max-width: 600px;
margin: 0 auto 20px;
background: white;
padding: 10px;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.games-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
max-width: 1200px;
margin: 0 auto;
}
.game-card {
background: white;
padding: 20px;
border-radius: 15px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.game-card:hover {
transform: translateY(-5px);
}
.btn {
background: var(--primary);
border: none;
padding: 10px 20px;
border-radius: 5px;
color: white;
cursor: pointer;
transition: all 0.3s ease;
margin: 5px;
}
.btn:hover {
background: #ff6b8b;
transform: scale(1.05);
}
.result {
margin-top: 10px;
font-weight: bold;
padding: 5px;
border-radius: 5px;
text-align: center;
}
input[type="text"],
input[type="number"],
select {
padding: 8px;
margin: 5px;
border: 1px solid var(--secondary);
border-radius: 5px;
width: calc(100% - 20px);
}
.memory-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
margin-top: 10px;
}
.memory-card {
aspect-ratio: 1;
background: var(--primary);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 0;
transition: all 0.3s ease;
border-radius: 5px;
}
.memory-card.flipped {
background: white;
font-size: 14px;
border: 2px solid var(--primary);
}
.progress-bar {
width: 100%;
height: 20px;
background: #eee;
border-radius: 10px;
margin: 10px 0;
overflow: hidden;
}
.progress {
height: 100%;
background: var(--primary);
transition: width 0.3s ease;
}
.confetti {
position: fixed;
width: 10px;
height: 10px;
background: var(--primary);
animation: confetti 3s ease-in-out infinite;
pointer-events: none;
}
.unscramble-container {
display: flex;
flex-wrap: wrap;
gap: 5px;
margin: 10px 0;
}
.letter-tile {
padding: 10px;
background: var(--secondary);
border-radius: 5px;
cursor: pointer;
user-select: none;
}
.timeline-container {
display: flex;
flex-direction: column;
gap: 10px;
margin: 10px 0;
}
.timeline-item {
padding: 10px;
background: var(--secondary);
border-radius: 5px;
cursor: move;
}
@keyframes confetti {
0% { transform: translateY(0) rotate(0deg); }
100% { transform: translateY(100vh) rotate(720deg); }
}
</style>
</head>
<body>
<div class="header">
<h1>🎵 Juegos de Taylor Swift - Edición Deluxe Plus 🎵</h1>
<p>¡Demuestra cuánto sabes sobre Taylor!</p>
</div>
<div class="stats">
<div>Nivel: <span id="level">1</span></div>
<div>Puntos: <span id="score">0</span></div>
<div>Racha: <span id="streak">0</span></div>
<div>Mejor Puntuación: <span id="highScore">0</span></div>
</div>
<div class="games-container" id="gamesContainer"></div>
<script>
// Banco de preguntas y respuestas
const questionBank = {
lyrics: [
{ lyric: "Cause baby I'm a _________", answer: "nightmare" },
{ lyric: "Are we out of the _________?", answer: "woods" },
{ lyric: "I stay up too _________ ", answer: "late" },
{ lyric: "Nice to meet you, where you _________", answer: "been" },
{ lyric: "We are never ever ever getting back _________", answer: "together" },
{ lyric: "I knew you were _________ when you walked in", answer: "trouble" },
{ lyric: "Shake it _________, shake it off", answer: "off" },
{ lyric: "Look what you made me _________", answer: "do" },
{ lyric: "Baby just say _________", answer: "yes" },
{ lyric: "I'm feeling twenty-_________ everything", answer: "two" },
{ lyric: "All of the _________ (all of the _________)", answer: "lights" },
{ lyric: "Out of the _________, into the rain", answer: "dark" },
{ lyric: "Meet me at _________ ", answer: "midnight" },
{ lyric: "Karma is my _________ star", answer: "lucky" },
{ lyric: "It's me, hi, I'm the _________", answer: "problem" },
{ lyric: "Draw the _________ wide", answer: "curtains" },
{ lyric: "Paint the town _________ ", answer: "red" },
{ lyric: "Dancing with our hands _________", answer: "tied" },
{ lyric: "I had a marvelous _________", answer: "time" },
{ lyric: "Welcome to New _________ ", answer: "york" }
],
albums: [
{ song: "Love Story", album: "fearless" },
{ song: "Shake It Off", album: "1989" },
{ song: "Cardigan", album: "folklore" },
{ song: "Anti-Hero", album: "midnights" },
{ song: "Cruel Summer", album: "lover" },
{ song: "All Too Well", album: "red" },
{ song: "Enchanted", album: "speak now" },
{ song: "Tim McGraw", album: "taylor swift" },
{ song: "August", album: "folklore" },
{ song: "Karma", album: "midnights" },
{ song: "You Belong With Me", album: "fearless" },
{ song: "Blank Space", album: "1989" },
{ song: "Willow", album: "evermore" },
{ song: "Lavender Haze", album: "midnights" },
{ song: "Lover", album: "lover" }
],
trivia: [
{ question: "¿En qué año nació Taylor Swift?", answer: "1989" },
{ question: "¿Cuál fue su primer álbum de estudio?", answer: "taylor swift" },
{ question: "¿En qué ciudad nació Taylor?", answer: "reading" },
{ question: "¿Cuál es el nombre de su gato blanco?", answer: "benjamin button" },
{ question: "¿Qué número considera Taylor su favorito?", answer: "13" },
{ question: "¿En qué año lanzó '1989'?", answer: "2014" },
{ question: "¿Qué instrumento tocaba Taylor en sus inicios?", answer: "guitarra" },
{ question: "¿Cuál fue su primer sencillo número 1 en Billboard Hot 100?", answer: "shake it off" },
{ question: "¿En qué estado creció Taylor?", answer: "pennsylvania" },
{ question: "¿Cuántos álbumes ha regrabado hasta 2024?", answer: "4" }
],
unscramble: [
{ word: "FEARLESS", hint: "Álbum que incluye 'Love Story'" },
{ word: "SWIFTIE", hint: "Nombre que reciben los fans de Taylor" },
{ word: "FOLKLORE", hint: "Álbum sorpresa lanzado en 2020" },
{ word: "REPUTATION", hint: "Álbum con serpientes como símbolo" },
{ word: "ENCHANTED", hint: "Canción de Speak Now que se hizo viral en TikTok" }
],
timeline: [
{ event: "Lanzamiento de Taylor Swift", year: 2006 },
{ event: "Lanzamiento de Fearless", year: 2008 },
{ event: "Lanzamiento de Speak Now", year: 2010 },
{ event: "Lanzamiento de Red", year: 2012 },
{ event: "Lanzamiento de 1989", year: 2014 }
],
memoryPairs: [
"1989", "Red", "Fearless", "Speak Now",
"Folklore", "Evermore", "Midnights", "Lover",
"Reputation", "Taylor Swift"
]
};
// Estado del juego
let gameState = {
level: 1,
score: 0,
streak: 0,
highScore: parseInt(localStorage.getItem('taylorHighScore')) || 0,
usedQuestions: {
lyrics: [],
albums: [],
trivia: [],
unscramble: [],
timeline: []
},
memoryGame: {
flippedCards: [],
matchedPairs: 0
}
};
// Funciones auxiliares
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function createConfetti() {
for(let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.backgroundColor = ['#ff8fab', '#ffc2d1', '#ffb3c6', '#ff69b4'][Math.floor(Math.random() * 4)];
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
function updateStats() {
document.getElementById('level').textContent = gameState.level;
document.getElementById('score').textContent = gameState.score;
document.getElementById('streak').textContent = gameState.streak;
document.getElementById('highScore').textContent = gameState.highScore;
}
let timerInterval; // Declare timerInterval in a broader scope
function createWordSearchGame() {
const words = ["SWIFT", "LOVE", "FOLKLORE", "REPUTATION"];
const wordSearchGrid = [
['S', 'W', 'I', 'F', 'T', 'E'],
['L', 'O', 'V', 'E', 'R', 'T'],
['F', 'O', 'L', 'K', 'L', 'O'],
['R', 'E', 'P', 'U', 'T', 'A']
// Expand with more rows/letters
];
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Sopa de Letras</h2>
<table class="wordsearch-table">
${wordSearchGrid.map(row => `
<tr>${row.map(letter => `<td>${letter}</td>`).join('')}</tr>
`).join('')}
</table>
<p>Encuentra las palabras: ${words.join(', ')}</p>
<div id="wordSearchResult" class="result"></div>
`;
return gameCard;
}
function createTrueFalseGame() {
const questions = [
{ question: "Taylor Swift tiene un álbum llamado 'Midnights'", correct: true },
{ question: "Taylor nació en California", correct: false }
// Add more questions
];
const question = getRandomItem(questions);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Verdadero o Falso</h2>
<p>${question.question}</p>
<button class="btn" onclick="checkTrueFalse(${question.correct}, true)">Verdadero</button>
<button class="btn" onclick="checkTrueFalse(${question.correct}, false)">Falso</button>
<div class="result" data-id="trueFalseResult"></div>
`;
return gameCard;
}
function checkTrueFalse(correct, answer) {
const result = document.querySelector('[data-id="trueFalseResult"]');
if (correct === answer) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function createTimedQuizGame() {
let timeRemaining = 30; // 30 seconds
const question = { question: "¿Cuál es el álbum más vendido de Taylor Swift?", answer: "1989" };
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Quiz de Tiempo</h2>
<p>${question.question}</p>
<input type="text" id="timedQuizInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTimedQuiz('${question.answer}')">Verificar</button>
<div id="timedQuizResult" class="result"></div>
<div id="timerDisplay">Tiempo: ${timeRemaining} segundos</div>
`;
timerInterval = setInterval(() => {
if (timeRemaining > 0) {
timeRemaining--;
document.getElementById('timerDisplay').textContent = `Tiempo: ${timeRemaining} segundos`;
} else {
clearInterval(timerInterval);
document.getElementById('timedQuizResult').textContent = "¡Tiempo agotado! 😊";
}
}, 1000);
return gameCard;
}
function checkTimedQuiz(answer) {
const input = document.getElementById('timedQuizInput').value.toLowerCase();
const result = document.getElementById('timedQuizResult');
clearInterval(timerInterval); // Stop the timer when checking answer
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function correctAnswer() {
const points = 100 * gameState.level;
gameState.score += points;
gameState.streak++;
if(gameState.score > gameState.highScore) {
gameState.highScore = gameState.score;
localStorage.setItem('taylorHighScore', gameState.highScore);
}
if(gameState.streak % 3 === 0) {
gameState.level++;
createConfetti();
setTimeout(generateNewGames, 1500);
}
updateStats();
document.dispatchEvent(new Event('scoreUpdate'));
return points;
}
function wrongAnswer() {
gameState.streak = 0;
updateStats();
}
// Creación de juegos
function createLyricsGame() {
const unusedLyrics = questionBank.lyrics.filter(q => !gameState.usedQuestions.lyrics.includes(q.lyric));
if (unusedLyrics.length === 0) {
gameState.usedQuestions.lyrics = [];
}
const question = getRandomItem(unusedLyrics);
gameState.usedQuestions.lyrics.push(question.lyric);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Completa la Letra</h2>
<p>${question.lyric}</p>
<input type="text" id="lyricsInput" placeholder="Completa la letra">
<button class="btn" onclick="checkLyrics('${question.answer}')">Verificar</button>
<div id="lyricsResult" class="result"></div>
`;
return gameCard;
}
function createAlbumGame() {
const unusedAlbums = questionBank.albums.filter(q => !gameState.usedQuestions.albums.includes(q.song));
if (unusedAlbums.length === 0) {
gameState.usedQuestions.albums = [];
}
const question = getRandomItem(unusedAlbums);
gameState.usedQuestions.albums.push(question.song);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>¿De Qué Álbum Es?</h2>
<p>¿En qué álbum aparece "${question.song}"?</p>
<input type="text" id="albumInput" placeholder="Nombre del álbum">
<button class="btn" onclick="checkAlbum('${question.album}')">Verificar</button>
<div id="albumResult" class="result"></div>
`;
return gameCard;
}
function createTriviaGame() {
const unusedTrivia = questionBank.trivia.filter(q => !gameState.usedQuestions.trivia.includes(q.question));
if (unusedTrivia.length === 0) {
gameState.usedQuestions.trivia = [];
}
const question = getRandomItem(unusedTrivia);
gameState.usedQuestions.trivia.push(question.question);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Trivia Swiftie</h2>
<p>${question.question}</p>
<input type="text" id="triviaInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTrivia('${question.answer}')">Verificar</button>
<div id="triviaResult" class="result"></div>
`;
return gameCard;
}
function createMemoryGame() {
const gameCard = document.createElement('div');
gameCard.className = 'game-card memory-game';
gameCard.innerHTML = `
<h2>Memoria Taylor</h2>
<div class="memory-grid" id="memoryGrid"></div>
<div id="memoryResult" class="result"></div>
`;
return gameCard;
}
// Funciones de verificación
function checkLyrics(answer) {
const input = document.getElementById('lyricsInput').value.toLowerCase();
const result = document.getElementById('lyricsResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkAlbum(answer) {
const input = document.getElementById('albumInput').value.toLowerCase();
const result = document.getElementById('albumResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkTrivia(answer) {
const input = document.getElementById('triviaInput').value.toLowerCase();
const result = document.getElementById('triviaResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
// Juego de memoria
function startMemoryGame() {
const grid = document.getElementById('memoryGrid');
if (!grid) return;
// Crear pares de cartas
const pairs = [...questionBank.memoryPairs];
const cards = [...pairs, ...pairs];
cards.sort(() => Math.random() - 0.5);
grid.innerHTML = cards.map((card, index) => `
<div class="memory-card" data-index="${index}" data-value="${card}">
<div class="memory-card-inner">
<div class="memory-card-front">?</div>
<div class="memory-card-back">${card}</div>
</div>
</div>
`).join('');
// Agregar eventos
grid.querySelectorAll('.memory-card').forEach(card => {
card.addEventListener('click', handleMemoryCardClick);
});
}
function handleMemoryCardClick() {
const card = this;
if (
card.classList.contains('flipped') ||
gameState.memoryGame.flippedCards.length >= 2
) return;
card.classList.add('flipped');
gameState.memoryGame.flippedCards.push(card);
if (gameState.memoryGame.flippedCards.length === 2) {
setTimeout(checkMemoryMatch, 1000);
}
}
function checkMemoryMatch() {
const [card1, card2] = gameState.memoryGame.flippedCards;
const match = card1.dataset.value === card2.dataset.value;
if (match) {
gameState.memoryGame.matchedPairs++;
const points = correctAnswer();
document.getElementById('memoryResult').textContent = `¡Par encontrado! +${points} puntos 🎉`;
if (gameState.memoryGame.matchedPairs === questionBank.memoryPairs.length) {
document.getElementById('memoryResult').textContent = "¡Juego completado! 🎉";
setTimeout(generateNewGames, 1500);
}
} else {
card1.classList.remove('flipped');
card2.classList.remove('flipped');
wrongAnswer();
}
gameState.memoryGame.flippedCards = [];
}
// Sistema de guardado
function saveProgress() {
const saveData = {
gameState: gameState,
timestamp: Date.now()
};
localStorage.setItem('taylorGameState', JSON.stringify(saveData));
}
function loadProgress() {
const saved = localStorage.getItem('taylorGameState');
if (saved) {
const saveData = JSON.parse(saved);
if (Date.now() - saveData.timestamp < 24 * 60 * 60 * 1000) { // 1 day
gameState = saveData.gameState;
} else {
localStorage.removeItem('taylorGameState');
}
}
updateStats();
}
// Función mejorada para generar nuevos juegos
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame(),
createWordSearchGame(),
createTrueFalseGame(),
createTimedQuizGame()
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
// Add initializations for other game types here
}
// Sistema de logros
const achievements = {
perfectStreak: { name: "Racha Perfecta", description: "Obtén una racha de 10 respuestas correctas", unlocked: false },
highScore: { name: "Alta Puntuación", description: "Alcanza 5000 puntos", unlocked: false },
masterLevel: { name: "Nivel Maestro", description: "Alcanza el nivel 5", unlocked: false }
};
function checkAchievements() {
if (gameState.streak >= 10 && !achievements.perfectStreak.unlocked) {
unlockAchievement('perfectStreak');
}
if (gameState.score >= 5000 && !achievements.highScore.unlocked) {
unlockAchievement('highScore');
}
if (gameState.level >= 5 && !achievements.masterLevel.unlocked) {
unlockAchievement('masterLevel');
}
}
function unlockAchievement(achievementId) {
achievements[achievementId].unlocked = true;
createConfetti();
alert(`¡Logro Desbloqueado! ${achievements[achievementId].name}\n${achievements[achievementId].description}`);
}
// Inicialización mejorada
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
};
</script>
</body>
</html>
Cambios Realizados:
Ámbito del Temporizador: Declaré timerInterval a un nivel más amplio para controlarlo correctamente dentro y fuera de la función de temporización del quiz.
Uso de Data-ID: Para los juegos que tienen múltiples instancias en el DOM, utilicé data-id en lugar de id para los elementos dinámicos como trueFalseResult, asegurando que cada instancia tenga un resultado específico único que no entre en conflicto.
Detención del Temporizador: Asegurarse de que timerInterval se detenga correctamente al verificar una respuesta.
Inicialización de Juegos: Asegúrate de llamar a todas las funciones de creación de juegos dentro de generateNewGames().
Estos ajustes deberían ayudar a que cada tipo de juego funcione correctamente después de corregir la lógica de uso de elementos y valores en el DOM. Además, asegúrate de que no haya errores en la consola del navegador, ya que estos pueden ayudar a depurar cualquier problema que persista.
<div class="stats">
<div>Nivel: <span id="level">1</span></div>
<div>Puntos: <span id="score">0</span></div>
<div>Racha: <span id="streak">0</span></div>
<div>Mejor Puntuación: <span id="highScore">0</span></div>
</div>
<div class="games-container" id="gamesContainer"></div>
<script>
// Banco de preguntas y respuestas
const questionBank = {
lyrics: [
{ lyric: "Cause baby I'm a _________", answer: "nightmare" },
{ lyric: "Are we out of the _________?", answer: "woods" },
{ lyric: "I stay up too _________ ", answer: "late" },
{ lyric: "Nice to meet you, where you _________", answer: "been" },
{ lyric: "We are never ever ever getting back _________", answer: "together" },
{ lyric: "I knew you were _________ when you walked in", answer: "trouble" },
{ lyric: "Shake it _________, shake it off", answer: "off" },
{ lyric: "Look what you made me _________", answer: "do" },
{ lyric: "Baby just say _________", answer: "yes" },
{ lyric: "I'm feeling twenty-_________ everything", answer: "two" },
{ lyric: "All of the _________ (all of the _________)", answer: "lights" },
{ lyric: "Out of the _________, into the rain", answer: "dark" },
{ lyric: "Meet me at _________ ", answer: "midnight" },
{ lyric: "Karma is my _________ star", answer: "lucky" },
{ lyric: "It's me, hi, I'm the _________", answer: "problem" },
{ lyric: "Draw the _________ wide", answer: "curtains" },
{ lyric: "Paint the town _________ ", answer: "red" },
{ lyric: "Dancing with our hands _________", answer: "tied" },
{ lyric: "I had a marvelous _________", answer: "time" },
{ lyric: "Welcome to New _________ ", answer: "york" }
],
albums: [
{ song: "Love Story", album: "fearless" },
{ song: "Shake It Off", album: "1989" },
{ song: "Cardigan", album: "folklore" },
{ song: "Anti-Hero", album: "midnights" },
{ song: "Cruel Summer", album: "lover" },
{ song: "All Too Well", album: "red" },
{ song: "Enchanted", album: "speak now" },
{ song: "Tim McGraw", album: "taylor swift" },
{ song: "August", album: "folklore" },
{ song: "Karma", album: "midnights" },
{ song: "You Belong With Me", album: "fearless" },
{ song: "Blank Space", album: "1989" },
{ song: "Willow", album: "evermore" },
{ song: "Lavender Haze", album: "midnights" },
{ song: "Lover", album: "lover" }
],
trivia: [
{ question: "¿En qué año nació Taylor Swift?", answer: "1989" },
{ question: "¿Cuál fue su primer álbum de estudio?", answer: "taylor swift" },
{ question: "¿En qué ciudad nació Taylor?", answer: "reading" },
{ question: "¿Cuál es el nombre de su gato blanco?", answer: "benjamin button" },
{ question: "¿Qué número considera Taylor su favorito?", answer: "13" },
{ question: "¿En qué año lanzó '1989'?", answer: "2014" },
{ question: "¿Qué instrumento tocaba Taylor en sus inicios?", answer: "guitarra" },
{ question: "¿Cuál fue su primer sencillo número 1 en Billboard Hot 100?", answer: "shake it off" },
{ question: "¿En qué estado creció Taylor?", answer: "pennsylvania" },
{ question: "¿Cuántos álbumes ha regrabado hasta 2024?", answer: "4" }
],
unscramble: [
{ word: "FEARLESS", hint: "Álbum que incluye 'Love Story'" },
{ word: "SWIFTIE", hint: "Nombre que reciben los fans de Taylor" },
{ word: "FOLKLORE", hint: "Álbum sorpresa lanzado en 2020" },
{ word: "REPUTATION", hint: "Álbum con serpientes como símbolo" },
{ word: "ENCHANTED", hint: "Canción de Speak Now que se hizo viral en TikTok" }
],
timeline: [
{ event: "Lanzamiento de Taylor Swift", year: 2006 },
{ event: "Lanzamiento de Fearless", year: 2008 },
{ event: "Lanzamiento de Speak Now", year: 2010 },
{ event: "Lanzamiento de Red", year: 2012 },
{ event: "Lanzamiento de 1989", year: 2014 }
],
memoryPairs: [
"1989", "Red", "Fearless", "Speak Now",
"Folklore", "Evermore", "Midnights", "Lover",
"Reputation", "Taylor Swift"
]
};
// Estado del juego
let gameState = {
level: 1,
score: 0,
streak: 0,
highScore: parseInt(localStorage.getItem('taylorHighScore')) || 0,
usedQuestions: {
lyrics: [],
albums: [],
trivia: [],
unscramble: [],
timeline: []
},
memoryGame: {
flippedCards: [],
matchedPairs: 0
}
};
// Funciones auxiliares
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function createConfetti() {
for(let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.backgroundColor = ['#ff8fab', '#ffc2d1', '#ffb3c6', '#ff69b4'][Math.floor(Math.random() * 4)];
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
function updateStats() {
document.getElementById('level').textContent = gameState.level;
document.getElementById('score').textContent = gameState.score;
document.getElementById('streak').textContent = gameState.streak;
document.getElementById('highScore').textContent = gameState.highScore;
}
let timerInterval; // Declare timerInterval in a broader scope
function createWordSearchGame() {
const words = ["SWIFT", "LOVE", "FOLKLORE", "REPUTATION"];
const wordSearchGrid = [
['S', 'W', 'I', 'F', 'T', 'E'],
['L', 'O', 'V', 'E', 'R', 'T'],
['F', 'O', 'L', 'K', 'L', 'O'],
['R', 'E', 'P', 'U', 'T', 'A']
// Expand with more rows/letters
];
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Sopa de Letras</h2>
<table class="wordsearch-table">
${wordSearchGrid.map(row => `
<tr>${row.map(letter => `<td>${letter}</td>`).join('')}</tr>
`).join('')}
</table>
<p>Encuentra las palabras: ${words.join(', ')}</p>
<div id="wordSearchResult" class="result"></div>
`;
return gameCard;
}
function createTrueFalseGame() {
const questions = [
{ question: "Taylor Swift tiene un álbum llamado 'Midnights'", correct: true },
{ question: "Taylor nació en California", correct: false }
// Add more questions
];
const question = getRandomItem(questions);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Verdadero o Falso</h2>
<p>${question.question}</p>
<button class="btn" onclick="checkTrueFalse(${question.correct}, true)">Verdadero</button>
<button class="btn" onclick="checkTrueFalse(${question.correct}, false)">Falso</button>
<div class="result" data-id="trueFalseResult"></div>
`;
return gameCard;
}
function checkTrueFalse(correct, answer) {
const result = document.querySelector('[data-id="trueFalseResult"]');
if (correct === answer) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function createTimedQuizGame() {
let timeRemaining = 30; // 30 seconds
const question = { question: "¿Cuál es el álbum más vendido de Taylor Swift?", answer: "1989" };
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Quiz de Tiempo</h2>
<p>${question.question}</p>
<input type="text" id="timedQuizInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTimedQuiz('${question.answer}')">Verificar</button>
<div id="timedQuizResult" class="result"></div>
<div id="timerDisplay">Tiempo: ${timeRemaining} segundos</div>
`;
timerInterval = setInterval(() => {
if (timeRemaining > 0) {
timeRemaining--;
document.getElementById('timerDisplay').textContent = `Tiempo: ${timeRemaining} segundos`;
} else {
clearInterval(timerInterval);
document.getElementById('timedQuizResult').textContent = "¡Tiempo agotado! 😊";
}
}, 1000);
return gameCard;
}
function checkTimedQuiz(answer) {
const input = document.getElementById('timedQuizInput').value.toLowerCase();
const result = document.getElementById('timedQuizResult');
clearInterval(timerInterval); // Stop the timer when checking answer
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function correctAnswer() {
const points = 100 * gameState.level;
gameState.score += points;
gameState.streak++;
if(gameState.score > gameState.highScore) {
gameState.highScore = gameState.score;
localStorage.setItem('taylorHighScore', gameState.highScore);
}
if(gameState.streak % 3 === 0) {
gameState.level++;
createConfetti();
setTimeout(generateNewGames, 1500);
}
updateStats();
document.dispatchEvent(new Event('scoreUpdate'));
return points;
}
function wrongAnswer() {
gameState.streak = 0;
updateStats();
}
// Creación de juegos
function createLyricsGame() {
const unusedLyrics = questionBank.lyrics.filter(q => !gameState.usedQuestions.lyrics.includes(q.lyric));
if (unusedLyrics.length === 0) {
gameState.usedQuestions.lyrics = [];
}
const question = getRandomItem(unusedLyrics);
gameState.usedQuestions.lyrics.push(question.lyric);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Completa la Letra</h2>
<p>${question.lyric}</p>
<input type="text" id="lyricsInput" placeholder="Completa la letra">
<button class="btn" onclick="checkLyrics('${question.answer}')">Verificar</button>
<div id="lyricsResult" class="result"></div>
`;
return gameCard;
}
function createAlbumGame() {
const unusedAlbums = questionBank.albums.filter(q => !gameState.usedQuestions.albums.includes(q.song));
if (unusedAlbums.length === 0) {
gameState.usedQuestions.albums = [];
}
const question = getRandomItem(unusedAlbums);
gameState.usedQuestions.albums.push(question.song);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>¿De Qué Álbum Es?</h2>
<p>¿En qué álbum aparece "${question.song}"?</p>
<input type="text" id="albumInput" placeholder="Nombre del álbum">
<button class="btn" onclick="checkAlbum('${question.album}')">Verificar</button>
<div id="albumResult" class="result"></div>
`;
return gameCard;
}
function createTriviaGame() {
const unusedTrivia = questionBank.trivia.filter(q => !gameState.usedQuestions.trivia.includes(q.question));
if (unusedTrivia.length === 0) {
gameState.usedQuestions.trivia = [];
}
const question = getRandomItem(unusedTrivia);
gameState.usedQuestions.trivia.push(question.question);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Trivia Swiftie</h2>
<p>${question.question}</p>
<input type="text" id="triviaInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTrivia('${question.answer}')">Verificar</button>
<div id="triviaResult" class="result"></div>
`;
return gameCard;
}
function createMemoryGame() {
const gameCard = document.createElement('div');
gameCard.className = 'game-card memory-game';
gameCard.innerHTML = `
<h2>Memoria Taylor</h2>
<div class="memory-grid" id="memoryGrid"></div>
<div id="memoryResult" class="result"></div>
`;
return gameCard;
}
// Funciones de verificación
function checkLyrics(answer) {
const input = document.getElementById('lyricsInput').value.toLowerCase();
const result = document.getElementById('lyricsResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkAlbum(answer) {
const input = document.getElementById('albumInput').value.toLowerCase();
const result = document.getElementById('albumResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkTrivia(answer) {
const input = document.getElementById('triviaInput').value.toLowerCase();
const result = document.getElementById('triviaResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
// Juego de memoria
function startMemoryGame() {
const grid = document.getElementById('memoryGrid');
if (!grid) return;
// Crear pares de cartas
const pairs = [...questionBank.memoryPairs];
const cards = [...pairs, ...pairs];
cards.sort(() => Math.random() - 0.5);
grid.innerHTML = cards.map((card, index) => `
<div class="memory-card" data-index="${index}" data-value="${card}">
<div class="memory-card-inner">
<div class="memory-card-front">?</div>
<div class="memory-card-back">${card}</div>
</div>
</div>
`).join('');
// Agregar eventos
grid.querySelectorAll('.memory-card').forEach(card => {
card.addEventListener('click', handleMemoryCardClick);
});
}
function handleMemoryCardClick() {
const card = this;
if (
card.classList.contains('flipped') ||
gameState.memoryGame.flippedCards.length >= 2
) return;
card.classList.add('flipped');
gameState.memoryGame.flippedCards.push(card);
if (gameState.memoryGame.flippedCards.length === 2) {
setTimeout(checkMemoryMatch, 1000);
}
}
function checkMemoryMatch() {
const [card1, card2] = gameState.memoryGame.flippedCards;
const match = card1.dataset.value === card2.dataset.value;
if (match) {
gameState.memoryGame.matchedPairs++;
const points = correctAnswer();
document.getElementById('memoryResult').textContent = `¡Par encontrado! +${points} puntos 🎉`;
if (gameState.memoryGame.matchedPairs === questionBank.memoryPairs.length) {
document.getElementById('memoryResult').textContent = "¡Juego completado! 🎉";
setTimeout(generateNewGames, 1500);
}
} else {
card1.classList.remove('flipped');
card2.classList.remove('flipped');
wrongAnswer();
}
gameState.memoryGame.flippedCards = [];
}
// Sistema de guardado
function saveProgress() {
const saveData = {
gameState: gameState,
timestamp: Date.now()
};
localStorage.setItem('taylorGameState', JSON.stringify(saveData));
}
function loadProgress() {
const saved = localStorage.getItem('taylorGameState');
if (saved) {
const saveData = JSON.parse(saved);
if (Date.now() - saveData.timestamp < 24 * 60 * 60 * 1000) { // 1 day
gameState = saveData.gameState;
} else {
localStorage.removeItem('taylorGameState');
}
}
updateStats();
}
// Función mejorada para generar nuevos juegos
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame(),
createWordSearchGame(),
createTrueFalseGame(),
createTimedQuizGame()
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
// Add initializations for other game types here
}
// Sistema de logros
const achievements = {
perfectStreak: { name: "Racha Perfecta", description: "Obtén una racha de 10 respuestas correctas", unlocked: false },
highScore: { name: "Alta Puntuación", description: "Alcanza 5000 puntos", unlocked: false },
masterLevel: { name: "Nivel Maestro", description: "Alcanza el nivel 5", unlocked: false }
};
function checkAchievements() {
if (gameState.streak >= 10 && !achievements.perfectStreak.unlocked) {
unlockAchievement('perfectStreak');
}
if (gameState.score >= 5000 && !achievements.highScore.unlocked) {
unlockAchievement('highScore');
}
if (gameState.level >= 5 && !achievements.masterLevel.unlocked) {
unlockAchievement('masterLevel');
}
}
function unlockAchievement(achievementId) {
achievements[achievementId].unlocked = true;
createConfetti();
alert(`¡Logro Desbloqueado! ${achievements[achievementId].name}\n${achievements[achievementId].description}`);
}
// Inicialización mejorada
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
};
</script>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Juegos de Taylor Swift - Edición Deluxe Plus</title>
<style>
:root {
--primary: #ff8fab;
--secondary: #ffc2d1;
--background: #ffe1e8;
--text: #2d3436;
}
body {
font-family: 'Arial', sans-serif;
background-color: var(--background);
margin: 0;
padding: 20px;
color: var(--text);
}
.header {
text-align: center;
background: linear-gradient(135deg, var(--primary), var(--secondary));
padding: 20px;
border-radius: 15px;
margin-bottom: 20px;
color: white;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.stats {
display: flex;
justify-content: space-around;
max-width: 600px;
margin: 0 auto 20px;
background: white;
padding: 10px;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.games-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
max-width: 1200px;
margin: 0 auto;
}
.game-card {
background: white;
padding: 20px;
border-radius: 15px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.game-card:hover {
transform: translateY(-5px);
}
.btn {
background: var(--primary);
border: none;
padding: 10px 20px;
border-radius: 5px;
color: white;
cursor: pointer;
transition: all 0.3s ease;
margin: 5px;
}
.btn:hover {
background: #ff6b8b;
transform: scale(1.05);
}
.result {
margin-top: 10px;
font-weight: bold;
padding: 5px;
border-radius: 5px;
text-align: center;
}
input[type="text"],
input[type="number"],
select {
padding: 8px;
margin: 5px;
border: 1px solid var(--secondary);
border-radius: 5px;
width: calc(100% - 20px);
}
.memory-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
margin-top: 10px;
}
.memory-card {
aspect-ratio: 1;
background: var(--primary);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 0;
transition: all 0.3s ease;
border-radius: 5px;
}
.memory-card.flipped {
background: white;
font-size: 14px;
border: 2px solid var(--primary);
}
.progress-bar {
width: 100%;
height: 20px;
background: #eee;
border-radius: 10px;
margin: 10px 0;
overflow: hidden;
}
.progress {
height: 100%;
background: var(--primary);
transition: width 0.3s ease;
}
.confetti {
position: fixed;
width: 10px;
height: 10px;
background: var(--primary);
animation: confetti 3s ease-in-out infinite;
pointer-events: none;
}
.unscramble-container {
display: flex;
flex-wrap: wrap;
gap: 5px;
margin: 10px 0;
}
.letter-tile {
padding: 10px;
background: var(--secondary);
border-radius: 5px;
cursor: pointer;
user-select: none;
}
.timeline-container {
display: flex;
flex-direction: column;
gap: 10px;
margin: 10px 0;
}
.timeline-item {
padding: 10px;
background: var(--secondary);
border-radius: 5px;
cursor: move;
}
@keyframes confetti {
0% { transform: translateY(0) rotate(0deg); }
100% { transform: translateY(100vh) rotate(720deg); }
}
</style>
</head>
<body>
<div class="header">
<h1>🎵 Juegos de Taylor Swift - Edición Deluxe Plus 🎵</h1>
<p>¡Demuestra cuánto sabes sobre Taylor!</p>
</div>
<div class="stats">
<div>Nivel: <span id="level">1</span></div>
<div>Puntos: <span id="score">0</span></div>
<div>Racha: <span id="streak">0</span></div>
<div>Mejor Puntuación: <span id="highScore">0</span></div>
</div>
<div class="games-container" id="gamesContainer"></div>
<!-- Botón para refrescar la página después de completar todos los juegos -->
<div style="text-align:center; margin-top: 20px;">
<button class="btn" onclick="location.reload()">Reiniciar Juegos</button>
</div>
<script>
// Banco de preguntas y respuestas
const questionBank = {
lyrics: [
{ lyric: "Cause baby I'm a _________", answer: "nightmare" },
{ lyric: "Are we out of the _________?", answer: "woods" },
{ lyric: "I stay up too _________ ", answer: "late" },
{ lyric: "Nice to meet you, where you _________", answer: "been" },
{ lyric: "We are never ever ever getting back _________", answer: "together" },
{ lyric: "I knew you were _________ when you walked in", answer: "trouble" },
{ lyric: "Shake it _________, shake it off", answer: "off" },
{ lyric: "Look what you made me _________", answer: "do" },
{ lyric: "Baby just say _________", answer: "yes" },
{ lyric: "I'm feeling twenty-_________ everything", answer: "two" },
{ lyric: "All of the _________ (all of the _________)", answer: "lights" },
{ lyric: "Out of the _________, into the rain", answer: "dark" },
{ lyric: "Meet me at _________ ", answer: "midnight" },
{ lyric: "Karma is my _________ star", answer: "lucky" },
{ lyric: "It's me, hi, I'm the _________", answer: "problem" },
{ lyric: "Draw the _________ wide", answer: "curtains" },
{ lyric: "Paint the town _________ ", answer: "red" },
{ lyric: "Dancing with our hands _________", answer: "tied" },
{ lyric: "I had a marvelous _________", answer: "time" },
{ lyric: "Welcome to New _________ ", answer: "york" }
],
albums: [
{ song: "Love Story", album: "fearless" },
{ song: "Shake It Off", album: "1989" },
{ song: "Cardigan", album: "folklore" },
{ song: "Anti-Hero", album: "midnights" },
{ song: "Cruel Summer", album: "lover" },
{ song: "All Too Well", album: "red" },
{ song: "Enchanted", album: "speak now" },
{ song: "Tim McGraw", album: "taylor swift" },
{ song: "August", album: "folklore" },
{ song: "Karma", album: "midnights" },
{ song: "You Belong With Me", album: "fearless" },
{ song: "Blank Space", album: "1989" },
{ song: "Willow", album: "evermore" },
{ song: "Lavender Haze", album: "midnights" },
{ song: "Lover", album: "lover" }
],
trivia: [
{ question: "¿En qué año nació Taylor Swift?", answer: "1989" },
{ question: "¿Cuál fue su primer álbum de estudio?", answer: "taylor swift" },
{ question: "¿En qué ciudad nació Taylor?", answer: "reading" },
{ question: "¿Cuál es el nombre de su gato blanco?", answer: "benjamin button" },
{ question: "¿Qué número considera Taylor su favorito?", answer: "13" },
{ question: "¿En qué año lanzó '1989'?", answer: "2014" },
{ question: "¿Qué instrumento tocaba Taylor en sus inicios?", answer: "guitarra" },
{ question: "¿Cuál fue su primer sencillo número 1 en Billboard Hot 100?", answer: "shake it off" },
{ question: "¿En qué estado creció Taylor?", answer: "pennsylvania" },
{ question: "¿Cuántos álbumes ha regrabado hasta 2024?", answer: "4" }
],
timedQuiz: [
{ question: "¿Cuál es el álbum más vendido de Taylor Swift?", answer: "1989" },
{ question: "¿Cuál es el verdadero nombre de Taylor Swift?", answer: "taylor alison swift" },
{ question: "¿Qué canción canta con Ed Sheeran?", answer: "everything has changed" },
{ question: "¿Cuál es su álbum más reciente en 2023?", answer: "midnights" }
],
memoryPairs: [
"1989", "Red", "Fearless", "Speak Now",
"Folklore", "Evermore", "Midnights", "Lover",
"Reputation", "Taylor Swift"
]
};
// Estado del juego
let gameState = {
level: 1,
score: 0,
streak: 0,
highScore: parseInt(localStorage.getItem('taylorHighScore')) || 0,
usedQuestions: {
lyrics: [],
albums: [],
trivia: [],
timedQuiz: []
},
memoryGame: {
flippedCards: [],
matchedPairs: 0
}
};
// Funciones auxiliares
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function createConfetti() {
for(let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.backgroundColor = ['#ff8fab', '#ffc2d1', '#ffb3c6', '#ff69b4'][Math.floor(Math.random() * 4)];
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
function updateStats() {
document.getElementById('level').textContent = gameState.level;
document.getElementById('score').textContent = gameState.score;
document.getElementById('streak').textContent = gameState.streak;
document.getElementById('highScore').textContent = gameState.highScore;
}
let timerInterval; // Declare timerInterval in a broader scope
function createWordSearchGame() {
const words = ["SWIFT", "LOVE", "FOLKLORE", "REPUTATION"];
const wordSearchGrid = [
['S', 'W', 'I', 'F', 'T', 'E'],
['L', 'O', 'V', 'E', 'R', 'T'],
['F', 'O', 'L', 'K', 'L', 'O'],
['R', 'E', 'P', 'U', 'T', 'A']
// Add more grid rows/letters here if needed
];
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Sopa de Letras</h2>
<p>Encuentra las siguientes palabras: <strong>${words.join(', ')}</strong></p>
<table class="wordsearch-table" border="1" cellspacing="0">
${wordSearchGrid.map(row => `
<tr>${row.map(letter => `<td>${letter}</td>`).join('')}</tr>
`).join('')}
</table>
<div id="wordSearchResult" class="result"></div>
`;
return gameCard;
}
function createTrueFalseGame() {
const questions = [
{ question: "Taylor Swift tiene un álbum llamado 'Midnights'", correct: true },
{ question: "Taylor nació en California", correct: false },
{ question: "Taylor tocó en la gira 'Lover' en 2020", correct: false }
];
const question = getRandomItem(questions);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Verdadero o Falso</h2>
<p>${question.question}</p>
<button class="btn" onclick="checkTrueFalse(this, ${question.correct}, true)">Verdadero</button>
<button class="btn" onclick="checkTrueFalse(this, ${question.correct}, false)">Falso</button>
<div class="result"></div>
`;
return gameCard;
}
function checkTrueFalse(btn, correct, answer) {
const result = btn.parentElement.querySelector('.result');
if (correct === answer) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function createTimedQuizGame() {
let timeRemaining = 30; // 30 seconds
const unusedTimedQuiz = questionBank.timedQuiz.filter(q => !gameState.usedQuestions.timedQuiz.includes(q.question));
if (unusedTimedQuiz.length === 0) {
gameState.usedQuestions.timedQuiz = [];
}
const question = getRandomItem(unusedTimedQuiz);
gameState.usedQuestions.timedQuiz.push(question.question);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Quiz de Tiempo</h2>
<p>${question.question}</p>
<input type="text" id="timedQuizInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTimedQuiz('${question.answer}')">Verificar</button>
<div id="timedQuizResult" class="result"></div>
<div id="timerDisplay">Tiempo: ${timeRemaining} segundos</div>
`;
timerInterval = setInterval(() => {
if (timeRemaining > 0) {
timeRemaining--;
document.getElementById('timerDisplay').textContent = `Tiempo: ${timeRemaining} segundos`;
} else {
clearInterval(timerInterval);
document.getElementById('timedQuizResult').textContent = "¡Tiempo agotado! 😊";
}
}, 1000);
return gameCard;
}
function checkTimedQuiz(answer) {
const input = document.getElementById('timedQuizInput').value.toLowerCase();
const result = document.getElementById('timedQuizResult');
clearInterval(timerInterval); // Stop the timer when checking answer
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function correctAnswer() {
const points = 100 * gameState.level;
gameState.score += points;
gameState.streak++;
if(gameState.score > gameState.highScore) {
gameState.highScore = gameState.score;
localStorage.setItem('taylorHighScore', gameState.highScore);
}
if(gameState.streak % 3 === 0) {
gameState.level++;
createConfetti();
setTimeout(generateNewGames, 1500);
}
updateStats();
document.dispatchEvent(new Event('scoreUpdate'));
return points;
}
function wrongAnswer() {
gameState.streak = 0;
updateStats();
}
// Creación de juegos
function createLyricsGame() {
const unusedLyrics = questionBank.lyrics.filter(q => !gameState.usedQuestions.lyrics.includes(q.lyric));
if (unusedLyrics.length === 0) {
gameState.usedQuestions.lyrics = [];
}
const question = getRandomItem(unusedLyrics);
gameState.usedQuestions.lyrics.push(question.lyric);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Completa la Letra</h2>
<p>${question.lyric}</p>
<input type="text" id="lyricsInput" placeholder="Completa la letra">
<button class="btn" onclick="checkLyrics('${question.answer}')">Verificar</button>
<div id="lyricsResult" class="result"></div>
`;
return gameCard;
}
function createAlbumGame() {
const unusedAlbums = questionBank.albums.filter(q => !gameState.usedQuestions.albums.includes(q.song));
if (unusedAlbums.length === 0) {
gameState.usedQuestions.albums = [];
}
const question = getRandomItem(unusedAlbums);
gameState.usedQuestions.albums.push(question.song);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>¿De Qué Álbum Es?</h2>
<p>¿En qué álbum aparece "${question.song}"?</p>
<input type="text" id="albumInput" placeholder="Nombre del álbum">
<button class="btn" onclick="checkAlbum('${question.album}')">Verificar</button>
<div id="albumResult" class="result"></div>
`;
return gameCard;
}
function createTriviaGame() {
const unusedTrivia = questionBank.trivia.filter(q => !gameState.usedQuestions.trivia.includes(q.question));
if (unusedTrivia.length === 0) {
gameState.usedQuestions.trivia = [];
}
const question = getRandomItem(unusedTrivia);
gameState.usedQuestions.trivia.push(question.question);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Trivia Swiftie</h2>
<p>${question.question}</p>
<input type="text" id="triviaInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTrivia('${question.answer}')">Verificar</button>
<div id="triviaResult" class="result"></div>
`;
return gameCard;
}
function createMemoryGame() {
const gameCard = document.createElement('div');
gameCard.className = 'game-card memory-game';
gameCard.innerHTML = `
<h2>Memoria Taylor</h2>
<div class="memory-grid" id="memoryGrid"></div>
<div id="memoryResult" class="result"></div>
`;
return gameCard;
}
// Funciones de verificación
function checkLyrics(answer) {
const input = document.getElementById('lyricsInput').value.toLowerCase();
const result = document.getElementById('lyricsResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkAlbum(answer) {
const input = document.getElementById('albumInput').value.toLowerCase();
const result = document.getElementById('albumResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkTrivia(answer) {
const input = document.getElementById('triviaInput').value.toLowerCase();
const result = document.getElementById('triviaResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
// Juego de memoria
function startMemoryGame() {
const grid = document.getElementById('memoryGrid');
if (!grid) return;
// Crear pares de cartas
const pairs = [...questionBank.memoryPairs];
const cards = [...pairs, ...pairs];
cards.sort(() => Math.random() - 0.5);
grid.innerHTML = cards.map((card, index) => `
<div class="memory-card" data-index="${index}" data-value="${card}">
<div class="memory-card-inner">
<div class="memory-card-front">?</div>
<div class="memory-card-back">${card}</div>
</div>
</div>
`).join('');
// Agregar eventos
grid.querySelectorAll('.memory-card').forEach(card => {
card.addEventListener('click', handleMemoryCardClick);
});
}
function handleMemoryCardClick() {
const card = this;
if (
card.classList.contains('flipped') ||
gameState.memoryGame.flippedCards.length >= 2
) return;
card.classList.add('flipped');
gameState.memoryGame.flippedCards.push(card);
if (gameState.memoryGame.flippedCards.length === 2) {
setTimeout(checkMemoryMatch, 1000);
}
}
function checkMemoryMatch() {
const [card1, card2] = gameState.memoryGame.flippedCards;
const match = card1.dataset.value === card2.dataset.value;
if (match) {
gameState.memoryGame.matchedPairs++;
const points = correctAnswer();
document.getElementById('memoryResult').textContent = `¡Par encontrado! +${points} puntos 🎉`;
if (gameState.memoryGame.matchedPairs === questionBank.memoryPairs.length) {
document.getElementById('memoryResult').textContent = "¡Juego completado! 🎉";
setTimeout(generateNewGames, 1500);
}
} else {
card1.classList.remove('flipped');
card2.classList.remove('flipped');
wrongAnswer();
}
gameState.memoryGame.flippedCards = [];
}
// Sistema de guardado
function saveProgress() {
const saveData = {
gameState: gameState,
timestamp: Date.now()
};
localStorage.setItem('taylorGameState', JSON.stringify(saveData));
}
function loadProgress() {
const saved = localStorage.getItem('taylorGameState');
if (saved) {
const saveData = JSON.parse(saved);
if (Date.now() - saveData.timestamp < 24 * 60 * 60 * 1000) { // 1 day
gameState = saveData.gameState;
} else {
localStorage.removeItem('taylorGameState');
}
}
updateStats();
}
// Función mejorada para generar nuevos juegos
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame(),
createWordSearchGame(),
createTrueFalseGame(),
createTimedQuizGame()
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
// Add initializations for other game types here
}
// Sistema de logros
const achievements = {
perfectStreak: { name: "Racha Perfecta", description: "Obtén una racha de 10 respuestas correctas", unlocked: false },
highScore: { name: "Alta Puntuación", description: "Alcanza 5000 puntos", unlocked: false },
masterLevel: { name: "Nivel Maestro", description: "Alcanza el nivel 5", unlocked: false }
};
function checkAchievements() {
if (gameState.streak >= 10 && !achievements.perfectStreak.unlocked) {
unlockAchievement('perfectStreak');
}
if (gameState.score >= 5000 && !achievements.highScore.unlocked) {
unlockAchievement('highScore');
}
if (gameState.level >= 5 && !achievements.masterLevel.unlocked) {
unlockAchievement('masterLevel');
}
}
function unlockAchievement(achievementId) {
achievements[achievementId].unlocked = true;
createConfetti();
alert(`¡Logro Desbloqueado! ${achievements[achievementId].name}\n${achievements[achievementId].description}`);
}
// Inicialización mejorada
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
};
</script>
</body>
</html>
Componentes Mejorados y Nuevos Juegos:
Sopa de Letras: Ahora tiene un formato más claro y puede expandirse con más filas y letras. Para una verdadera funcionalidad de interacción, necesitaría implementar funcionalidad de selección y verificación de palabras encontradas.
Preguntas de Quiz con Tiempo Aumentadas: Más preguntas disponibles y se seleccionan aleatoriamente de un conjunto de preguntas disponibles.
Botón de Reinicio: Agrega la capacidad para refrescar la página cuando se completen exitosamente todos los juegos.
Juegos Adicionales: Si deseas implementar más juegos, puedes repetir las funciones ya establecidas como base e integrarlas de manera similar, asegurando una interfaz de juego consistente.
Los cambios aseguran una experiencia más interactiva y hacen que la estructura de desarrollo futura sea más modular para integrar nuevos tipos de juegos e interacciones.
<div class="stats">
<div>Nivel: <span id="level">1</span></div>
<div>Puntos: <span id="score">0</span></div>
<div>Racha: <span id="streak">0</span></div>
<div>Mejor Puntuación: <span id="highScore">0</span></div>
</div>
<div class="games-container" id="gamesContainer"></div>
<script>
// Banco de preguntas y respuestas
const questionBank = {
lyrics: [
{ lyric: "Cause baby I'm a _________", answer: "nightmare" },
{ lyric: "Are we out of the _________?", answer: "woods" },
{ lyric: "I stay up too _________ ", answer: "late" },
{ lyric: "Nice to meet you, where you _________", answer: "been" },
{ lyric: "We are never ever ever getting back _________", answer: "together" },
{ lyric: "I knew you were _________ when you walked in", answer: "trouble" },
{ lyric: "Shake it _________, shake it off", answer: "off" },
{ lyric: "Look what you made me _________", answer: "do" },
{ lyric: "Baby just say _________", answer: "yes" },
{ lyric: "I'm feeling twenty-_________ everything", answer: "two" },
{ lyric: "All of the _________ (all of the _________)", answer: "lights" },
{ lyric: "Out of the _________, into the rain", answer: "dark" },
{ lyric: "Meet me at _________ ", answer: "midnight" },
{ lyric: "Karma is my _________ star", answer: "lucky" },
{ lyric: "It's me, hi, I'm the _________", answer: "problem" },
{ lyric: "Draw the _________ wide", answer: "curtains" },
{ lyric: "Paint the town _________ ", answer: "red" },
{ lyric: "Dancing with our hands _________", answer: "tied" },
{ lyric: "I had a marvelous _________", answer: "time" },
{ lyric: "Welcome to New _________ ", answer: "york" }
],
albums: [
{ song: "Love Story", album: "fearless" },
{ song: "Shake It Off", album: "1989" },
{ song: "Cardigan", album: "folklore" },
{ song: "Anti-Hero", album: "midnights" },
{ song: "Cruel Summer", album: "lover" },
{ song: "All Too Well", album: "red" },
{ song: "Enchanted", album: "speak now" },
{ song: "Tim McGraw", album: "taylor swift" },
{ song: "August", album: "folklore" },
{ song: "Karma", album: "midnights" },
{ song: "You Belong With Me", album: "fearless" },
{ song: "Blank Space", album: "1989" },
{ song: "Willow", album: "evermore" },
{ song: "Lavender Haze", album: "midnights" },
{ song: "Lover", album: "lover" }
],
trivia: [
{ question: "¿En qué año nació Taylor Swift?", answer: "1989" },
{ question: "¿Cuál fue su primer álbum de estudio?", answer: "taylor swift" },
{ question: "¿En qué ciudad nació Taylor?", answer: "reading" },
{ question: "¿Cuál es el nombre de su gato blanco?", answer: "benjamin button" },
{ question: "¿Qué número considera Taylor su favorito?", answer: "13" },
{ question: "¿En qué año lanzó '1989'?", answer: "2014" },
{ question: "¿Qué instrumento tocaba Taylor en sus inicios?", answer: "guitarra" },
{ question: "¿Cuál fue su primer sencillo número 1 en Billboard Hot 100?", answer: "shake it off" },
{ question: "¿En qué estado creció Taylor?", answer: "pennsylvania" },
{ question: "¿Cuántos álbumes ha regrabado hasta 2024?", answer: "4" }
],
unscramble: [
{ word: "FEARLESS", hint: "Álbum que incluye 'Love Story'" },
{ word: "SWIFTIE", hint: "Nombre que reciben los fans de Taylor" },
{ word: "FOLKLORE", hint: "Álbum sorpresa lanzado en 2020" },
{ word: "REPUTATION", hint: "Álbum con serpientes como símbolo" },
{ word: "ENCHANTED", hint: "Canción de Speak Now que se hizo viral en TikTok" }
],
timeline: [
{ event: "Lanzamiento de Taylor Swift", year: 2006 },
{ event: "Lanzamiento de Fearless", year: 2008 },
{ event: "Lanzamiento de Speak Now", year: 2010 },
{ event: "Lanzamiento de Red", year: 2012 },
{ event: "Lanzamiento de 1989", year: 2014 }
],
memoryPairs: [
"1989", "Red", "Fearless", "Speak Now",
"Folklore", "Evermore", "Midnights", "Lover",
"Reputation", "Taylor Swift"
]
};
// Estado del juego
let gameState = {
level: 1,
score: 0,
streak: 0,
highScore: parseInt(localStorage.getItem('taylorHighScore')) || 0,
usedQuestions: {
lyrics: [],
albums: [],
trivia: [],
unscramble: [],
timeline: []
},
memoryGame: {
flippedCards: [],
matchedPairs: 0
}
};
// Funciones auxiliares
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function createConfetti() {
for(let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.backgroundColor = ['#ff8fab', '#ffc2d1', '#ffb3c6', '#ff69b4'][Math.floor(Math.random() * 4)];
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
function updateStats() {
document.getElementById('level').textContent = gameState.level;
document.getElementById('score').textContent = gameState.score;
document.getElementById('streak').textContent = gameState.streak;
document.getElementById('highScore').textContent = gameState.highScore;
}
let timerInterval; // Declare timerInterval in a broader scope
function createWordSearchGame() {
const words = ["SWIFT", "LOVE", "FOLKLORE", "REPUTATION"];
const wordSearchGrid = [
['S', 'W', 'I', 'F', 'T', 'E'],
['L', 'O', 'V', 'E', 'R', 'T'],
['F', 'O', 'L', 'K', 'L', 'O'],
['R', 'E', 'P', 'U', 'T', 'A']
// Expand with more rows/letters
];
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Sopa de Letras</h2>
<table class="wordsearch-table">
${wordSearchGrid.map(row => `
<tr>${row.map(letter => `<td>${letter}</td>`).join('')}</tr>
`).join('')}
</table>
<p>Encuentra las palabras: ${words.join(', ')}</p>
<div id="wordSearchResult" class="result"></div>
`;
return gameCard;
}
function createTrueFalseGame() {
const questions = [
{ question: "Taylor Swift tiene un álbum llamado 'Midnights'", correct: true },
{ question: "Taylor nació en California", correct: false }
// Add more questions
];
const question = getRandomItem(questions);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Verdadero o Falso</h2>
<p>${question.question}</p>
<button class="btn" onclick="checkTrueFalse(${question.correct}, true)">Verdadero</button>
<button class="btn" onclick="checkTrueFalse(${question.correct}, false)">Falso</button>
<div class="result" data-id="trueFalseResult"></div>
`;
return gameCard;
}
function checkTrueFalse(correct, answer) {
const result = document.querySelector('[data-id="trueFalseResult"]');
if (correct === answer) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function createTimedQuizGame() {
let timeRemaining = 30; // 30 seconds
const question = { question: "¿Cuál es el álbum más vendido de Taylor Swift?", answer: "1989" };
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Quiz de Tiempo</h2>
<p>${question.question}</p>
<input type="text" id="timedQuizInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTimedQuiz('${question.answer}')">Verificar</button>
<div id="timedQuizResult" class="result"></div>
<div id="timerDisplay">Tiempo: ${timeRemaining} segundos</div>
`;
timerInterval = setInterval(() => {
if (timeRemaining > 0) {
timeRemaining--;
document.getElementById('timerDisplay').textContent = `Tiempo: ${timeRemaining} segundos`;
} else {
clearInterval(timerInterval);
document.getElementById('timedQuizResult').textContent = "¡Tiempo agotado! 😊";
}
}, 1000);
return gameCard;
}
function checkTimedQuiz(answer) {
const input = document.getElementById('timedQuizInput').value.toLowerCase();
const result = document.getElementById('timedQuizResult');
clearInterval(timerInterval); // Stop the timer when checking answer
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function correctAnswer() {
const points = 100 * gameState.level;
gameState.score += points;
gameState.streak++;
if(gameState.score > gameState.highScore) {
gameState.highScore = gameState.score;
localStorage.setItem('taylorHighScore', gameState.highScore);
}
if(gameState.streak % 3 === 0) {
gameState.level++;
createConfetti();
setTimeout(generateNewGames, 1500);
}
updateStats();
document.dispatchEvent(new Event('scoreUpdate'));
return points;
}
function wrongAnswer() {
gameState.streak = 0;
updateStats();
}
// Creación de juegos
function createLyricsGame() {
const unusedLyrics = questionBank.lyrics.filter(q => !gameState.usedQuestions.lyrics.includes(q.lyric));
if (unusedLyrics.length === 0) {
gameState.usedQuestions.lyrics = [];
}
const question = getRandomItem(unusedLyrics);
gameState.usedQuestions.lyrics.push(question.lyric);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Completa la Letra</h2>
<p>${question.lyric}</p>
<input type="text" id="lyricsInput" placeholder="Completa la letra">
<button class="btn" onclick="checkLyrics('${question.answer}')">Verificar</button>
<div id="lyricsResult" class="result"></div>
`;
return gameCard;
}
function createAlbumGame() {
const unusedAlbums = questionBank.albums.filter(q => !gameState.usedQuestions.albums.includes(q.song));
if (unusedAlbums.length === 0) {
gameState.usedQuestions.albums = [];
}
const question = getRandomItem(unusedAlbums);
gameState.usedQuestions.albums.push(question.song);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>¿De Qué Álbum Es?</h2>
<p>¿En qué álbum aparece "${question.song}"?</p>
<input type="text" id="albumInput" placeholder="Nombre del álbum">
<button class="btn" onclick="checkAlbum('${question.album}')">Verificar</button>
<div id="albumResult" class="result"></div>
`;
return gameCard;
}
function createTriviaGame() {
const unusedTrivia = questionBank.trivia.filter(q => !gameState.usedQuestions.trivia.includes(q.question));
if (unusedTrivia.length === 0) {
gameState.usedQuestions.trivia = [];
}
const question = getRandomItem(unusedTrivia);
gameState.usedQuestions.trivia.push(question.question);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Trivia Swiftie</h2>
<p>${question.question}</p>
<input type="text" id="triviaInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTrivia('${question.answer}')">Verificar</button>
<div id="triviaResult" class="result"></div>
`;
return gameCard;
}
function createMemoryGame() {
const gameCard = document.createElement('div');
gameCard.className = 'game-card memory-game';
gameCard.innerHTML = `
<h2>Memoria Taylor</h2>
<div class="memory-grid" id="memoryGrid"></div>
<div id="memoryResult" class="result"></div>
`;
return gameCard;
}
// Funciones de verificación
function checkLyrics(answer) {
const input = document.getElementById('lyricsInput').value.toLowerCase();
const result = document.getElementById('lyricsResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkAlbum(answer) {
const input = document.getElementById('albumInput').value.toLowerCase();
const result = document.getElementById('albumResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkTrivia(answer) {
const input = document.getElementById('triviaInput').value.toLowerCase();
const result = document.getElementById('triviaResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
// Juego de memoria
function startMemoryGame() {
const grid = document.getElementById('memoryGrid');
if (!grid) return;
// Crear pares de cartas
const pairs = [...questionBank.memoryPairs];
const cards = [...pairs, ...pairs];
cards.sort(() => Math.random() - 0.5);
grid.innerHTML = cards.map((card, index) => `
<div class="memory-card" data-index="${index}" data-value="${card}">
<div class="memory-card-inner">
<div class="memory-card-front">?</div>
<div class="memory-card-back">${card}</div>
</div>
</div>
`).join('');
// Agregar eventos
grid.querySelectorAll('.memory-card').forEach(card => {
card.addEventListener('click', handleMemoryCardClick);
});
}
function handleMemoryCardClick() {
const card = this;
if (
card.classList.contains('flipped') ||
gameState.memoryGame.flippedCards.length >= 2
) return;
card.classList.add('flipped');
gameState.memoryGame.flippedCards.push(card);
if (gameState.memoryGame.flippedCards.length === 2) {
setTimeout(checkMemoryMatch, 1000);
}
}
function checkMemoryMatch() {
const [card1, card2] = gameState.memoryGame.flippedCards;
const match = card1.dataset.value === card2.dataset.value;
if (match) {
gameState.memoryGame.matchedPairs++;
const points = correctAnswer();
document.getElementById('memoryResult').textContent = `¡Par encontrado! +${points} puntos 🎉`;
if (gameState.memoryGame.matchedPairs === questionBank.memoryPairs.length) {
document.getElementById('memoryResult').textContent = "¡Juego completado! 🎉";
setTimeout(generateNewGames, 1500);
}
} else {
card1.classList.remove('flipped');
card2.classList.remove('flipped');
wrongAnswer();
}
gameState.memoryGame.flippedCards = [];
}
// Sistema de guardado
function saveProgress() {
const saveData = {
gameState: gameState,
timestamp: Date.now()
};
localStorage.setItem('taylorGameState', JSON.stringify(saveData));
}
function loadProgress() {
const saved = localStorage.getItem('taylorGameState');
if (saved) {
const saveData = JSON.parse(saved);
if (Date.now() - saveData.timestamp < 24 * 60 * 60 * 1000) { // 1 day
gameState = saveData.gameState;
} else {
localStorage.removeItem('taylorGameState');
}
}
updateStats();
}
// Función mejorada para generar nuevos juegos
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame(),
createWordSearchGame(),
createTrueFalseGame(),
createTimedQuizGame()
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
// Add initializations for other game types here
}
// Sistema de logros
const achievements = {
perfectStreak: { name: "Racha Perfecta", description: "Obtén una racha de 10 respuestas correctas", unlocked: false },
highScore: { name: "Alta Puntuación", description: "Alcanza 5000 puntos", unlocked: false },
masterLevel: { name: "Nivel Maestro", description: "Alcanza el nivel 5", unlocked: false }
};
function checkAchievements() {
if (gameState.streak >= 10 && !achievements.perfectStreak.unlocked) {
unlockAchievement('perfectStreak');
}
if (gameState.score >= 5000 && !achievements.highScore.unlocked) {
unlockAchievement('highScore');
}
if (gameState.level >= 5 && !achievements.masterLevel.unlocked) {
unlockAchievement('masterLevel');
}
}
function unlockAchievement(achievementId) {
achievements[achievementId].unlocked = true;
createConfetti();
alert(`¡Logro Desbloqueado! ${achievements[achievementId].name}\n${achievements[achievementId].description}`);
}
// Inicialización mejorada
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
};
</script>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Juegos de Taylor Swift - Edición Deluxe Plus</title>
<style>
:root {
--primary: #ff8fab;
--secondary: #ffc2d1;
--background: #ffe1e8;
--text: #2d3436;
}
body {
font-family: 'Arial', sans-serif;
background-color: var(--background);
margin: 0;
padding: 20px;
color: var(--text);
}
.header {
text-align: center;
background: linear-gradient(135deg, var(--primary), var(--secondary));
padding: 20px;
border-radius: 15px;
margin-bottom: 20px;
color: white;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.stats {
display: flex;
justify-content: space-around;
max-width: 600px;
margin: 0 auto 20px;
background: white;
padding: 10px;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.games-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
max-width: 1200px;
margin: 0 auto;
}
.game-card {
background: white;
padding: 20px;
border-radius: 15px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.game-card:hover {
transform: translateY(-5px);
}
.btn {
background: var(--primary);
border: none;
padding: 10px 20px;
border-radius: 5px;
color: white;
cursor: pointer;
transition: all 0.3s ease;
margin: 5px;
}
.btn:hover {
background: #ff6b8b;
transform: scale(1.05);
}
.result {
margin-top: 10px;
font-weight: bold;
padding: 5px;
border-radius: 5px;
text-align: center;
}
input[type="text"],
input[type="number"],
select {
padding: 8px;
margin: 5px;
border: 1px solid var(--secondary);
border-radius: 5px;
width: calc(100% - 20px);
}
.wordsearch-table {
border-collapse: collapse;
margin: 20px 0;
width: 100%;
}
.wordsearch-table td {
width: 40px;
height: 40px;
text-align: center;
vertical-align: middle;
cursor: pointer;
background-color: white;
border: 1px solid var(--secondary);
user-select: none;
}
.wordsearch-table td.selected {
background-color: var(--primary);
color: white;
}
@keyframes confetti {
0% { transform: translateY(0) rotate(0deg); }
100% { transform: translateY(100vh) rotate(720deg); }
}
</style>
</head>
<body>
<div class="header">
<h1>🎵 Juegos de Taylor Swift - Edición Deluxe Plus 🎵</h1>
<p>¡Demuestra cuánto sabes sobre Taylor!</p>
</div>
<div class="stats">
<div>Nivel: <span id="level">1</span></div>
<div>Puntos: <span id="score">0</span></div>
<div>Racha: <span id="streak">0</span></div>
<div>Mejor Puntuación: <span id="highScore">0</span></div>
</div>
<div class="games-container" id="gamesContainer"></div>
<script>
// Banco de preguntas y respuestas
const questionBank = {
lyrics: [
{ lyric: "Cause baby I'm a _________", answer: "nightmare" },
{ lyric: "Are we out of the _________?", answer: "woods" },
{ lyric: "I stay up too _________ ", answer: "late" },
{ lyric: "Nice to meet you, where you _________", answer: "been" },
{ lyric: "We are never ever ever getting back _________", answer: "together" },
{ lyric: "I knew you were _________ when you walked in", answer: "trouble" },
{ lyric: "Shake it _________, shake it off", answer: "off" },
{ lyric: "Look what you made me _________", answer: "do" },
{ lyric: "Baby just say _________", answer: "yes" },
{ lyric: "I'm feeling twenty-_________ everything", answer: "two" },
{ lyric: "All of the _________ (all of the _________)", answer: "lights" },
{ lyric: "Out of the _________, into the rain", answer: "dark" },
{ lyric: "Meet me at _________ ", answer: "midnight" },
{ lyric: "Karma is my _________ star", answer: "lucky" },
{ lyric: "It's me, hi, I'm the _________", answer: "problem" },
{ lyric: "Draw the _________ wide", answer: "curtains" },
{ lyric: "Paint the town _________ ", answer: "red" },
{ lyric: "Dancing with our hands _________", answer: "tied" },
{ lyric: "I had a marvelous _________", answer: "time" },
{ lyric: "Welcome to New _________ ", answer: "york" }
],
albums: [
{ song: "Love Story", album: "fearless" },
{ song: "Shake It Off", album: "1989" },
{ song: "Cardigan", album: "folklore" },
{ song: "Anti-Hero", album: "midnights" },
{ song: "Cruel Summer", album: "lover" },
{ song: "All Too Well", album: "red" },
{ song: "Enchanted", album: "speak now" },
{ song: "Tim McGraw", album: "taylor swift" },
{ song: "August", album: "folklore" },
{ song: "Karma", album: "midnights" },
{ song: "You Belong With Me", album: "fearless" },
{ song: "Blank Space", album: "1989" },
{ song: "Willow", album: "evermore" },
{ song: "Lavender Haze", album: "midnights" },
{ song: "Lover", album: "lover" }
],
trivia: [
{ question: "¿En qué año nació Taylor Swift?", answer: "1989" },
{ question: "¿Cuál fue su primer álbum de estudio?", answer: "taylor swift" },
{ question: "¿En qué ciudad nació Taylor?", answer: "reading" },
{ question: "¿Cuál es el nombre de su gato blanco?", answer: "benjamin button" },
{ question: "¿Qué número considera Taylor su favorito?", answer: "13" },
{ question: "¿En qué año lanzó '1989'?", answer: "2014" },
{ question: "¿Qué instrumento tocaba Taylor en sus inicios?", answer: "guitarra" },
{ question: "¿Cuál fue su primer sencillo número 1 en Billboard Hot 100?", answer: "shake it off" },
{ question: "¿En qué estado creció Taylor?", answer: "pennsylvania" },
{ question: "¿Cuántos álbumes ha regrabado hasta 2024?", answer: "4" }
],
memoryPairs: [
"1989", "Red", "Fearless", "Speak Now",
"Folklore", "Evermore", "Midnights", "Lover",
"Reputation", "Taylor Swift"
]
};
// Estado del juego
let gameState = {
level: 1,
score: 0,
streak: 0,
highScore: parseInt(localStorage.getItem('taylorHighScore')) || 0,
usedQuestions: {
lyrics: [],
albums: [],
trivia: []
},
memoryGame: {
flippedCards: [],
matchedPairs: 0
}
};
// Funciones auxiliares
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function createConfetti() {
for(let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.backgroundColor = ['#ff8fab', '#ffc2d1', '#ffb3c6', '#ff69b4'][Math.floor(Math.random() * 4)];
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
function updateStats() {
document.getElementById('level').textContent = gameState.level;
document.getElementById('score').textContent = gameState.score;
document.getElementById('streak').textContent = gameState.streak;
document.getElementById('highScore').textContent = gameState.highScore;
}
let timerInterval; // Declare timerInterval in a broader scope
function createWordSearchGame() {
const words = ["SWIFT", "LOVE", "FOLKLORE", "REPUTATION"];
const wordSearchGrid = [
['S', 'W', 'I', 'F', 'T', 'E'],
['L', 'O', 'V', 'E', 'R', 'T'],
['F', 'O', 'L', 'K', 'L', 'O'],
['R', 'E', 'P', 'U', 'T', 'A']
];
const foundWords = new Set();
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Sopa de Letras</h2>
<p>Encuentra las palabras: ${words.join(', ')}</p>
<table class="wordsearch-table">
${wordSearchGrid.map((row, rowIndex) => `
<tr>${row.map((letter, colIndex) => `<td data-row="${rowIndex}" data-col="${colIndex}" onclick="selectLetter(this)">${letter}</td>`).join('')}</tr>
`).join('')}
</table>
<button class="btn" onclick="checkWordSearch(words, foundWords)">Verificar Palabras</button>
<div id="wordSearchResult" class="result"></div>
`;
return gameCard;
}
let selectedLetters = [];
function selectLetter(cell) {
if (!cell.classList.contains('selected')) {
cell.classList.add('selected');
selectedLetters.push(cell);
}
}
function checkWordSearch(words, foundWords) {
const selectedWord = selectedLetters.map(cell => cell.textContent).join('');
const result = document.getElementById('wordSearchResult');
if (words.includes(selectedWord) && !foundWords.has(selectedWord)) {
foundWords.add(selectedWord);
selectedLetters.forEach(cell => cell.style.backgroundColor = "#ff8fab");
selectedLetters = [];
result.textContent = `¡Encontraste la palabra: ${selectedWord}!`;
result.style.color = "green";
if (foundWords.size === words.length) {
const points = correctAnswer();
result.textContent += ` ¡Completaste el Juego! +${points} puntos 🎉`;
}
} else {
result.textContent = "No es una palabra válida o ya encontrada";
result.style.color = "red";
selectedLetters.forEach(cell => cell.classList.remove('selected'));
selectedLetters = [];
}
}
function createTrueFalseGame() {
const questions = [
{ question: "Taylor Swift tiene un álbum llamado 'Midnights'", correct: true },
{ question: "Taylor nació en California", correct: false }
// Add more questions
];
const question = getRandomItem(questions);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Verdadero o Falso</h2>
<p>${question.question}</p>
<button class="btn" onclick="checkTrueFalse(this.parentElement, ${question.correct}, true)">Verdadero</button>
<button class="btn" onclick="checkTrueFalse(this.parentElement, ${question.correct}, false)">Falso</button>
<div class="result"></div>
`;
return gameCard;
}
function checkTrueFalse(parent, correct, answer) {
const result = parent.querySelector('.result');
if (correct === answer) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
// Continuar con el resto del código para otros juegos...
function correctAnswer() {
const points = 100 * gameState.level;
gameState.score += points;
gameState.streak++;
if(gameState.score > gameState.highScore) {
gameState.highScore = gameState.score;
localStorage.setItem('taylorHighScore', gameState.highScore);
}
if(gameState.streak % 3 === 0) {
gameState.level++;
createConfetti();
setTimeout(generateNewGames, 1500);
}
updateStats();
document.dispatchEvent(new Event('scoreUpdate'));
return points;
}
function wrongAnswer() {
gameState.streak = 0;
updateStats();
}
// Sistema de guardado y carga, más lógica del juego sigue aquí...
// Inicialización mejorada
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
};
</script>
</body>
</html>
Cambios y Mejoras:
Interactividad: Los usuarios ahora pueden hacer clic en las letras para seleccionarlas y formar palabras.
Validación: Añadí un botón de "Verificar Palabras" que evalúa si las letras seleccionadas forman una palabra válida que aún no ha sido encontrada.
Selección Visual: Las celdas seleccionadas cambian de color al ser seleccionadas, y se marcan permanentemente cuando forman correctamente una palabra.
Este código proporciona las bases para una interacción básica con la Sopa de Letras. Para una implementación más completa, podrías añadir reglas como restricciones de dirección al formar palabras (por ejemplo, solo horizontal o verticalmente).
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Juegos de Taylor Swift - Edición Deluxe Plus</title>
<style>
:root {
--primary: #ff8fab;
--secondary: #ffc2d1;
--background: #ffe1e8;
--text: #2d3436;
}
body {
font-family: 'Arial', sans-serif;
background-color: var(--background);
margin: 0;
padding: 20px;
color: var(--text);
}
.header {
text-align: center;
background: linear-gradient(135deg, var(--primary), var(--secondary));
padding: 20px;
border-radius: 15px;
margin-bottom: 20px;
color: white;
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.stats {
display: flex;
justify-content: space-around;
max-width: 600px;
margin: 0 auto 20px;
background: white;
padding: 10px;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.games-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
max-width: 1200px;
margin: 0 auto;
}
.game-card {
background: white;
padding: 20px;
border-radius: 15px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.game-card:hover {
transform: translateY(-5px);
}
.btn {
background: var(--primary);
border: none;
padding: 10px 20px;
border-radius: 5px;
color: white;
cursor: pointer;
transition: all 0.3s ease;
margin: 5px;
}
.btn:hover {
background: #ff6b8b;
transform: scale(1.05);
}
.result {
margin-top: 10px;
font-weight: bold;
padding: 5px;
border-radius: 5px;
text-align: center;
}
input[type="text"],
input[type="number"],
select {
padding: 8px;
margin: 5px;
border: 1px solid var(--secondary);
border-radius: 5px;
width: calc(100% - 20px);
}
.memory-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
margin-top: 10px;
}
.memory-card {
aspect-ratio: 1;
background: var(--primary);
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
font-size: 0;
transition: all 0.3s ease;
border-radius: 5px;
}
.memory-card.flipped {
background: white;
font-size: 14px;
border: 2px solid var(--primary);
}
.wordsearch-table {
border-collapse: collapse;
margin: 20px 0;
width: 100%;
}
.wordsearch-table td {
width: 40px;
height: 40px;
text-align: center;
vertical-align: middle;
cursor: pointer;
background-color: white;
border: 1px solid var(--secondary);
user-select: none;
}
.wordsearch-table td.selected {
background-color: var(--primary);
color: white;
}
@keyframes confetti {
0% { transform: translateY(0) rotate(0deg); }
100% { transform: translateY(100vh) rotate(720deg); }
}
</style>
</head>
<body>
<div class="header">
<h1>🎵 Juegos de Taylor Swift - Edición Deluxe Plus 🎵</h1>
<p>¡Demuestra cuánto sabes sobre Taylor!</p>
</div>
<div class="stats">
<div>Nivel: <span id="level">1</span></div>
<div>Puntos: <span id="score">0</span></div>
<div>Racha: <span id="streak">0</span></div>
<div>Mejor Puntuación: <span id="highScore">0</span></div>
</div>
<div class="games-container" id="gamesContainer"></div>
<script>
// Banco de preguntas y respuestas
const questionBank = {
lyrics: [
{ lyric: "Cause baby I'm a _________", answer: "nightmare" },
{ lyric: "Are we out of the _________?", answer: "woods" },
{ lyric: "I stay up too _________ ", answer: "late" },
{ lyric: "Nice to meet you, where you _________", answer: "been" },
{ lyric: "We are never ever ever getting back _________", answer: "together" },
{ lyric: "I knew you were _________ when you walked in", answer: "trouble" },
{ lyric: "Shake it _________, shake it off", answer: "off" },
{ lyric: "Look what you made me _________", answer: "do" },
{ lyric: "Baby just say _________", answer: "yes" },
{ lyric: "I'm feeling twenty-_________ everything", answer: "two" },
{ lyric: "All of the _________ (all of the _________)", answer: "lights" },
{ lyric: "Out of the _________, into the rain", answer: "dark" },
{ lyric: "Meet me at _________ ", answer: "midnight" },
{ lyric: "Karma is my _________ star", answer: "lucky" },
{ lyric: "It's me, hi, I'm the _________", answer: "problem" },
{ lyric: "Draw the _________ wide", answer: "curtains" },
{ lyric: "Paint the town _________ ", answer: "red" },
{ lyric: "Dancing with our hands _________", answer: "tied" },
{ lyric: "I had a marvelous _________", answer: "time" },
{ lyric: "Welcome to New _________ ", answer: "york" }
],
albums: [
{ song: "Love Story", album: "fearless" },
{ song: "Shake It Off", album: "1989" },
{ song: "Cardigan", album: "folklore" },
{ song: "Anti-Hero", album: "midnights" },
{ song: "Cruel Summer", album: "lover" },
{ song: "All Too Well", album: "red" },
{ song: "Enchanted", album: "speak now" },
{ song: "Tim McGraw", album: "taylor swift" },
{ song: "August", album: "folklore" },
{ song: "Karma", album: "midnights" },
{ song: "You Belong With Me", album: "fearless" },
{ song: "Blank Space", album: "1989" },
{ song: "Willow", album: "evermore" },
{ song: "Lavender Haze", album: "midnights" },
{ song: "Lover", album: "lover" }
],
trivia: [
{ question: "¿En qué año nació Taylor Swift?", answer: "1989" },
{ question: "¿Cuál fue su primer álbum de estudio?", answer: "taylor swift" },
{ question: "¿En qué ciudad nació Taylor?", answer: "reading" },
{ question: "¿Cuál es el nombre de su gato blanco?", answer: "benjamin button" },
{ question: "¿Qué número considera Taylor su favorito?", answer: "13" },
{ question: "¿En qué año lanzó '1989'?", answer: "2014" },
{ question: "¿Qué instrumento tocaba Taylor en sus inicios?", answer: "guitarra" },
{ question: "¿Cuál fue su primer sencillo número 1 en Billboard Hot 100?", answer: "shake it off" },
{ question: "¿En qué estado creció Taylor?", answer: "pennsylvania" },
{ question: "¿Cuántos álbumes ha regrabado hasta 2024?", answer: "4" }
],
memoryPairs: [
"1989", "Red", "Fearless", "Speak Now",
"Folklore", "Evermore", "Midnights", "Lover",
"Reputation", "Taylor Swift"
]
};
// Estado del juego
let gameState = {
level: 1,
score: 0,
streak: 0,
highScore: parseInt(localStorage.getItem('taylorHighScore')) || 0,
usedQuestions: {
lyrics: [],
albums: [],
trivia: []
},
memoryGame: {
flippedCards: [],
matchedPairs: 0
}
};
// Funciones auxiliares
function getRandomItem(array) {
return array[Math.floor(Math.random() * array.length)];
}
function createConfetti() {
for(let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * window.innerWidth + 'px';
confetti.style.backgroundColor = ['#ff8fab', '#ffc2d1', '#ffb3c6', '#ff69b4'][Math.floor(Math.random() * 4)];
confetti.style.animationDuration = (Math.random() * 3 + 2) + 's';
document.body.appendChild(confetti);
setTimeout(() => confetti.remove(), 5000);
}
}
function updateStats() {
document.getElementById('level').textContent = gameState.level;
document.getElementById('score').textContent = gameState.score;
document.getElementById('streak').textContent = gameState.streak;
document.getElementById('highScore').textContent = gameState.highScore;
}
function createWordSearchGame() {
const words = ["SWIFT", "LOVE", "FOLKLORE", "REPUTATION"];
const wordSearchGrid = [
['S', 'W', 'I', 'F', 'T', 'X'],
['L', 'O', 'V', 'E', 'R', 'H'],
['F', 'O', 'L', 'K', 'L', 'O'],
['R', 'E', 'P', 'U', 'T', 'A']
];
const foundWords = new Set();
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Sopa de Letras</h2>
<p>Encuentra las palabras: ${words.join(', ')}</p>
<table class="wordsearch-table">
${wordSearchGrid.map((row, rowIndex) => `
<tr>${row.map((letter, colIndex) => `<td data-row="${rowIndex}" data-col="${colIndex}" onclick="selectLetter(this)">${letter}</td>`).join('')}</tr>
`).join('')}
</table>
<button class="btn" onclick="checkWordSearch(words, foundWords)">Verificar Palabras</button>
<div id="wordSearchResult" class="result"></div>
`;
return gameCard;
}
let selectedLetters = [];
function selectLetter(cell) {
if (!cell.classList.contains('selected')) {
cell.classList.add('selected');
selectedLetters.push(cell);
}
}
function checkWordSearch(words, foundWords) {
const selectedWord = selectedLetters.map(cell => cell.textContent).join('');
const result = document.getElementById('wordSearchResult');
if (words.includes(selectedWord) && !foundWords.has(selectedWord)) {
foundWords.add(selectedWord);
selectedLetters.forEach(cell => cell.style.backgroundColor = "#ff8fab");
selectedLetters = [];
result.textContent = `¡Encontraste la palabra: ${selectedWord}!`;
result.style.color = "green";
if (foundWords.size === words.length) {
const points = correctAnswer();
result.textContent += ` ¡Completaste el Juego! +${points} puntos 🎉`;
setTimeout(generateNewGames, 1500); // Move to next game
}
} else {
result.textContent = "No es una palabra válida o ya encontrada";
result.style.color = "red";
selectedLetters.forEach(cell => cell.classList.remove('selected'));
selectedLetters = [];
}
}
function createTrueFalseGame() {
const questions = [
{ question: "Taylor Swift tiene un álbum llamado 'Midnights'", correct: true },
{ question: "Taylor nació en California", correct: false }
];
const question = getRandomItem(questions);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Verdadero o Falso</h2>
<p>${question.question}</p>
<button class="btn" onclick="checkTrueFalse(this.parentElement, ${question.correct}, true)">Verdadero</button>
<button class="btn" onclick="checkTrueFalse(this.parentElement, ${question.correct}, false)">Falso</button>
<div class="result"></div>
`;
return gameCard;
}
function checkTrueFalse(parent, correct, answer) {
const result = parent.querySelector('.result');
if (correct === answer) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function createTimedQuizGame() {
const question = getRandomItem([
{ question: "¿Cuál es el álbum más vendido de Taylor Swift?", answer: "1989" },
{ question: "¿Cuál es su segundo álbum de estudio?", answer: "fearless" }
]);
let timeRemaining = 30; // 30 seconds
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Quiz de Tiempo</h2>
<p>${question.question}</p>
<input type="text" id="timedQuizInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTimedQuiz('${question.answer}')">Verificar</button>
<div id="timedQuizResult" class="result"></div>
<div id="timerDisplay">Tiempo: ${timeRemaining} segundos</div>
`;
function updateTimer() {
if (timeRemaining > 0) {
timeRemaining--;
document.getElementById('timerDisplay').textContent = `Tiempo: ${timeRemaining} segundos`;
} else {
clearInterval(timerInterval);
document.getElementById('timedQuizResult').textContent = "¡Tiempo agotado! 😊";
}
}
let timerInterval = setInterval(updateTimer, 1000);
return gameCard;
}
function checkTimedQuiz(answer) {
const input = document.getElementById('timedQuizInput').value.toLowerCase();
const result = document.getElementById('timedQuizResult');
clearInterval(timerInterval); // Clear timer
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Incorrecto! 😞";
result.style.color = "red";
wrongAnswer();
}
}
function correctAnswer() {
const points = 100 * gameState.level;
gameState.score += points;
gameState.streak++;
if (gameState.score > gameState.highScore) {
gameState.highScore = gameState.score;
localStorage.setItem('taylorHighScore', gameState.highScore);
}
if (gameState.streak % 3 === 0) {
gameState.level++;
createConfetti();
setTimeout(generateNewGames, 1500);
}
updateStats();
document.dispatchEvent(new Event('scoreUpdate'));
return points;
}
function wrongAnswer() {
gameState.streak = 0;
updateStats();
}
// Creación de juegos
function createLyricsGame() {
const unusedLyrics = questionBank.lyrics.filter(q => !gameState.usedQuestions.lyrics.includes(q.lyric));
if (unusedLyrics.length === 0) {
gameState.usedQuestions.lyrics = [];
}
const question = getRandomItem(unusedLyrics);
gameState.usedQuestions.lyrics.push(question.lyric);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Completa la Letra</h2>
<p>${question.lyric}</p>
<input type="text" id="lyricsInput" placeholder="Completa la letra">
<button class="btn" onclick="checkLyrics('${question.answer}')">Verificar</button>
<div id="lyricsResult" class="result"></div>
`;
return gameCard;
}
function createAlbumGame() {
const unusedAlbums = questionBank.albums.filter(q => !gameState.usedQuestions.albums.includes(q.song));
if (unusedAlbums.length === 0) {
gameState.usedQuestions.albums = [];
}
const question = getRandomItem(unusedAlbums);
gameState.usedQuestions.albums.push(question.song);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>¿De Qué Álbum Es?</h2>
<p>¿En qué álbum aparece "${question.song}"?</p>
<input type="text" id="albumInput" placeholder="Nombre del álbum">
<button class="btn" onclick="checkAlbum('${question.album}')">Verificar</button>
<div id="albumResult" class="result"></div>
`;
return gameCard;
}
function createTriviaGame() {
const unusedTrivia = questionBank.trivia.filter(q => !gameState.usedQuestions.trivia.includes(q.question));
if (unusedTrivia.length === 0) {
gameState.usedQuestions.trivia = [];
}
const question = getRandomItem(unusedTrivia);
gameState.usedQuestions.trivia.push(question.question);
const gameCard = document.createElement('div');
gameCard.className = 'game-card';
gameCard.innerHTML = `
<h2>Trivia Swiftie</h2>
<p>${question.question}</p>
<input type="text" id="triviaInput" placeholder="Tu respuesta">
<button class="btn" onclick="checkTrivia('${question.answer}')">Verificar</button>
<div id="triviaResult" class="result"></div>
`;
return gameCard;
}
function createMemoryGame() {
const gameCard = document.createElement('div');
gameCard.className = 'game-card memory-game';
gameCard.innerHTML = `
<h2>Memoria Taylor</h2>
<div class="memory-grid" id="memoryGrid"></div>
<div id="memoryResult" class="result"></div>
`;
return gameCard;
}
// Funciones de verificación
function checkLyrics(answer) {
const input = document.getElementById('lyricsInput').value.toLowerCase();
const result = document.getElementById('lyricsResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkAlbum(answer) {
const input = document.getElementById('albumInput').value.toLowerCase();
const result = document.getElementById('albumResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
function checkTrivia(answer) {
const input = document.getElementById('triviaInput').value.toLowerCase();
const result = document.getElementById('triviaResult');
if (input === answer.toLowerCase()) {
const points = correctAnswer();
result.textContent = `¡Correcto! +${points} puntos 🎉`;
result.style.color = "green";
} else {
result.textContent = "¡Intenta de nuevo! 😊";
result.style.color = "red";
wrongAnswer();
}
}
// Juego de memoria
function startMemoryGame() {
const grid = document.getElementById('memoryGrid');
if (!grid) return;
// Crear pares de cartas
const pairs = [...questionBank.memoryPairs];
const cards = [...pairs, ...pairs];
cards.sort(() => Math.random() - 0.5);
grid.innerHTML = cards.map((card, index) => `
<div class="memory-card" data-index="${index}" data-value="${card}">
<div class="memory-card-inner">
<div class="memory-card-front">?</div>
<div class="memory-card-back">${card}</div>
</div>
</div>
`).join('');
// Agregar eventos
grid.querySelectorAll('.memory-card').forEach(card => {
card.addEventListener('click', handleMemoryCardClick);
});
}
function handleMemoryCardClick() {
const card = this;
if (
card.classList.contains('flipped') ||
gameState.memoryGame.flippedCards.length >= 2
) return;
card.classList.add('flipped');
gameState.memoryGame.flippedCards.push(card);
if (gameState.memoryGame.flippedCards.length === 2) {
setTimeout(checkMemoryMatch, 1000);
}
}
function checkMemoryMatch() {
const [card1, card2] = gameState.memoryGame.flippedCards;
const match = card1.dataset.value === card2.dataset.value;
if (match) {
gameState.memoryGame.matchedPairs++;
const points = correctAnswer();
document.getElementById('memoryResult').textContent = `¡Par encontrado! +${points} puntos 🎉`;
if (gameState.memoryGame.matchedPairs === questionBank.memoryPairs.length) {
document.getElementById('memoryResult').textContent = "¡Juego completado! 🎉";
setTimeout(generateNewGames, 1500);
}
} else {
card1.classList.remove('flipped');
card2.classList.remove('flipped');
wrongAnswer();
}
gameState.memoryGame.flippedCards = [];
}
// Sistema de guardado
function saveProgress() {
const saveData = {
gameState: gameState,
timestamp: Date.now()
};
localStorage.setItem('taylorGameState', JSON.stringify(saveData));
}
function loadProgress() {
const saved = localStorage.getItem('taylorGameState');
if (saved) {
const saveData = JSON.parse(saved);
if (Date.now() - saveData.timestamp < 24 * 60 * 60 * 1000) { // 1 day
gameState = saveData.gameState;
} else {
localStorage.removeItem('taylorGameState');
}
}
updateStats();
}
// Función mejorada para generar nuevos juegos
function generateNewGames() {
const container = document.getElementById('gamesContainer');
container.innerHTML = '';
// Crear nuevas instancias de los juegos
const games = [
createLyricsGame(),
createAlbumGame(),
createTriviaGame(),
createMemoryGame(),
createWordSearchGame(),
createTrueFalseGame(),
createTimedQuizGame()
];
// Mezclar el orden de los juegos
games.sort(() => Math.random() - 0.5);
// Mostrar solo 4 juegos aleatorios
games.slice(0, 4).forEach(game => container.appendChild(game));
// Inicializar juegos específicos
startMemoryGame();
}
// Sistema de logros
const achievements = {
perfectStreak: { name: "Racha Perfecta", description: "Obtén una racha de 10 respuestas correctas", unlocked: false },
highScore: { name: "Alta Puntuación", description: "Alcanza 5000 puntos", unlocked: false },
masterLevel: { name: "Nivel Maestro", description: "Alcanza el nivel 5", unlocked: false }
};
function checkAchievements() {
if (gameState.streak >= 10 && !achievements.perfectStreak.unlocked) {
unlockAchievement('perfectStreak');
}
if (gameState.score >= 5000 && !achievements.highScore.unlocked) {
unlockAchievement('highScore');
}
if (gameState.level >= 5 && !achievements.masterLevel.unlocked) {
unlockAchievement('masterLevel');
}
}
function unlockAchievement(achievementId) {
achievements[achievementId].unlocked = true;
createConfetti();
alert(`¡Logro Desbloqueado! ${achievements[achievementId].name}\n${achievements[achievementId].description}`);
}
// Inicialización
window.onload = function() {
loadProgress();
generateNewGames();
// Guardar progreso cada 30 segundos
setInterval(saveProgress, 30000);
// Verificar logros cada vez que se actualiza la puntuación
document.addEventListener('scoreUpdate', checkAchievements);
};
</script>
</body>
</html>
Cambios y Mejoras Detalladas:
Sopa de Letras Interactiva: El usuario puede seleccionar letras al hacer clic en ellas. Se verifica si las letras seleccionadas forman cualquiera de las palabras configuradas y se actualiza el progreso del juego en consecuencia.
Refactored TrueFalse Game: Mejora la lógica de eventos y los métodos de manejo para garantizar que las verificaciones de resultado se alineen correctamente con el botón que envía el evento.
Quiz de Tiempo Mejorado: Reorganización del cronómetro para manejar tiempos de manera eficiente y asegurarse de que se detenga al verificar la respuesta.
Botones y Feedbacks Mejorados: Ahora se manejan correctamente los estados visuales de los componentes del juego al verificar las respuestas.
Estos ajustes aseguran que todos los juegos ofrezcan una experiencia de usuario interactiva y dinámica. Ajusta las preguntas y las funcionalidades del juego según lo que desees lograr o expandir en futuras características o niveles de dificultad.