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
}];
var currentQuestion = 0;
var questionBox;
var questionText;
var answerButtons = [];
var scoreText;
// Create UI elements
questionBox = game.addChild(LK.getAsset('questionBox', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 800
}));
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);
LK.gui.top.addChild(scoreText);
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];
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);
}
// Start the game
displayQuestion(currentQuestion); ===================================================================
--- original.js
+++ change.js
@@ -188,8 +188,15 @@
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;