Code edit (1 edits merged)
Please save this source code
User prompt
add when the player choose correct or in correct answer the space should be 10 lines between the question panel and the message
User prompt
add when the player choose correct or in correct answer the space should be 4 lines between the question panel and the message
User prompt
add 4lines space after the question panel
User prompt
add a player choose the correct answer then pop the congratualtion message with paper blast
User prompt
the emoji should be fun and sad mixing and it will walk the through the page
User prompt
add when the player choose incorrect answer then the sad emoji has to appear in that page
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'alpha')' in or related to this line: 'quitButton.buttonShape.alpha = 0.7;' Line Number: 712
User prompt
add option in the the home Ui
User prompt
remove the over all badges option in the game
User prompt
add 20 questions for each category
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'alpha')' in or related to this line: 'nextButton.buttonShape.alpha = 1;' Line Number: 233
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'feedbackText.style.fill = "#FF3B30";' Line Number: 252
Code edit (1 edits merged)
Please save this source code
User prompt
Science Explorer: Educational Discovery Quest
Initial prompt
"Create an interactive educational game called Science Explorer where players learn about space, wildlife, and the human body through engaging activities. 🧩 Game Structure: Players choose from three categories: Space, Wildlife, and Human Anatomy.(every category contains 25 questions) Quiz Mode: Answer fun science questions to unlock new levels. for every correct answer-- congratulations pop up Mini-Puzzles: Solve interactive challenges to reinforce learning. add quit option --then player will want to quit any time they will 🏆 Progress & Rewards: Correct answers unlock new levels and earn badges like "Space Cadet", "Wildlife Ranger", and "Anatomy Expert". Fun animations and sounds celebrate achievements. A progress tracker keeps players motivated. 🎨 Design & UX: Bright, engaging visuals with smooth animations and easy navigation. Instant feedback: "Great Job!" for correct answers, hints for retries. No time pressure, allowing a stress-free learning experience. 🏁 Win/Lose Condition: ✅ Completing activities unlocks new challenges.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { currentCategory: "space", progress: { space: 0, wildlife: 0, anatomy: 0 }, currentLevel: 1, highestLevel: 1 }); /**** * Classes ****/ var CategoryButton = Container.expand(function (category, title, description) { var self = Container.call(this); var buttonShape = self.attachAsset(category + 'Theme', { anchorX: 0.5, anchorY: 0.5 }); var titleText = new Text2(title, { size: 60, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.y = -80; self.addChild(titleText); var descText = new Text2(description, { size: 30, fill: 0xFFFFFF }); descText.anchor.set(0.5, 0); descText.y = 10; descText.wordWrap = true; descText.wordWrapWidth = 450; self.addChild(descText); var progressLabel = new Text2("Progress: 0%", { size: 30, fill: 0xFFFFFF }); progressLabel.anchor.set(0.5, 0); progressLabel.y = 100; self.addChild(progressLabel); self.category = category; self.updateProgress = function (progress) { progressLabel.setText("Progress: " + Math.floor(progress * 100) + "%"); }; self.down = function (x, y, obj) { LK.getSound('buttonClick').play(); buttonShape.alpha = 0.7; }; self.up = function (x, y, obj) { buttonShape.alpha = 1; selectCategory(self.category); }; return self; }); var OptionButton = Container.expand(function (text) { var self = Container.call(this); var buttonShape = self.attachAsset('optionButton', { anchorX: 0.5, anchorY: 0.5 }); var optionText = new Text2(text, { size: 40, fill: 0xFFFFFF }); optionText.anchor.set(0.5, 0.5); self.addChild(optionText); self.isCorrect = false; self.setText = function (text) { optionText.setText(text); }; self.down = function (x, y, obj) { LK.getSound('buttonClick').play(); buttonShape.alpha = 0.7; }; self.up = function (x, y, obj) { buttonShape.alpha = 1; checkAnswer(self); }; self.setEnabled = function (enabled) { self.interactive = enabled; buttonShape.alpha = enabled ? 1 : 0.5; }; return self; }); var ProgressBar = Container.expand(function () { var self = Container.call(this); var barBackground = self.attachAsset('progressBar', { anchorX: 0, anchorY: 0.5 }); var barFill = self.attachAsset('progressFill', { anchorX: 0, anchorY: 0.5 }); var levelText = new Text2("Level 1", { size: 40, fill: 0xFFFFFF }); levelText.anchor.set(0.5, 0.5); levelText.x = barBackground.width / 2; self.addChild(levelText); self.updateProgress = function (current, total) { var percentage = current / total; var targetWidth = barBackground.width * percentage; tween(barFill, { width: targetWidth }, { duration: 500, easing: tween.easeOut }); levelText.setText("Level " + storage.currentLevel); }; return self; }); var QuestionPanel = Container.expand(function () { var self = Container.call(this); var panel = self.attachAsset('questionPanel', { anchorX: 0.5, anchorY: 0.5 }); var questionText = new Text2("", { size: 50, fill: 0x000000 }); questionText.anchor.set(0.5, 0); questionText.y = -150; questionText.wordWrap = true; questionText.wordWrapWidth = 1700; self.addChild(questionText); self.options = []; for (var i = 0; i < 4; i++) { var option = new OptionButton(""); option.x = i % 2 === 0 ? -400 : 400; option.y = i < 2 ? 0 : 150; self.options.push(option); self.addChild(option); } var feedbackIcon = self.attachAsset('correctFeedback', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 250 }); feedbackIcon.visible = false; var feedbackText = new Text2("", { size: 40, fill: 0x000000 }); feedbackText.anchor.set(0.5, 0.5); feedbackText.y = 350; // Adjusted to add 4 lines of space feedbackText.wordWrap = true; feedbackText.wordWrapWidth = 1700; self.addChild(feedbackText); var nextButton = new OptionButton("Next Question"); nextButton.y = 350; nextButton.visible = false; self.addChild(nextButton); nextButton.up = function () { if (nextButton.buttonShape) { nextButton.buttonShape.alpha = 1; } loadNextQuestion(); }; self.setQuestion = function (question) { questionText.setText(question.question); for (var i = 0; i < self.options.length; i++) { self.options[i].setText(question.options[i]); self.options[i].isCorrect = i === question.correctIndex; self.options[i].setEnabled(true); } feedbackIcon.visible = false; feedbackText.setText(""); nextButton.visible = false; }; self.showFeedback = function (correct, explanation) { feedbackIcon.visible = true; if (correct) { feedbackIcon.texture = LK.getAsset('correctFeedback', {}).texture; feedbackText.setText("Correct! " + explanation); feedbackText.setStyle({ fill: 0x34C759 }); // Add congratulation message var congratsText = new Text2("Congratulations!", { size: 80, fill: 0xFFD700 }); congratsText.anchor.set(0.5, 0.5); congratsText.x = 0; congratsText.y = -300; self.addChild(congratsText); // Animate paper blast effect var paperBlast = LK.getAsset('correctFeedback', { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); self.addChild(paperBlast); tween(paperBlast, { scaleX: 3, scaleY: 3, alpha: 0 }, { duration: 1000, easing: tween.easeOut, onComplete: function onComplete() { self.removeChild(paperBlast); self.removeChild(congratsText); } }); } else { feedbackIcon.texture = LK.getAsset('incorrectFeedback', {}).texture; var sadEmoji = new Text2("😢", { size: 100, fill: 0xFF3B30 }); sadEmoji.anchor.set(0.5, 0.5); sadEmoji.x = -1024; // Start off-screen to the left sadEmoji.y = 350; self.addChild(sadEmoji); // Animate the emoji to walk across the screen tween(sadEmoji, { x: 1024 // Move to off-screen to the right }, { duration: 3000, // 3 seconds to walk across easing: tween.easeInOut, onComplete: function onComplete() { self.removeChild(sadEmoji); // Remove emoji after animation } }); feedbackText.setText("Incorrect. " + explanation); feedbackText.setStyle({ fill: 0xFF3B30 }); } nextButton.visible = true; // Disable all option buttons for (var i = 0; i < self.options.length; i++) { self.options[i].setEnabled(false); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game state variables var currentScreen = "categories"; // categories, gameplay var questions = []; var currentQuestionIndex = 0; var categoryButtons = []; // Category and question data var categoryData = { space: { name: "Space", description: "Explore planets, stars, and galaxies", questions: [{ question: "Which planet is known as the Red Planet?", options: ["Venus", "Mars", "Jupiter", "Mercury"], correctIndex: 1, explanation: "Mars is called the Red Planet because of the reddish iron oxide on its surface." }, { question: "How many planets are in our solar system?", options: ["7", "8", "9", "10"], correctIndex: 1, explanation: "There are 8 planets: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune." }, { question: "What is the largest planet in our solar system?", options: ["Earth", "Saturn", "Jupiter", "Neptune"], correctIndex: 2, explanation: "Jupiter is the largest planet in our solar system." }, { question: "What is the name of the galaxy we live in?", options: ["Andromeda", "Milky Way", "Triangulum", "Sombrero"], correctIndex: 1, explanation: "We live in the Milky Way galaxy, which contains billions of stars." }, { question: "What causes the phases of the Moon?", options: ["Earth's shadow", "Moon's rotation", "Moon's orbit and sunlight", "Solar flares"], correctIndex: 2, explanation: "The Moon's phases are caused by its position relative to Earth and the Sun as it orbits Earth." }, { question: "What is the closest star to Earth?", options: ["Alpha Centauri", "Proxima Centauri", "Sirius", "Betelgeuse"], correctIndex: 1, explanation: "Proxima Centauri is the closest known star to the Sun." }, { question: "What is the smallest planet in our solar system?", options: ["Mercury", "Mars", "Venus", "Earth"], correctIndex: 0, explanation: "Mercury is the smallest planet in our solar system." }, { question: "What is the hottest planet in our solar system?", options: ["Mercury", "Venus", "Mars", "Jupiter"], correctIndex: 1, explanation: "Venus is the hottest planet due to its thick, toxic atmosphere." }, { question: "What is the main component of the Sun?", options: ["Helium", "Oxygen", "Hydrogen", "Carbon"], correctIndex: 2, explanation: "The Sun is primarily composed of hydrogen." }, { question: "What is the name of the first artificial satellite sent into space?", options: ["Sputnik 1", "Explorer 1", "Vanguard 1", "Luna 1"], correctIndex: 0, explanation: "Sputnik 1 was the first artificial satellite launched by the Soviet Union in 1957." }, { question: "What is the term for a rocky object that orbits the Sun?", options: ["Comet", "Asteroid", "Meteor", "Meteorite"], correctIndex: 1, explanation: "Asteroids are rocky objects that orbit the Sun." }, { question: "What is the name of the largest volcano in the solar system?", options: ["Mount Everest", "Olympus Mons", "Mauna Kea", "Mount Etna"], correctIndex: 1, explanation: "Olympus Mons on Mars is the largest volcano in the solar system." }, { question: "What is the term for a star that suddenly increases in brightness?", options: ["Supernova", "Nova", "Pulsar", "Quasar"], correctIndex: 1, explanation: "A nova is a star that suddenly increases in brightness." }, { question: "What is the name of the first human to travel into space?", options: ["Neil Armstrong", "Yuri Gagarin", "Buzz Aldrin", "John Glenn"], correctIndex: 1, explanation: "Yuri Gagarin was the first human to travel into space in 1961." }, { question: "What is the term for the path an object takes as it moves around another object in space?", options: ["Orbit", "Trajectory", "Course", "Route"], correctIndex: 0, explanation: "An orbit is the path an object takes as it moves around another object in space." }, { question: "What is the name of the first American astronaut to orbit Earth?", options: ["John Glenn", "Alan Shepard", "Neil Armstrong", "Buzz Aldrin"], correctIndex: 0, explanation: "John Glenn was the first American astronaut to orbit Earth in 1962." }, { question: "What is the term for a small body of ice, rock, and cosmic dust that follows an elliptical orbit around the Sun?", options: ["Asteroid", "Comet", "Meteor", "Meteorite"], correctIndex: 1, explanation: "A comet is a small body of ice, rock, and cosmic dust that follows an elliptical orbit around the Sun." }, { question: "What is the name of the first spacecraft to land on the Moon?", options: ["Apollo 11", "Luna 2", "Viking 1", "Mariner 4"], correctIndex: 0, explanation: "Apollo 11 was the first spacecraft to land on the Moon in 1969." }, { question: "What is the term for the boundary around a black hole beyond which no light or other radiation can escape?", options: ["Event Horizon", "Singularity", "Accretion Disk", "Photon Sphere"], correctIndex: 0, explanation: "The event horizon is the boundary around a black hole beyond which no light or other radiation can escape." }, { question: "What is the name of the largest moon of Saturn?", options: ["Titan", "Europa", "Ganymede", "Callisto"], correctIndex: 0, explanation: "Titan is the largest moon of Saturn." }, { question: "What is the term for the apparent shift in position of an object when viewed from different angles?", options: ["Parallax", "Refraction", "Reflection", "Diffraction"], correctIndex: 0, explanation: "Parallax is the apparent shift in position of an object when viewed from different angles." }, { question: "What is the name of the first space station launched into orbit?", options: ["Skylab", "Mir", "Salyut 1", "International Space Station"], correctIndex: 2, explanation: "Salyut 1 was the first space station launched into orbit by the Soviet Union in 1971." }, { question: "What is the term for the point in an orbit closest to the Earth?", options: ["Apogee", "Perigee", "Zenith", "Nadir"], correctIndex: 1, explanation: "Perigee is the point in an orbit closest to the Earth." }] }, wildlife: { name: "Wildlife", description: "Discover amazing animals and their habitats", questions: [{ question: "Which is the fastest land animal?", options: ["Lion", "Cheetah", "Gazelle", "Elephant"], correctIndex: 1, explanation: "Cheetahs can run up to 70 mph (112 km/h) for short bursts." }, { question: "What do koalas mainly eat?", options: ["Bamboo", "Eucalyptus leaves", "Fruits", "Insects"], correctIndex: 1, explanation: "Koalas primarily eat eucalyptus leaves, which are toxic to many other animals." }, { question: "Which animal is known as the 'King of the Jungle'?", options: ["Tiger", "Lion", "Gorilla", "Panther"], correctIndex: 1, explanation: "Lions are called 'King of the Jungle' despite living in savannas, not jungles." }, { question: "How many hearts does an octopus have?", options: ["1", "2", "3", "4"], correctIndex: 2, explanation: "Octopuses have three hearts: two pump blood through the gills and one pumps it through the body." }, { question: "Which bird can fly backward?", options: ["Eagle", "Sparrow", "Hummingbird", "Penguin"], correctIndex: 2, explanation: "Hummingbirds are the only birds that can fly backward, upside down, and hover in mid-air." }, { question: "What is the largest land animal?", options: ["Elephant", "Giraffe", "Hippopotamus", "Rhinoceros"], correctIndex: 0, explanation: "The African elephant is the largest land animal." }, { question: "What is the only mammal capable of true flight?", options: ["Bat", "Flying Squirrel", "Sugar Glider", "Flying Lemur"], correctIndex: 0, explanation: "Bats are the only mammals capable of true flight." }, { question: "What is the largest species of shark?", options: ["Great White Shark", "Hammerhead Shark", "Whale Shark", "Tiger Shark"], correctIndex: 2, explanation: "The whale shark is the largest species of shark." }, { question: "What is the primary diet of a panda?", options: ["Bamboo", "Insects", "Fish", "Fruits"], correctIndex: 0, explanation: "Pandas primarily eat bamboo." }, { question: "What is the fastest bird in the world?", options: ["Peregrine Falcon", "Eagle", "Hawk", "Owl"], correctIndex: 0, explanation: "The peregrine falcon is the fastest bird, reaching speeds over 240 mph (386 km/h) during dives." }, { question: "What is the largest species of cat?", options: ["Lion", "Tiger", "Cheetah", "Leopard"], correctIndex: 1, explanation: "The tiger is the largest species of cat." }, { question: "What is the only bird that can fly both forwards and backwards?", options: ["Hummingbird", "Sparrow", "Eagle", "Parrot"], correctIndex: 0, explanation: "Hummingbirds are the only birds that can fly both forwards and backwards." }, { question: "What is the largest species of bear?", options: ["Polar Bear", "Grizzly Bear", "Black Bear", "Panda Bear"], correctIndex: 0, explanation: "The polar bear is the largest species of bear." }, { question: "What is the primary diet of a carnivorous animal?", options: ["Plants", "Insects", "Meat", "Fruits"], correctIndex: 2, explanation: "Carnivorous animals primarily eat meat." }, { question: "What is the largest species of primate?", options: ["Gorilla", "Chimpanzee", "Orangutan", "Gibbon"], correctIndex: 0, explanation: "The gorilla is the largest species of primate." }, { question: "What is the primary diet of a herbivorous animal?", options: ["Plants", "Insects", "Meat", "Fruits"], correctIndex: 0, explanation: "Herbivorous animals primarily eat plants." }, { question: "What is the largest species of reptile?", options: ["Komodo Dragon", "Crocodile", "Alligator", "Iguana"], correctIndex: 1, explanation: "The saltwater crocodile is the largest species of reptile." }, { question: "What is the primary diet of an omnivorous animal?", options: ["Plants", "Insects", "Meat and Plants", "Fruits"], correctIndex: 2, explanation: "Omnivorous animals eat both meat and plants." }, { question: "What is the largest species of amphibian?", options: ["Frog", "Toad", "Salamander", "Newt"], correctIndex: 2, explanation: "The Chinese giant salamander is the largest species of amphibian." }, { question: "What is the primary diet of a frugivorous animal?", options: ["Plants", "Insects", "Fruits", "Meat"], correctIndex: 2, explanation: "Frugivorous animals primarily eat fruits." }, { question: "What is the largest species of fish?", options: ["Great White Shark", "Whale Shark", "Hammerhead Shark", "Tiger Shark"], correctIndex: 1, explanation: "The whale shark is the largest species of fish." }] }, anatomy: { name: "Human Anatomy", description: "Learn about the amazing human body", questions: [{ question: "What is the largest organ in the human body?", options: ["Heart", "Liver", "Skin", "Brain"], correctIndex: 2, explanation: "The skin is the body's largest organ, covering about 20 square feet in adults." }, { question: "How many bones are in the adult human body?", options: ["206", "186", "226", "246"], correctIndex: 0, explanation: "The adult human body has 206 bones. Babies are born with about 300 bones that fuse as they grow." }, { question: "What is the strongest muscle in the human body?", options: ["Biceps", "Heart", "Jaw muscles", "Gluteus maximus"], correctIndex: 2, explanation: "The masseter (jaw muscle) is the strongest based on its size and the force it can exert." }, { question: "What percentage of the human body is water?", options: ["50-60%", "60-70%", "70-80%", "80-90%"], correctIndex: 1, explanation: "The human body is composed of about 60-70% water, varying by age, gender, and body composition." }, { question: "Which part of the body produces insulin?", options: ["Liver", "Kidney", "Pancreas", "Gallbladder"], correctIndex: 2, explanation: "The pancreas produces insulin, which regulates blood sugar levels." }, { question: "What is the smallest bone in the human body?", options: ["Stapes", "Incus", "Malleus", "Humerus"], correctIndex: 0, explanation: "The stapes, located in the middle ear, is the smallest bone in the human body." }, { question: "What is the main function of red blood cells?", options: ["Fight infections", "Transport oxygen", "Clot blood", "Regulate temperature"], correctIndex: 1, explanation: "Red blood cells transport oxygen from the lungs to the rest of the body." }, { question: "What is the largest artery in the human body?", options: ["Aorta", "Carotid", "Femoral", "Pulmonary"], correctIndex: 0, explanation: "The aorta is the largest artery in the human body." }, { question: "What is the main function of the liver?", options: ["Produce insulin", "Filter blood", "Store calcium", "Regulate temperature"], correctIndex: 1, explanation: "The liver filters blood, detoxifies chemicals, and metabolizes drugs." }, { question: "What is the main function of the kidneys?", options: ["Produce insulin", "Filter blood", "Store calcium", "Regulate temperature"], correctIndex: 1, explanation: "The kidneys filter waste products from the blood and excrete them as urine." }, { question: "What is the main function of the lungs?", options: ["Produce insulin", "Filter blood", "Exchange oxygen and carbon dioxide", "Regulate temperature"], correctIndex: 2, explanation: "The lungs exchange oxygen and carbon dioxide between the air and the blood." }, { question: "What is the main function of the heart?", options: ["Produce insulin", "Pump blood", "Store calcium", "Regulate temperature"], correctIndex: 1, explanation: "The heart pumps blood throughout the body, supplying oxygen and nutrients to tissues." }, { question: "What is the main function of the brain?", options: ["Produce insulin", "Control body functions", "Store calcium", "Regulate temperature"], correctIndex: 1, explanation: "The brain controls body functions, processes sensory information, and coordinates movement." }, { question: "What is the main function of the stomach?", options: ["Produce insulin", "Digest food", "Store calcium", "Regulate temperature"], correctIndex: 1, explanation: "The stomach digests food by secreting acid and enzymes." }, { question: "What is the main function of the intestines?", options: ["Produce insulin", "Absorb nutrients", "Store calcium", "Regulate temperature"], correctIndex: 1, explanation: "The intestines absorb nutrients from digested food into the bloodstream." }, { question: "What is the main function of the pancreas?", options: ["Produce insulin", "Filter blood", "Store calcium", "Regulate temperature"], correctIndex: 0, explanation: "The pancreas produces insulin and other hormones that regulate blood sugar levels." }, { question: "What is the main function of the spleen?", options: ["Produce insulin", "Filter blood", "Store calcium", "Regulate temperature"], correctIndex: 1, explanation: "The spleen filters blood, recycles old red blood cells, and helps fight infections." }, { question: "What is the main function of the gallbladder?", options: ["Produce insulin", "Store bile", "Store calcium", "Regulate temperature"], correctIndex: 1, explanation: "The gallbladder stores bile produced by the liver, which helps digest fats." }, { question: "What is the main function of the thyroid gland?", options: ["Produce insulin", "Regulate metabolism", "Store calcium", "Regulate temperature"], correctIndex: 1, explanation: "The thyroid gland produces hormones that regulate metabolism, growth, and development." }, { question: "What is the main function of the adrenal glands?", options: ["Produce insulin", "Regulate metabolism", "Produce adrenaline", "Regulate temperature"], correctIndex: 2, explanation: "The adrenal glands produce hormones like adrenaline that help regulate metabolism and stress response." }] } }; // UI Elements var questionPanel = new QuestionPanel(); questionPanel.x = 2048 / 2; questionPanel.y = 2732 / 2 + 200; questionPanel.visible = false; var progressBar = new ProgressBar(); progressBar.x = 124; progressBar.y = 100; progressBar.visible = false; var badges = []; // Helper functions function getCategoryName(category) { return categoryData[category].name; } function selectCategory(category) { currentScreen = "gameplay"; storage.currentCategory = category; // Update UI visibility showGameplayScreen(); // Load questions questions = categoryData[category].questions; currentQuestionIndex = 0; // Show first question loadQuestion(currentQuestionIndex); // Update progress bar progressBar.updateProgress(currentQuestionIndex, questions.length); LK.playMusic('gameMusic'); } function showCategoriesScreen() { currentScreen = "categories"; // Hide gameplay elements questionPanel.visible = false; progressBar.visible = false; // Show category buttons for (var i = 0; i < categoryButtons.length; i++) { categoryButtons[i].visible = true; categoryButtons[i].updateProgress(storage.progress[categoryButtons[i].category]); } } function showGameplayScreen() { // Hide category buttons for (var i = 0; i < categoryButtons.length; i++) { categoryButtons[i].visible = false; } // Show gameplay elements questionPanel.visible = true; progressBar.visible = true; } function loadQuestion(index) { if (index < questions.length) { questionPanel.setQuestion(questions[index]); } else { completeCategoryProgress(); } } function loadNextQuestion() { currentQuestionIndex++; progressBar.updateProgress(currentQuestionIndex, questions.length); loadQuestion(currentQuestionIndex); } function checkAnswer(selectedOption) { var isCorrect = selectedOption.isCorrect; if (isCorrect) { LK.getSound('correct').play(); LK.setScore(LK.getScore() + 10); } else { LK.getSound('incorrect').play(); } questionPanel.showFeedback(isCorrect, questions[currentQuestionIndex].explanation); // Update progress if (isCorrect) { var categoryProgress = storage.progress[storage.currentCategory]; var newProgress = (currentQuestionIndex + 1) / questions.length; if (newProgress > categoryProgress) { storage.progress[storage.currentCategory] = newProgress; } } } function completeCategoryProgress() { // Play level complete sound if all questions are completed if (storage.progress[storage.currentCategory] >= 1) { LK.getSound('levelComplete').play(); } showCategoriesScreen(); } // Initialize game function initializeGame() { // Create category selection screen var spaceButton = new CategoryButton('space', "SPACE", "Explore planets, stars, and the universe"); spaceButton.x = 2048 / 2 - 550; spaceButton.y = 2732 / 2; game.addChild(spaceButton); categoryButtons.push(spaceButton); var wildlifeButton = new CategoryButton('wildlife', "WILDLIFE", "Discover amazing animals and their habitats"); wildlifeButton.x = 2048 / 2; wildlifeButton.y = 2732 / 2; game.addChild(wildlifeButton); categoryButtons.push(wildlifeButton); var anatomyButton = new CategoryButton('anatomy', "ANATOMY", "Learn about the amazing human body"); anatomyButton.x = 2048 / 2 + 550; anatomyButton.y = 2732 / 2; game.addChild(anatomyButton); categoryButtons.push(anatomyButton); // Create title var titleText = new Text2("SCIENCE EXPLORER", { size: 100, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 400; game.addChild(titleText); var subtitleText = new Text2("Choose a topic to explore", { size: 50, fill: 0xFFFFFF }); subtitleText.anchor.set(0.5, 0.5); subtitleText.x = 2048 / 2; subtitleText.y = 500; game.addChild(subtitleText); // Create score display var scoreText = new Text2("Score: 0", { size: 50, fill: 0xFFFFFF }); scoreText.anchor.set(1, 0); LK.gui.topRight.addChild(scoreText); // Add quit button var quitButton = new OptionButton("Quit"); quitButton.x = 2048 / 2; quitButton.y = 2732 / 2 + 400; quitButton.down = function (x, y, obj) { LK.getSound('buttonClick').play(); if (quitButton.buttonShape) { quitButton.buttonShape.alpha = 0.7; } }; quitButton.up = function (x, y, obj) { if (quitButton.buttonShape) { quitButton.buttonShape.alpha = 1; } LK.showGameOver(); // Use LK's built-in game over screen to quit }; game.addChild(quitButton); // Add gameplay elements game.addChild(questionPanel); game.addChild(progressBar); // Update category buttons with saved progress for (var i = 0; i < categoryButtons.length; i++) { categoryButtons[i].updateProgress(storage.progress[categoryButtons[i].category]); } // Update UI based on initial screen if (currentScreen === "categories") { showCategoriesScreen(); } else { showGameplayScreen(); } // Update score display LK.setScore(0); } initializeGame(); // Game update loop game.update = function () { // Update score display var scoreDisplay = LK.gui.topRight.children[0]; if (scoreDisplay) { scoreDisplay.setText("Score: " + LK.getScore()); } }; LK.playMusic('gameMusic');
===================================================================
--- original.js
+++ change.js
@@ -153,9 +153,9 @@
size: 40,
fill: 0x000000
});
feedbackText.anchor.set(0.5, 0.5);
- feedbackText.y = 250;
+ feedbackText.y = 350; // Adjusted to add 4 lines of space
feedbackText.wordWrap = true;
feedbackText.wordWrapWidth = 1700;
self.addChild(feedbackText);
var nextButton = new OptionButton("Next Question");