/**** * Classes ****/ // Class for the Answer Option var AnswerOption = Container.expand(function () { var self = Container.call(this); var optionText = new Text2('', { size: 100, fill: "#ffffff" }); optionText.anchor.set(0.5, 0.5); self.addChild(optionText); self.setText = function (text) { optionText.setText(text); }; self.down = function (x, y, obj) { if (self.correct) { LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); LK.effects.flashObject(self, 0x00ff00, 500); nextQuestion(); } else { LK.effects.flashObject(self, 0xff0000, 500); } }; return self; }); //<Assets used in the game will automatically appear here> // Class for the Question var Question = Container.expand(function () { var self = Container.call(this); var questionText = new Text2('', { size: 120, fill: "#ffffff" }); questionText.anchor.set(0.5, 0.5); self.addChild(questionText); self.setText = function (text) { questionText.setText(text); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var questions = [{ question: "What is 2 + 2?", options: ["3", "4", "5"], correct: 1 }, { question: "What is the capital of France?", options: ["Berlin", "Paris", "Rome"], correct: 1 }, { question: "What is the color of the sky?", options: ["Blue", "Green", "Red"], correct: 0 }, { question: "What is the largest planet in our solar system?", options: ["Earth", "Jupiter", "Mars"], correct: 1 }, { question: "What is the boiling point of water?", options: ["100°C", "0°C", "50°C"], correct: 0 }, { question: "What is the chemical symbol for gold?", options: ["Au", "Ag", "Pb"], correct: 0 }, { question: "What is the capital of Japan?", options: ["Seoul", "Tokyo", "Beijing"], correct: 1 }, { question: "What is the square root of 64?", options: ["6", "8", "10"], correct: 1 }, { question: "What is the largest mammal?", options: ["Elephant", "Blue Whale", "Giraffe"], correct: 1 }, { question: "What is the smallest prime number?", options: ["1", "2", "3"], correct: 1 }, { question: "What is the capital of Italy?", options: ["Venice", "Rome", "Milan"], correct: 1 }, { question: "What is the speed of light?", options: ["300,000 km/s", "150,000 km/s", "450,000 km/s"], correct: 0 }, { question: "What is the chemical symbol for water?", options: ["H2O", "O2", "CO2"], correct: 0 }, { question: "What is the capital of Canada?", options: ["Toronto", "Ottawa", "Vancouver"], correct: 1 }, { question: "What is the largest ocean on Earth?", options: ["Atlantic", "Indian", "Pacific"], correct: 2 }, { question: "What is the capital of Australia?", options: ["Sydney", "Canberra", "Melbourne"], correct: 1 }, { question: "What is the freezing point of water?", options: ["0°C", "100°C", "50°C"], correct: 0 }, { question: "What is the chemical symbol for iron?", options: ["Fe", "Ir", "In"], correct: 0 }, { question: "What is the capital of Germany?", options: ["Munich", "Berlin", "Frankfurt"], correct: 1 }, { question: "What is the largest continent?", options: ["Africa", "Asia", "Europe"], correct: 1 }, { question: "What is the capital of Russia?", options: ["Moscow", "St. Petersburg", "Kiev"], correct: 0 }, { question: "What is the smallest planet in our solar system?", options: ["Mercury", "Mars", "Venus"], correct: 0 }, { question: "What is the capital of India?", options: ["Mumbai", "New Delhi", "Bangalore"], correct: 1 }, { question: "What is the chemical symbol for sodium?", options: ["Na", "S", "N"], correct: 0 }, { question: "What is the capital of Brazil?", options: ["Rio de Janeiro", "Brasília", "São Paulo"], correct: 1 }, { question: "What is the largest desert in the world?", options: ["Sahara", "Gobi", "Kalahari"], correct: 0 }, { question: "What is the capital of Egypt?", options: ["Cairo", "Alexandria", "Giza"], correct: 0 }, { question: "What is the chemical symbol for potassium?", options: ["K", "P", "Pt"], correct: 0 }, { question: "What is the capital of Mexico?", options: ["Guadalajara", "Mexico City", "Monterrey"], correct: 1 }, { question: "What is the largest river in the world?", options: ["Amazon", "Nile", "Yangtze"], correct: 0 }]; var currentQuestionIndex = 0; var questionDisplay = new Question(); questionDisplay.x = 2048 / 2; questionDisplay.y = 500; game.addChild(questionDisplay); var answerOptions = []; for (var i = 0; i < 3; i++) { var option = new AnswerOption(); option.x = 2048 / 2; option.y = 1000 + i * 200; game.addChild(option); answerOptions.push(option); } var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); function nextQuestion() { if (currentQuestionIndex >= questions.length) { LK.showGameOver(); return; } var currentQuestion = questions[currentQuestionIndex]; questionDisplay.setText(currentQuestion.question); for (var i = 0; i < answerOptions.length; i++) { answerOptions[i].setText(currentQuestion.options[i]); answerOptions[i].correct = i === currentQuestion.correct; } currentQuestionIndex++; } nextQuestion(); game.update = function () { // Game update logic if needed };
===================================================================
--- original.js
+++ change.js
@@ -4,9 +4,9 @@
// Class for the Answer Option
var AnswerOption = Container.expand(function () {
var self = Container.call(this);
var optionText = new Text2('', {
- size: 80,
+ size: 100,
fill: "#ffffff"
});
optionText.anchor.set(0.5, 0.5);
self.addChild(optionText);
@@ -29,9 +29,9 @@
// Class for the Question
var Question = Container.expand(function () {
var self = Container.call(this);
var questionText = new Text2('', {
- size: 100,
+ size: 120,
fill: "#ffffff"
});
questionText.anchor.set(0.5, 0.5);
self.addChild(questionText);