User prompt
Ahora agrega nuevas preguntas de categoría videojuegos y que son 20 preguntas nuevas. Para identificar que son preguntas nuevas, arriba va aparecer una palabra "nueva" qué significara qué es una nueva pregunta.
User prompt
Ahora agrega la canción que esta en la carpeta "adivina" que solo se usa en toda la partida cuando estés jugando la trivia.
User prompt
Ahora haz un menú con el nombre del juego.
User prompt
Entonces haz lo que te dije
User prompt
Que las preguntas estarán en posiciones aleatorios me refiero a que se cambiará de posición de preguntas.
Code edit (1 edits merged)
Please save this source code
User prompt
Video Game Trivia Challenge
Initial prompt
Quiero que hagas un juego de trivia de categoría "videojuegos". Habrá solo 4 opciones para elegir, si fallas, pierdes pero si lo haces bien, vamos a la otra pregunta.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var AnswerButton = Container.expand(function (answerText, isCorrect, questionIndex) {
var self = Container.call(this);
self.isCorrect = isCorrect;
self.answered = false;
self.questionIndex = questionIndex;
var buttonGraphics = self.attachAsset('answerButton', {
anchorX: 0.5,
anchorY: 0.5
});
var answerTxt = new Text2(answerText, {
size: 60,
fill: 0xFFFFFF,
wordWrap: true,
wordWrapWidth: 800
});
answerTxt.anchor.set(0.5, 0.5);
self.addChild(answerTxt);
self.down = function (x, y, obj) {
if (self.answered || currentQuestion !== self.questionIndex) return;
self.answered = true;
if (self.isCorrect) {
self.removeChild(buttonGraphics);
var correctGraphics = self.attachAsset('correctButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChildAt(correctGraphics, 0);
LK.getSound('correct').play();
LK.setScore(LK.getScore() + 1);
scoreText.setText('Score: ' + LK.getScore());
LK.setTimeout(function () {
nextQuestion();
}, 1500);
} else {
self.removeChild(buttonGraphics);
var wrongGraphics = self.attachAsset('wrongButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChildAt(wrongGraphics, 0);
LK.getSound('wrong').play();
LK.setTimeout(function () {
LK.showGameOver();
}, 2000);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a252f
});
/****
* Game Code
****/
// Game variables
var questions = [{
question: "Who is the main character in the Legend of Zelda series?",
answers: ["Zelda", "Link", "Ganon", "Epona"],
correct: 1
}, {
question: "Which company created the Super Mario franchise?",
answers: ["Sega", "Nintendo", "Sony", "Microsoft"],
correct: 1
}, {
question: "What is the name of Sonic's sidekick?",
answers: ["Knuckles", "Shadow", "Tails", "Amy"],
correct: 2
}, {
question: "In which year was the original Pac-Man released?",
answers: ["1978", "1980", "1982", "1984"],
correct: 1
}, {
question: "What is the currency called in the Mario games?",
answers: ["Rings", "Coins", "Stars", "Gems"],
correct: 1
}, {
question: "Which game series features Master Chief?",
answers: ["Call of Duty", "Gears of War", "Halo", "Destiny"],
correct: 2
}, {
question: "What does RPG stand for in gaming?",
answers: ["Real Player Game", "Role Playing Game", "Rapid Play Gaming", "Random Player Generator"],
correct: 1
}, {
question: "Which console was known as 'Project Revolution' during development?",
answers: ["PlayStation 3", "Xbox 360", "Nintendo Wii", "Nintendo Switch"],
correct: 2
}, {
question: "In Pokémon, what type is Pikachu?",
answers: ["Fire", "Water", "Electric", "Normal"],
correct: 2
}, {
question: "Which company developed Minecraft?",
answers: ["Microsoft", "Mojang", "Epic Games", "Valve"],
correct: 1
}, {
question: "What is the highest selling video game of all time?",
answers: ["Tetris", "Minecraft", "Grand Theft Auto V", "Super Mario Bros."],
correct: 1
}, {
question: "In Street Fighter, what country is Ryu from?",
answers: ["China", "Japan", "Korea", "Thailand"],
correct: 1
}, {
question: "Which game introduced the Battle Royale genre to mainstream gaming?",
answers: ["PUBG", "Fortnite", "Apex Legends", "H1Z1"],
correct: 0
}, {
question: "What is the name of the princess in the Super Mario series?",
answers: ["Princess Daisy", "Princess Rosalina", "Princess Peach", "Princess Zelda"],
correct: 2
}, {
question: "Which gaming console was the first to use CD-ROMs?",
answers: ["Sega Saturn", "PlayStation", "TurboGrafx-CD", "3DO"],
correct: 2
}, {
question: "NUEVA - What is the name of the main antagonist in The Legend of Zelda series?",
answers: ["Bowser", "Ganondorf", "Sephiroth", "Ridley"],
correct: 1
}, {
question: "NUEVA - Which video game franchise features the character Kratos?",
answers: ["God of War", "Devil May Cry", "Mortal Kombat", "Tekken"],
correct: 0
}, {
question: "NUEVA - In which game would you find the city of Rapture?",
answers: ["Fallout", "BioShock", "Dead Space", "System Shock"],
correct: 1
}, {
question: "NUEVA - What is the name of Mario's dinosaur companion?",
answers: ["Bowser Jr.", "Koopa", "Yoshi", "Toad"],
correct: 2
}, {
question: "NUEVA - Which company developed the Dark Souls series?",
answers: ["FromSoftware", "Capcom", "Square Enix", "Bandai Namco"],
correct: 0
}, {
question: "NUEVA - In Overwatch, what type of hero is Mercy?",
answers: ["Tank", "Damage", "Support", "Defense"],
correct: 2
}, {
question: "NUEVA - What is the maximum level cap in most Pokémon games?",
answers: ["50", "99", "100", "255"],
correct: 2
}, {
question: "NUEVA - Which game features the character Gordon Freeman?",
answers: ["Half-Life", "Portal", "Doom", "Quake"],
correct: 0
}, {
question: "NUEVA - What does FPS stand for in gaming?",
answers: ["First Person Shooter", "Frames Per Second", "Final Player Score", "Fast Paced Strategy"],
correct: 0
}, {
question: "NUEVA - Which Nintendo character is known for exploring space?",
answers: ["Link", "Mario", "Samus", "Donkey Kong"],
correct: 2
}, {
question: "NUEVA - In which game series would you find the character Solid Snake?",
answers: ["Splinter Cell", "Metal Gear", "Hitman", "Assassin's Creed"],
correct: 1
}, {
question: "NUEVA - What is the name of the world in The Elder Scrolls V: Skyrim?",
answers: ["Tamriel", "Skyrim", "Nirn", "Cyrodiil"],
correct: 1
}, {
question: "NUEVA - Which fighting game series features Ryu and Chun-Li?",
answers: ["Tekken", "Mortal Kombat", "Street Fighter", "King of Fighters"],
correct: 2
}, {
question: "NUEVA - What color is Sonic the Hedgehog?",
answers: ["Red", "Blue", "Green", "Yellow"],
correct: 1
}, {
question: "NUEVA - Which game popularized the 'battle royale' concept before PUBG?",
answers: ["Minecraft Hunger Games", "DayZ", "Arma 2", "H1Z1"],
correct: 0
}, {
question: "NUEVA - In World of Warcraft, what are the two main factions?",
answers: ["Empire vs Rebels", "Alliance vs Horde", "Order vs Chaos", "Light vs Dark"],
correct: 1
}, {
question: "NUEVA - Which game features the character Lara Croft?",
answers: ["Uncharted", "Tomb Raider", "Indiana Jones", "Assassin's Creed"],
correct: 1
}, {
question: "NUEVA - What is the name of the currency in Fortnite?",
answers: ["V-Bucks", "Gold Coins", "Battle Points", "Storm Tokens"],
correct: 0
}, {
question: "NUEVA - Which game series is known for the phrase 'The cake is a lie'?",
answers: ["Half-Life", "Portal", "Left 4 Dead", "Team Fortress"],
correct: 1
}, {
question: "NUEVA - In Minecraft, what material do you need to make a Nether Portal?",
answers: ["Diamond", "Gold", "Obsidian", "Iron"],
correct: 2
}];
var currentQuestion = 0;
var questionBox;
var questionText;
var answerButtons = [];
var scoreText;
var gameStarted = false;
var titleText;
var subtitleText;
var startButton;
var newQuestionIndicator;
// Create title screen elements
titleText = new Text2('VIDEO GAME TRIVIA\nCHALLENGE', {
size: 100,
fill: 0xFFFFFF,
align: 'center'
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 800;
game.addChild(titleText);
subtitleText = new Text2('Test your gaming knowledge!\nAnswer correctly to advance, one wrong answer ends the game.', {
size: 60,
fill: 0x3498db,
align: 'center',
wordWrap: true,
wordWrapWidth: 1600
});
subtitleText.anchor.set(0.5, 0.5);
subtitleText.x = 1024;
subtitleText.y = 1200;
game.addChild(subtitleText);
startButton = game.addChild(LK.getAsset('answerButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1600
}));
var startButtonText = new Text2('TAP TO START', {
size: 70,
fill: 0xFFFFFF
});
startButtonText.anchor.set(0.5, 0.5);
startButton.addChild(startButtonText);
// Create game UI elements (initially hidden)
questionBox = game.addChild(LK.getAsset('questionBox', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 800
}));
questionBox.visible = false;
questionText = new Text2('', {
size: 70,
fill: 0xFFFFFF,
wordWrap: true,
wordWrapWidth: 1700
});
questionText.anchor.set(0.5, 0.5);
questionBox.addChild(questionText);
scoreText = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
scoreText.visible = false;
LK.gui.top.addChild(scoreText);
newQuestionIndicator = new Text2('', {
size: 50,
fill: 0xff6b35,
align: 'center'
});
newQuestionIndicator.anchor.set(0.5, 1);
newQuestionIndicator.x = 1024;
newQuestionIndicator.y = 600;
newQuestionIndicator.visible = false;
game.addChild(newQuestionIndicator);
function displayQuestion(index) {
if (index >= questions.length) {
// Player has answered all questions - show win
LK.setTimeout(function () {
LK.showYouWin();
}, 500);
return;
}
var q = questions[index];
// Check if this is a new question and show indicator
if (q.question.indexOf('NUEVA') === 0) {
newQuestionIndicator.setText('NUEVA');
newQuestionIndicator.visible = true;
// Remove "NUEVA - " from the question text
questionText.setText(q.question.substring(7));
} else {
newQuestionIndicator.visible = false;
questionText.setText(q.question);
}
// Clear previous answer buttons
for (var i = 0; i < answerButtons.length; i++) {
answerButtons[i].destroy();
}
answerButtons = [];
// Create new answer buttons
var buttonPositions = [{
x: 512,
y: 1400
},
// Top left
{
x: 1536,
y: 1400
},
// Top right
{
x: 512,
y: 1600
},
// Bottom left
{
x: 1536,
y: 1600
} // Bottom right
];
// Shuffle button positions to randomize answer placement
for (var i = buttonPositions.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = buttonPositions[i];
buttonPositions[i] = buttonPositions[j];
buttonPositions[j] = temp;
}
for (var i = 0; i < q.answers.length; i++) {
var isCorrect = i === q.correct;
var button = new AnswerButton(q.answers[i], isCorrect, index);
button.x = buttonPositions[i].x;
button.y = buttonPositions[i].y;
answerButtons.push(button);
game.addChild(button);
}
}
function nextQuestion() {
currentQuestion++;
displayQuestion(currentQuestion);
}
function startGame() {
if (gameStarted) return;
gameStarted = true;
// Hide menu elements
titleText.visible = false;
subtitleText.visible = false;
startButton.visible = false;
// Show game elements
questionBox.visible = true;
scoreText.visible = true;
newQuestionIndicator.visible = false;
// Shuffle questions array to randomize question order
for (var i = questions.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = questions[i];
questions[i] = questions[j];
questions[j] = temp;
}
// Start the game
displayQuestion(currentQuestion);
}
// Handle start button click
startButton.down = function (x, y, obj) {
startGame();
};
// Play background music when game starts
LK.playMusic('Adivina'); ===================================================================
--- original.js
+++ change.js
@@ -125,8 +125,88 @@
}, {
question: "Which gaming console was the first to use CD-ROMs?",
answers: ["Sega Saturn", "PlayStation", "TurboGrafx-CD", "3DO"],
correct: 2
+}, {
+ question: "NUEVA - What is the name of the main antagonist in The Legend of Zelda series?",
+ answers: ["Bowser", "Ganondorf", "Sephiroth", "Ridley"],
+ correct: 1
+}, {
+ question: "NUEVA - Which video game franchise features the character Kratos?",
+ answers: ["God of War", "Devil May Cry", "Mortal Kombat", "Tekken"],
+ correct: 0
+}, {
+ question: "NUEVA - In which game would you find the city of Rapture?",
+ answers: ["Fallout", "BioShock", "Dead Space", "System Shock"],
+ correct: 1
+}, {
+ question: "NUEVA - What is the name of Mario's dinosaur companion?",
+ answers: ["Bowser Jr.", "Koopa", "Yoshi", "Toad"],
+ correct: 2
+}, {
+ question: "NUEVA - Which company developed the Dark Souls series?",
+ answers: ["FromSoftware", "Capcom", "Square Enix", "Bandai Namco"],
+ correct: 0
+}, {
+ question: "NUEVA - In Overwatch, what type of hero is Mercy?",
+ answers: ["Tank", "Damage", "Support", "Defense"],
+ correct: 2
+}, {
+ question: "NUEVA - What is the maximum level cap in most Pokémon games?",
+ answers: ["50", "99", "100", "255"],
+ correct: 2
+}, {
+ question: "NUEVA - Which game features the character Gordon Freeman?",
+ answers: ["Half-Life", "Portal", "Doom", "Quake"],
+ correct: 0
+}, {
+ question: "NUEVA - What does FPS stand for in gaming?",
+ answers: ["First Person Shooter", "Frames Per Second", "Final Player Score", "Fast Paced Strategy"],
+ correct: 0
+}, {
+ question: "NUEVA - Which Nintendo character is known for exploring space?",
+ answers: ["Link", "Mario", "Samus", "Donkey Kong"],
+ correct: 2
+}, {
+ question: "NUEVA - In which game series would you find the character Solid Snake?",
+ answers: ["Splinter Cell", "Metal Gear", "Hitman", "Assassin's Creed"],
+ correct: 1
+}, {
+ question: "NUEVA - What is the name of the world in The Elder Scrolls V: Skyrim?",
+ answers: ["Tamriel", "Skyrim", "Nirn", "Cyrodiil"],
+ correct: 1
+}, {
+ question: "NUEVA - Which fighting game series features Ryu and Chun-Li?",
+ answers: ["Tekken", "Mortal Kombat", "Street Fighter", "King of Fighters"],
+ correct: 2
+}, {
+ question: "NUEVA - What color is Sonic the Hedgehog?",
+ answers: ["Red", "Blue", "Green", "Yellow"],
+ correct: 1
+}, {
+ question: "NUEVA - Which game popularized the 'battle royale' concept before PUBG?",
+ answers: ["Minecraft Hunger Games", "DayZ", "Arma 2", "H1Z1"],
+ correct: 0
+}, {
+ question: "NUEVA - In World of Warcraft, what are the two main factions?",
+ answers: ["Empire vs Rebels", "Alliance vs Horde", "Order vs Chaos", "Light vs Dark"],
+ correct: 1
+}, {
+ question: "NUEVA - Which game features the character Lara Croft?",
+ answers: ["Uncharted", "Tomb Raider", "Indiana Jones", "Assassin's Creed"],
+ correct: 1
+}, {
+ question: "NUEVA - What is the name of the currency in Fortnite?",
+ answers: ["V-Bucks", "Gold Coins", "Battle Points", "Storm Tokens"],
+ correct: 0
+}, {
+ question: "NUEVA - Which game series is known for the phrase 'The cake is a lie'?",
+ answers: ["Half-Life", "Portal", "Left 4 Dead", "Team Fortress"],
+ correct: 1
+}, {
+ question: "NUEVA - In Minecraft, what material do you need to make a Nether Portal?",
+ answers: ["Diamond", "Gold", "Obsidian", "Iron"],
+ correct: 2
}];
var currentQuestion = 0;
var questionBox;
var questionText;
@@ -135,8 +215,9 @@
var gameStarted = false;
var titleText;
var subtitleText;
var startButton;
+var newQuestionIndicator;
// Create title screen elements
titleText = new Text2('VIDEO GAME TRIVIA\nCHALLENGE', {
size: 100,
fill: 0xFFFFFF,
@@ -191,8 +272,18 @@
});
scoreText.anchor.set(0.5, 0);
scoreText.visible = false;
LK.gui.top.addChild(scoreText);
+newQuestionIndicator = new Text2('', {
+ size: 50,
+ fill: 0xff6b35,
+ align: 'center'
+});
+newQuestionIndicator.anchor.set(0.5, 1);
+newQuestionIndicator.x = 1024;
+newQuestionIndicator.y = 600;
+newQuestionIndicator.visible = false;
+game.addChild(newQuestionIndicator);
function displayQuestion(index) {
if (index >= questions.length) {
// Player has answered all questions - show win
LK.setTimeout(function () {
@@ -200,9 +291,18 @@
}, 500);
return;
}
var q = questions[index];
- questionText.setText(q.question);
+ // Check if this is a new question and show indicator
+ if (q.question.indexOf('NUEVA') === 0) {
+ newQuestionIndicator.setText('NUEVA');
+ newQuestionIndicator.visible = true;
+ // Remove "NUEVA - " from the question text
+ questionText.setText(q.question.substring(7));
+ } else {
+ newQuestionIndicator.visible = false;
+ questionText.setText(q.question);
+ }
// Clear previous answer buttons
for (var i = 0; i < answerButtons.length; i++) {
answerButtons[i].destroy();
}
@@ -257,8 +357,9 @@
startButton.visible = false;
// Show game elements
questionBox.visible = true;
scoreText.visible = true;
+ newQuestionIndicator.visible = false;
// Shuffle questions array to randomize question order
for (var i = questions.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = questions[i];