User prompt
So under the icon say the name of the category
User prompt
So next to the question there will be an icon that represents what the question is about: nature, science, geography, and the rest.
User prompt
Proceed to do what you consider a good and great update to the game βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
So you have three lives displayed in the top corner and every time you fail you lose one and when you lose them all you lose
Code edit (1 edits merged)
Please save this source code
User prompt
Quiz Quest: True or False
Initial prompt
Create a game where you have to choose two options, only one is good, the other makes you lose. Questions like: What does photosynthesis do? And there are two answers: pig or tree.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var AnswerButton = Container.expand(function () { var self = Container.call(this); self.isCorrect = false; self.answered = false; // Button background self.buttonBg = self.attachAsset('answerButton', { anchorX: 0.5, anchorY: 0.5 }); // Answer text self.answerText = new Text2('', { size: 60, fill: 0xFFFFFF, wordWrap: true, wordWrapWidth: 750 }); self.answerText.anchor.set(0.5, 0.5); self.addChild(self.answerText); self.setAnswer = function (text, correct) { self.answerText.setText(text); self.isCorrect = correct; }; self.showCorrect = function () { self.removeChild(self.buttonBg); self.buttonBg = self.attachAsset('correctButton', { anchorX: 0.5, anchorY: 0.5 }); self.addChildAt(self.buttonBg, 0); }; self.showWrong = function () { self.removeChild(self.buttonBg); self.buttonBg = self.attachAsset('wrongButton', { anchorX: 0.5, anchorY: 0.5 }); self.addChildAt(self.buttonBg, 0); }; self.down = function (x, y, obj) { if (self.answered) return; self.answered = true; answered = true; // Add press animation tween(self, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.bounceOut }); } }); if (self.isCorrect) { // Correct answer self.showCorrect(); LK.effects.flashObject(self, 0x27ae60, 500); LK.getSound('correct').play(); LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // Add score celebration animation tween(scoreTxt, { scaleX: 1.3, scaleY: 1.3 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(scoreTxt, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.easeOut }); } }); // Show next question after delay LK.setTimeout(function () { showNextQuestion(); }, 1000); } else { // Wrong answer self.showWrong(); LK.effects.flashObject(self, 0xe74c3c, 500); LK.effects.flashScreen(0xe74c3c, 1000); LK.getSound('wrong').play(); // Show correct answer if (answerButton1.isCorrect) { answerButton1.showCorrect(); } else { answerButton2.showCorrect(); } // Lose a life lives--; livesTxt.setText('Lives: ' + lives); // Add life loss animation tween(livesTxt, { scaleX: 1.2, scaleY: 1.2, tint: 0xff0000 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(livesTxt, { scaleX: 1, scaleY: 1, tint: 0xffffff }, { duration: 400, easing: tween.easeOut }); } }); // Check if game over or continue LK.setTimeout(function () { if (lives <= 0) { LK.showGameOver(); } else { showNextQuestion(); } }, 2000); } }; return self; }); var Question = Container.expand(function () { var self = Container.call(this); // Question background var questionBg = self.attachAsset('questionBox', { anchorX: 0.5, anchorY: 0.5 }); // Category icon self.categoryIcon = null; // Category text self.categoryText = null; // Question text self.questionText = new Text2('', { size: 80, fill: 0xFFFFFF, wordWrap: true, wordWrapWidth: 1500 }); self.questionText.anchor.set(0.5, 0.5); self.questionText.x = 100; // Offset to make room for icon self.addChild(self.questionText); self.setQuestion = function (text, category) { self.questionText.setText(text); // Remove existing category icon if any if (self.categoryIcon) { self.removeChild(self.categoryIcon); } // Add new category icon var iconAsset = category + 'Icon'; self.categoryIcon = self.attachAsset(iconAsset, { anchorX: 0.5, anchorY: 0.5 }); self.categoryIcon.x = -700; // Position to the left of text self.categoryIcon.y = -50; // Add category name text if (self.categoryText) { self.removeChild(self.categoryText); } self.categoryText = new Text2(category.charAt(0).toUpperCase() + category.slice(1), { size: 40, fill: 0xFFFFFF }); self.categoryText.anchor.set(0.5, 0.5); self.categoryText.x = -700; // Same x as icon self.categoryText.y = 50; // Below the icon self.addChild(self.categoryText); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x34495e }); /**** * Game Code ****/ var questions = [{ question: "The Sun is a star.", answers: ["True", "False"], correct: 0, category: "science" }, { question: "Penguins can fly.", answers: ["True", "False"], correct: 1, category: "nature" }, { question: "Water boils at 100Β°C at sea level.", answers: ["True", "False"], correct: 0, category: "science" }, { question: "The Great Wall of China is visible from space.", answers: ["True", "False"], correct: 1, category: "geography" }, { question: "Sharks are mammals.", answers: ["True", "False"], correct: 1, category: "nature" }, { question: "Lightning never strikes the same place twice.", answers: ["True", "False"], correct: 1, category: "science" }, { question: "Goldfish have a 3-second memory.", answers: ["True", "False"], correct: 1, category: "nature" }, { question: "Bananas are berries.", answers: ["True", "False"], correct: 0, category: "nature" }, { question: "The human body has 206 bones.", answers: ["True", "False"], correct: 0, category: "science" }, { question: "Mount Everest is the tallest mountain on Earth.", answers: ["True", "False"], correct: 0, category: "geography" }, { question: "Octopuses have three hearts.", answers: ["True", "False"], correct: 0, category: "nature" }, { question: "The Earth is flat.", answers: ["True", "False"], correct: 1, category: "geography" }, { question: "Honey never spoils.", answers: ["True", "False"], correct: 0, category: "general" }, { question: "Humans only use 10% of their brain.", answers: ["True", "False"], correct: 1, category: "science" }, { question: "Diamonds are made of carbon.", answers: ["True", "False"], correct: 0, category: "science" }, { question: "Bulls are attracted to the color red.", answers: ["True", "False"], correct: 1, category: "nature" }, { question: "The Moon causes ocean tides.", answers: ["True", "False"], correct: 0, category: "science" }, { question: "Chameleons change color to blend in.", answers: ["True", "False"], correct: 1, category: "nature" }, { question: "There are more trees on Earth than stars in the Milky Way.", answers: ["True", "False"], correct: 0, category: "nature" }, { question: "Glass is a liquid at room temperature.", answers: ["True", "False"], correct: 1, category: "science" }]; var currentQuestionIndex = 0; var answered = false; var lives = 3; // Score display var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Lives display var livesTxt = new Text2('Lives: 3', { size: 80, fill: 0xFFFFFF }); livesTxt.anchor.set(1, 0); LK.gui.topRight.addChild(livesTxt); // Question display var questionDisplay = game.addChild(new Question()); questionDisplay.x = 2048 / 2; questionDisplay.y = 800; // Answer buttons var answerButton1 = game.addChild(new AnswerButton()); answerButton1.x = 2048 / 2 - 450; answerButton1.y = 1600; var answerButton2 = game.addChild(new AnswerButton()); answerButton2.x = 2048 / 2 + 450; answerButton2.y = 1600; function showNextQuestion() { if (currentQuestionIndex >= questions.length) { // Player completed all questions - they win! LK.showYouWin(); return; } var question = questions[currentQuestionIndex]; // Reset button states answered = false; answerButton1.answered = false; answerButton2.answered = false; // Reset button graphics answerButton1.removeChild(answerButton1.buttonBg); answerButton1.buttonBg = answerButton1.attachAsset('answerButton', { anchorX: 0.5, anchorY: 0.5 }); answerButton1.addChildAt(answerButton1.buttonBg, 0); answerButton2.removeChild(answerButton2.buttonBg); answerButton2.buttonBg = answerButton2.attachAsset('answerButton', { anchorX: 0.5, anchorY: 0.5 }); answerButton2.addChildAt(answerButton2.buttonBg, 0); // Set question and answers questionDisplay.setQuestion(question.question, question.category); answerButton1.setAnswer(question.answers[0], question.correct === 0); answerButton2.setAnswer(question.answers[1], question.correct === 1); // Animate elements entrance questionDisplay.alpha = 0; questionDisplay.scaleX = 0.5; questionDisplay.scaleY = 0.5; tween(questionDisplay, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 600, easing: tween.easeOut }); answerButton1.alpha = 0; answerButton1.y = 1800; tween(answerButton1, { alpha: 1, y: 1600 }, { duration: 500, easing: tween.easeOut }); answerButton2.alpha = 0; answerButton2.y = 1800; tween(answerButton2, { alpha: 1, y: 1600 }, { duration: 500, easing: tween.easeOut }); currentQuestionIndex++; } // Start the game with entrance animations scoreTxt.setText(LK.getScore()); // Initial setup - hide elements for entrance animation questionDisplay.alpha = 0; answerButton1.alpha = 0; answerButton2.alpha = 0; // Animate score text entrance scoreTxt.y = -100; tween(scoreTxt, { y: 0 }, { duration: 800, easing: tween.bounceOut }); // Animate lives text entrance livesTxt.y = -100; tween(livesTxt, { y: 0 }, { duration: 900, easing: tween.bounceOut }); // Start first question after UI animations LK.setTimeout(function () { showNextQuestion(); }, 500);
===================================================================
--- original.js
+++ change.js
@@ -147,8 +147,10 @@
anchorY: 0.5
});
// Category icon
self.categoryIcon = null;
+ // Category text
+ self.categoryText = null;
// Question text
self.questionText = new Text2('', {
size: 80,
fill: 0xFFFFFF,
@@ -170,9 +172,21 @@
anchorX: 0.5,
anchorY: 0.5
});
self.categoryIcon.x = -700; // Position to the left of text
- self.categoryIcon.y = 0;
+ self.categoryIcon.y = -50;
+ // Add category name text
+ if (self.categoryText) {
+ self.removeChild(self.categoryText);
+ }
+ self.categoryText = new Text2(category.charAt(0).toUpperCase() + category.slice(1), {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ self.categoryText.anchor.set(0.5, 0.5);
+ self.categoryText.x = -700; // Same x as icon
+ self.categoryText.y = 50; // Below the icon
+ self.addChild(self.categoryText);
};
return self;
});
Long Burton. In-Game asset. 2d. High contrast. No shadows
Long button. In-Game asset. 2d. High contrast. No shadows
Long, shiny green button. In-Game asset. 2d. High contrast. No shadows
Long Bright red button. In-Game asset. 2d. High contrast. No shadows
Science icon. In-Game asset. 2d. High contrast. No shadows
Minimalist nature icon. In-Game asset. 2d. High contrast. No shadows
Minimalist geography icon. In-Game asset. 2d. High contrast. No shadows
Minimalist icon for general topics. In-Game asset. 2d. High contrast. No shadows
Minimalist icon of history. In-Game asset. 2d. High contrast. No shadows
Dark orange circular minimalist roulette. In-Game asset. 2d. High contrast. No shadows
Minimalist medical icon. In-Game asset. 2d. High contrast. No shadows
Minimalist mechanics icon. In-Game asset. 2d. High contrast. No shadows
Minimalist film icon. In-Game asset. 2d. High contrast. No shadows