User prompt
132/24 /<--- bu işerat cıkmasın sorularda
User prompt
Medium esay bolmeye işareti cıkarsın Hard çarpma işareti çıksın extreme bölme işareti çıksın
User prompt
İlk 10 tur esay medium çarpma işlemi çıkmasın
User prompt
3 yanlışında olmeyileim bidaha 4. Yanlış yaparsak otelimiz
User prompt
3 tane yanlış yapınca kaybedelim
User prompt
Bug fixed
Code edit (1 edits merged)
Please save this source code
User prompt
Math Challenge Quiz
Initial prompt
20 tane soru yap ilk 5 soru kolay ondan sonra 5 soru orta seviye ondan sonra zor seviye en son 5 deli seviyede matematik soruları olsun aşağıda a şıkkı b şıkkı c şıkkı d şıkkı gerçek cevabı bul
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var AnswerButton = Container.expand(function (optionText, index) { var self = Container.call(this); var buttonGraphics = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); var optionLetter = ['A', 'B', 'C', 'D'][index]; var buttonText = new Text2(optionLetter + ': ' + optionText, { size: 60, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.isCorrect = false; self.optionText = optionText; self.setCorrect = function (correct) { self.isCorrect = correct; }; self.showResult = function (isSelected) { if (isSelected) { if (self.isCorrect) { tween(buttonGraphics, { tint: 0x42f56f }, { duration: 300 }); LK.getSound('correct').play(); } else { tween(buttonGraphics, { tint: 0xf54242 }, { duration: 300 }); LK.getSound('wrong').play(); } } else if (self.isCorrect) { tween(buttonGraphics, { tint: 0x42f56f }, { duration: 300 }); } }; self.reset = function () { tween(buttonGraphics, { tint: 0x4287f5 }, { duration: 300 }); }; self.down = function (x, y, obj) { tween(buttonGraphics, { scaleX: 0.95, scaleY: 0.95 }, { duration: 100 }); }; self.up = function (x, y, obj) { tween(buttonGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100 }); // Handle selection in the game class if (typeof game.onOptionSelected === 'function') { game.onOptionSelected(self); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xf0f0f0 }); /**** * Game Code ****/ // Game configuration var currentQuestion = 0; var totalQuestions = 20; var questions = []; var answerButtons = []; var questionText = null; var difficultyText = null; var progressText = null; var canAnswer = true; var difficultyLevels = ["Easy", "Medium", "Difficult", "Extreme"]; var currentDifficulty = 0; // Generate questions of increasing difficulty function generateQuestions() { questions = []; // Easy questions (1-5) for (var i = 0; i < 5; i++) { var num1 = Math.floor(Math.random() * 10) + 1; var num2 = Math.floor(Math.random() * 10) + 1; var operation = ['+', '-', '*'][Math.floor(Math.random() * 3)]; var correctAnswer = calculateAnswer(num1, num2, operation); questions.push({ question: "".concat(num1, " ").concat(operation, " ").concat(num2, " = ?"), options: generateOptions(correctAnswer, 20), correctAnswer: correctAnswer, difficulty: 0 }); } // Medium questions (6-10) for (var i = 0; i < 5; i++) { var num1 = Math.floor(Math.random() * 20) + 10; var num2 = Math.floor(Math.random() * 20) + 10; var operation = ['+', '-', '*', '/'][Math.floor(Math.random() * 4)]; if (operation === '/' && num1 % num2 !== 0) { // Make sure division results in an integer num1 = num2 * (Math.floor(Math.random() * 10) + 1); } var correctAnswer = calculateAnswer(num1, num2, operation); questions.push({ question: "".concat(num1, " ").concat(operation, " ").concat(num2, " = ?"), options: generateOptions(correctAnswer, 50), correctAnswer: correctAnswer, difficulty: 1 }); } // Difficult questions (11-15) for (var i = 0; i < 5; i++) { var num1 = Math.floor(Math.random() * 50) + 20; var num2 = Math.floor(Math.random() * 30) + 10; var num3 = Math.floor(Math.random() * 10) + 1; var operations = ['+', '-', '*']; var op1 = operations[Math.floor(Math.random() * 3)]; var op2 = operations[Math.floor(Math.random() * 3)]; var question = "".concat(num1, " ").concat(op1, " ").concat(num2, " ").concat(op2, " ").concat(num3, " = ?"); var correctAnswer = calculateComplexAnswer(num1, num2, num3, op1, op2); questions.push({ question: question, options: generateOptions(correctAnswer, 100), correctAnswer: correctAnswer, difficulty: 2 }); } // Extreme questions (16-20) for (var i = 0; i < 5; i++) { var question = ""; var correctAnswer = 0; // Choose a random type of extreme question var questionType = Math.floor(Math.random() * 4); switch (questionType) { case 0: // Powers and roots var base = Math.floor(Math.random() * 10) + 2; var exponent = Math.floor(Math.random() * 3) + 2; question = "".concat(base, "^").concat(exponent, " = ?"); correctAnswer = Math.pow(base, exponent); break; case 1: // Percentage problems var whole = Math.floor(Math.random() * 100) + 50; var percentage = Math.floor(Math.random() * 90) + 10; question = "".concat(percentage, "% of ").concat(whole, " = ?"); correctAnswer = percentage / 100 * whole; break; case 2: // Complex equation var a = Math.floor(Math.random() * 10) + 1; var b = Math.floor(Math.random() * 20) + 10; var c = Math.floor(Math.random() * 5) + 1; var d = Math.floor(Math.random() * 10) + 5; question = "(".concat(a, " \xD7 ").concat(b, ") \xF7 (").concat(c, " + ").concat(d, ") = ?"); correctAnswer = a * b / (c + d); correctAnswer = Math.round(correctAnswer * 100) / 100; // Round to 2 decimal places break; case 3: // Sequence problems var start = Math.floor(Math.random() * 5) + 1; var diff = Math.floor(Math.random() * 5) + 2; var sequence = []; for (var j = 0; j < 5; j++) { sequence.push(start + j * diff); } question = "What comes next: ".concat(sequence.join(", "), ", ?"); correctAnswer = start + 5 * diff; break; } questions.push({ question: question, options: generateOptions(correctAnswer, 200), correctAnswer: correctAnswer, difficulty: 3 }); } } function calculateAnswer(num1, num2, operation) { switch (operation) { case '+': return num1 + num2; case '-': return num1 - num2; case '*': return num1 * num2; case '/': return num1 / num2; default: return 0; } } function calculateComplexAnswer(num1, num2, num3, op1, op2) { // Follow order of operations (BODMAS) if ((op1 === '*' || op1 === '/') && (op2 === '+' || op2 === '-')) { // First operation takes precedence var intermediateResult = calculateAnswer(num1, num2, op1); return calculateAnswer(intermediateResult, num3, op2); } else { // Second operation takes precedence var intermediateResult = calculateAnswer(num2, num3, op2); return calculateAnswer(num1, intermediateResult, op1); } } function generateOptions(correctAnswer, range) { var options = [correctAnswer]; // Generate 3 wrong answers while (options.length < 4) { var offset = Math.floor(Math.random() * range) - range / 2; var wrongAnswer = correctAnswer + offset; // Make sure the wrong answer is not the same as any existing options // and is not negative if (offset !== 0 && !options.includes(wrongAnswer) && wrongAnswer >= 0) { options.push(wrongAnswer); } } // Shuffle options for (var i = options.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = options[i]; options[i] = options[j]; options[j] = temp; } // Round decimal answers for better display for (var i = 0; i < options.length; i++) { if (options[i] % 1 !== 0) { options[i] = Math.round(options[i] * 100) / 100; } } return options; } function initializeGame() { // Clear any existing elements while (game.children.length > 0) { game.removeChild(game.children[0]); } // Reset variables currentQuestion = 0; currentDifficulty = 0; answerButtons = []; canAnswer = true; // Generate new questions generateQuestions(); // Create title var titleText = new Text2("Math Challenge Quiz", { size: 100, fill: 0x1A1A1A }); titleText.anchor.set(0.5, 0); titleText.x = 2048 / 2; titleText.y = 100; game.addChild(titleText); // Create difficulty indicator difficultyText = new Text2("Difficulty: ".concat(difficultyLevels[currentDifficulty]), { size: 60, fill: 0x1A1A1A }); difficultyText.anchor.set(0.5, 0); difficultyText.x = 2048 / 2; difficultyText.y = 220; game.addChild(difficultyText); // Create progress indicator progressText = new Text2("Question: ".concat(currentQuestion + 1, "/").concat(totalQuestions), { size: 60, fill: 0x1A1A1A }); progressText.anchor.set(0.5, 0); progressText.x = 2048 / 2; progressText.y = 300; game.addChild(progressText); // Create question text questionText = new Text2("", { size: 80, fill: 0x1A1A1A }); questionText.anchor.set(0.5, 0); questionText.x = 2048 / 2; questionText.y = 450; game.addChild(questionText); // Create answer buttons for (var i = 0; i < 4; i++) { var button = new AnswerButton("", i); // Calculate position var buttonWidth = 600; var buttonHeight = 250; var padding = 100; if (i < 2) { button.x = 2048 / 2 - buttonWidth / 2 - padding / 2 + i * (buttonWidth + padding); button.y = 800; } else { button.x = 2048 / 2 - buttonWidth / 2 - padding / 2 + (i - 2) * (buttonWidth + padding); button.y = 1100; } game.addChild(button); answerButtons.push(button); } // Create score display var scoreText = new Text2("Score: 0", { size: 60, fill: 0x1A1A1A }); scoreText.anchor.set(1, 0); scoreText.x = 2048 - 50; scoreText.y = 50; game.addChild(scoreText); // Display first question displayQuestion(currentQuestion); // Play background music LK.playMusic('bgMusic'); } function displayQuestion(questionIndex) { if (questionIndex >= questions.length) { return; } var question = questions[questionIndex]; // Update difficulty if needed var newDifficulty = question.difficulty; if (newDifficulty !== currentDifficulty) { currentDifficulty = newDifficulty; difficultyText.setText("Difficulty: ".concat(difficultyLevels[currentDifficulty])); LK.getSound('levelUp').play(); } // Update progress progressText.setText("Question: ".concat(questionIndex + 1, "/").concat(totalQuestions)); // Update question text questionText.setText(question.question); // Reset and update all buttons for (var i = 0; i < 4; i++) { answerButtons[i].reset(); answerButtons[i].setCorrect(question.options[i] === question.correctAnswer); var buttonText = new Text2(['A', 'B', 'C', 'D'][i] + ': ' + question.options[i], { size: 60, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); // Remove any existing text while (answerButtons[i].children.length > 1) { answerButtons[i].removeChild(answerButtons[i].children[1]); } answerButtons[i].addChild(buttonText); answerButtons[i].optionText = question.options[i]; } canAnswer = true; } game.onOptionSelected = function (selectedButton) { if (!canAnswer) return; canAnswer = false; // Show results for all buttons for (var i = 0; i < answerButtons.length; i++) { answerButtons[i].showResult(answerButtons[i] === selectedButton); } // Check if the selected answer is correct if (selectedButton.isCorrect) { // Increase score LK.setScore(LK.getScore() + 1); // Move to next question after a delay LK.setTimeout(function () { currentQuestion++; if (currentQuestion >= totalQuestions) { // Game completed LK.showYouWin(); } else { displayQuestion(currentQuestion); } }, 1000); } else { // If wrong answer, show game over after a delay LK.setTimeout(function () { LK.showGameOver(); }, 1500); } }; // On window resize, make sure everything is positioned correctly LK.on('resize', function () { // The engine handles scaling automatically }); // Initialize the game initializeGame();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,404 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var AnswerButton = Container.expand(function (optionText, index) {
+ var self = Container.call(this);
+ var buttonGraphics = self.attachAsset('button', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var optionLetter = ['A', 'B', 'C', 'D'][index];
+ var buttonText = new Text2(optionLetter + ': ' + optionText, {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ self.isCorrect = false;
+ self.optionText = optionText;
+ self.setCorrect = function (correct) {
+ self.isCorrect = correct;
+ };
+ self.showResult = function (isSelected) {
+ if (isSelected) {
+ if (self.isCorrect) {
+ tween(buttonGraphics, {
+ tint: 0x42f56f
+ }, {
+ duration: 300
+ });
+ LK.getSound('correct').play();
+ } else {
+ tween(buttonGraphics, {
+ tint: 0xf54242
+ }, {
+ duration: 300
+ });
+ LK.getSound('wrong').play();
+ }
+ } else if (self.isCorrect) {
+ tween(buttonGraphics, {
+ tint: 0x42f56f
+ }, {
+ duration: 300
+ });
+ }
+ };
+ self.reset = function () {
+ tween(buttonGraphics, {
+ tint: 0x4287f5
+ }, {
+ duration: 300
+ });
+ };
+ self.down = function (x, y, obj) {
+ tween(buttonGraphics, {
+ scaleX: 0.95,
+ scaleY: 0.95
+ }, {
+ duration: 100
+ });
+ };
+ self.up = function (x, y, obj) {
+ tween(buttonGraphics, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100
+ });
+ // Handle selection in the game class
+ if (typeof game.onOptionSelected === 'function') {
+ game.onOptionSelected(self);
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xf0f0f0
+});
+
+/****
+* Game Code
+****/
+// Game configuration
+var currentQuestion = 0;
+var totalQuestions = 20;
+var questions = [];
+var answerButtons = [];
+var questionText = null;
+var difficultyText = null;
+var progressText = null;
+var canAnswer = true;
+var difficultyLevels = ["Easy", "Medium", "Difficult", "Extreme"];
+var currentDifficulty = 0;
+// Generate questions of increasing difficulty
+function generateQuestions() {
+ questions = [];
+ // Easy questions (1-5)
+ for (var i = 0; i < 5; i++) {
+ var num1 = Math.floor(Math.random() * 10) + 1;
+ var num2 = Math.floor(Math.random() * 10) + 1;
+ var operation = ['+', '-', '*'][Math.floor(Math.random() * 3)];
+ var correctAnswer = calculateAnswer(num1, num2, operation);
+ questions.push({
+ question: "".concat(num1, " ").concat(operation, " ").concat(num2, " = ?"),
+ options: generateOptions(correctAnswer, 20),
+ correctAnswer: correctAnswer,
+ difficulty: 0
+ });
+ }
+ // Medium questions (6-10)
+ for (var i = 0; i < 5; i++) {
+ var num1 = Math.floor(Math.random() * 20) + 10;
+ var num2 = Math.floor(Math.random() * 20) + 10;
+ var operation = ['+', '-', '*', '/'][Math.floor(Math.random() * 4)];
+ if (operation === '/' && num1 % num2 !== 0) {
+ // Make sure division results in an integer
+ num1 = num2 * (Math.floor(Math.random() * 10) + 1);
+ }
+ var correctAnswer = calculateAnswer(num1, num2, operation);
+ questions.push({
+ question: "".concat(num1, " ").concat(operation, " ").concat(num2, " = ?"),
+ options: generateOptions(correctAnswer, 50),
+ correctAnswer: correctAnswer,
+ difficulty: 1
+ });
+ }
+ // Difficult questions (11-15)
+ for (var i = 0; i < 5; i++) {
+ var num1 = Math.floor(Math.random() * 50) + 20;
+ var num2 = Math.floor(Math.random() * 30) + 10;
+ var num3 = Math.floor(Math.random() * 10) + 1;
+ var operations = ['+', '-', '*'];
+ var op1 = operations[Math.floor(Math.random() * 3)];
+ var op2 = operations[Math.floor(Math.random() * 3)];
+ var question = "".concat(num1, " ").concat(op1, " ").concat(num2, " ").concat(op2, " ").concat(num3, " = ?");
+ var correctAnswer = calculateComplexAnswer(num1, num2, num3, op1, op2);
+ questions.push({
+ question: question,
+ options: generateOptions(correctAnswer, 100),
+ correctAnswer: correctAnswer,
+ difficulty: 2
+ });
+ }
+ // Extreme questions (16-20)
+ for (var i = 0; i < 5; i++) {
+ var question = "";
+ var correctAnswer = 0;
+ // Choose a random type of extreme question
+ var questionType = Math.floor(Math.random() * 4);
+ switch (questionType) {
+ case 0:
+ // Powers and roots
+ var base = Math.floor(Math.random() * 10) + 2;
+ var exponent = Math.floor(Math.random() * 3) + 2;
+ question = "".concat(base, "^").concat(exponent, " = ?");
+ correctAnswer = Math.pow(base, exponent);
+ break;
+ case 1:
+ // Percentage problems
+ var whole = Math.floor(Math.random() * 100) + 50;
+ var percentage = Math.floor(Math.random() * 90) + 10;
+ question = "".concat(percentage, "% of ").concat(whole, " = ?");
+ correctAnswer = percentage / 100 * whole;
+ break;
+ case 2:
+ // Complex equation
+ var a = Math.floor(Math.random() * 10) + 1;
+ var b = Math.floor(Math.random() * 20) + 10;
+ var c = Math.floor(Math.random() * 5) + 1;
+ var d = Math.floor(Math.random() * 10) + 5;
+ question = "(".concat(a, " \xD7 ").concat(b, ") \xF7 (").concat(c, " + ").concat(d, ") = ?");
+ correctAnswer = a * b / (c + d);
+ correctAnswer = Math.round(correctAnswer * 100) / 100; // Round to 2 decimal places
+ break;
+ case 3:
+ // Sequence problems
+ var start = Math.floor(Math.random() * 5) + 1;
+ var diff = Math.floor(Math.random() * 5) + 2;
+ var sequence = [];
+ for (var j = 0; j < 5; j++) {
+ sequence.push(start + j * diff);
+ }
+ question = "What comes next: ".concat(sequence.join(", "), ", ?");
+ correctAnswer = start + 5 * diff;
+ break;
+ }
+ questions.push({
+ question: question,
+ options: generateOptions(correctAnswer, 200),
+ correctAnswer: correctAnswer,
+ difficulty: 3
+ });
+ }
+}
+function calculateAnswer(num1, num2, operation) {
+ switch (operation) {
+ case '+':
+ return num1 + num2;
+ case '-':
+ return num1 - num2;
+ case '*':
+ return num1 * num2;
+ case '/':
+ return num1 / num2;
+ default:
+ return 0;
+ }
+}
+function calculateComplexAnswer(num1, num2, num3, op1, op2) {
+ // Follow order of operations (BODMAS)
+ if ((op1 === '*' || op1 === '/') && (op2 === '+' || op2 === '-')) {
+ // First operation takes precedence
+ var intermediateResult = calculateAnswer(num1, num2, op1);
+ return calculateAnswer(intermediateResult, num3, op2);
+ } else {
+ // Second operation takes precedence
+ var intermediateResult = calculateAnswer(num2, num3, op2);
+ return calculateAnswer(num1, intermediateResult, op1);
+ }
+}
+function generateOptions(correctAnswer, range) {
+ var options = [correctAnswer];
+ // Generate 3 wrong answers
+ while (options.length < 4) {
+ var offset = Math.floor(Math.random() * range) - range / 2;
+ var wrongAnswer = correctAnswer + offset;
+ // Make sure the wrong answer is not the same as any existing options
+ // and is not negative
+ if (offset !== 0 && !options.includes(wrongAnswer) && wrongAnswer >= 0) {
+ options.push(wrongAnswer);
+ }
+ }
+ // Shuffle options
+ for (var i = options.length - 1; i > 0; i--) {
+ var j = Math.floor(Math.random() * (i + 1));
+ var temp = options[i];
+ options[i] = options[j];
+ options[j] = temp;
+ }
+ // Round decimal answers for better display
+ for (var i = 0; i < options.length; i++) {
+ if (options[i] % 1 !== 0) {
+ options[i] = Math.round(options[i] * 100) / 100;
+ }
+ }
+ return options;
+}
+function initializeGame() {
+ // Clear any existing elements
+ while (game.children.length > 0) {
+ game.removeChild(game.children[0]);
+ }
+ // Reset variables
+ currentQuestion = 0;
+ currentDifficulty = 0;
+ answerButtons = [];
+ canAnswer = true;
+ // Generate new questions
+ generateQuestions();
+ // Create title
+ var titleText = new Text2("Math Challenge Quiz", {
+ size: 100,
+ fill: 0x1A1A1A
+ });
+ titleText.anchor.set(0.5, 0);
+ titleText.x = 2048 / 2;
+ titleText.y = 100;
+ game.addChild(titleText);
+ // Create difficulty indicator
+ difficultyText = new Text2("Difficulty: ".concat(difficultyLevels[currentDifficulty]), {
+ size: 60,
+ fill: 0x1A1A1A
+ });
+ difficultyText.anchor.set(0.5, 0);
+ difficultyText.x = 2048 / 2;
+ difficultyText.y = 220;
+ game.addChild(difficultyText);
+ // Create progress indicator
+ progressText = new Text2("Question: ".concat(currentQuestion + 1, "/").concat(totalQuestions), {
+ size: 60,
+ fill: 0x1A1A1A
+ });
+ progressText.anchor.set(0.5, 0);
+ progressText.x = 2048 / 2;
+ progressText.y = 300;
+ game.addChild(progressText);
+ // Create question text
+ questionText = new Text2("", {
+ size: 80,
+ fill: 0x1A1A1A
+ });
+ questionText.anchor.set(0.5, 0);
+ questionText.x = 2048 / 2;
+ questionText.y = 450;
+ game.addChild(questionText);
+ // Create answer buttons
+ for (var i = 0; i < 4; i++) {
+ var button = new AnswerButton("", i);
+ // Calculate position
+ var buttonWidth = 600;
+ var buttonHeight = 250;
+ var padding = 100;
+ if (i < 2) {
+ button.x = 2048 / 2 - buttonWidth / 2 - padding / 2 + i * (buttonWidth + padding);
+ button.y = 800;
+ } else {
+ button.x = 2048 / 2 - buttonWidth / 2 - padding / 2 + (i - 2) * (buttonWidth + padding);
+ button.y = 1100;
+ }
+ game.addChild(button);
+ answerButtons.push(button);
+ }
+ // Create score display
+ var scoreText = new Text2("Score: 0", {
+ size: 60,
+ fill: 0x1A1A1A
+ });
+ scoreText.anchor.set(1, 0);
+ scoreText.x = 2048 - 50;
+ scoreText.y = 50;
+ game.addChild(scoreText);
+ // Display first question
+ displayQuestion(currentQuestion);
+ // Play background music
+ LK.playMusic('bgMusic');
+}
+function displayQuestion(questionIndex) {
+ if (questionIndex >= questions.length) {
+ return;
+ }
+ var question = questions[questionIndex];
+ // Update difficulty if needed
+ var newDifficulty = question.difficulty;
+ if (newDifficulty !== currentDifficulty) {
+ currentDifficulty = newDifficulty;
+ difficultyText.setText("Difficulty: ".concat(difficultyLevels[currentDifficulty]));
+ LK.getSound('levelUp').play();
+ }
+ // Update progress
+ progressText.setText("Question: ".concat(questionIndex + 1, "/").concat(totalQuestions));
+ // Update question text
+ questionText.setText(question.question);
+ // Reset and update all buttons
+ for (var i = 0; i < 4; i++) {
+ answerButtons[i].reset();
+ answerButtons[i].setCorrect(question.options[i] === question.correctAnswer);
+ var buttonText = new Text2(['A', 'B', 'C', 'D'][i] + ': ' + question.options[i], {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ // Remove any existing text
+ while (answerButtons[i].children.length > 1) {
+ answerButtons[i].removeChild(answerButtons[i].children[1]);
+ }
+ answerButtons[i].addChild(buttonText);
+ answerButtons[i].optionText = question.options[i];
+ }
+ canAnswer = true;
+}
+game.onOptionSelected = function (selectedButton) {
+ if (!canAnswer) return;
+ canAnswer = false;
+ // Show results for all buttons
+ for (var i = 0; i < answerButtons.length; i++) {
+ answerButtons[i].showResult(answerButtons[i] === selectedButton);
+ }
+ // Check if the selected answer is correct
+ if (selectedButton.isCorrect) {
+ // Increase score
+ LK.setScore(LK.getScore() + 1);
+ // Move to next question after a delay
+ LK.setTimeout(function () {
+ currentQuestion++;
+ if (currentQuestion >= totalQuestions) {
+ // Game completed
+ LK.showYouWin();
+ } else {
+ displayQuestion(currentQuestion);
+ }
+ }, 1000);
+ } else {
+ // If wrong answer, show game over after a delay
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 1500);
+ }
+};
+// On window resize, make sure everything is positioned correctly
+LK.on('resize', function () {
+ // The engine handles scaling automatically
+});
+// Initialize the game
+initializeGame();
\ No newline at end of file