User prompt
still not working
User prompt
still not
User prompt
it did not work
User prompt
change the question answer options to be white
User prompt
change the question text to be white
User prompt
do that
User prompt
more!!!
User prompt
make the animation much bigger! Also, add a celebratory sound when the quess is correct ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
sounds good
User prompt
now i cannot read anything
User prompt
yes. do one at a time oplease
User prompt
yes please
User prompt
when you guess correct, go to the next questions
User prompt
you dont die when the answeer is correct
User prompt
you die when you guess wrong
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'x')' in or related to this line: 'questionTxt.x = 2048 / 2;' Line Number: 637
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'x')' in or related to this line: 'scoreTxt.x = LK.gui.width / 2 - 500;' Line Number: 613
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'x')' in or related to this line: 'scoreTxt.x = LK.gui.width / 2 - 500;' Line Number: 614
User prompt
the game title header is not centered at the top of the screen. please do that
User prompt
make all the buttons brighter
User prompt
still pleasu fix
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // OptionButton: A tappable answer button var OptionButton = Container.expand(function () { var self = Container.call(this); // Button background var bg = self.attachAsset('optionBg', { width: 1200, height: 180, color: 0x6c4edb, // brighter purple shape: 'box', anchorX: 0.5, anchorY: 0.5 }); // Option text var txt = new Text2('', { size: 70, fill: 0xFFFFFF }); txt.anchor.set(0.5, 0.5); self.addChild(txt); // Store callback self._onSelect = null; // Set option text self.setText = function (t) { txt.setText(t); }; // Set callback self.setCallback = function (cb) { self._onSelect = cb; }; // Enable/disable button self.setEnabled = function (enabled) { self.interactive = enabled; self.alpha = enabled ? 1 : 0.5; }; // Handle tap self.down = function (x, y, obj) { if (self._onSelect) self._onSelect(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181c24 }); /**** * Game Code ****/ // --- Quiz Data --- var quizData = [{ game: "The Legend of Zelda: Breath of the Wild", studio: "Nintendo", options: ["Nintendo", "Ubisoft", "Rockstar Games", "Valve"] }, { game: "The Witcher 3: Wild Hunt", studio: "CD Projekt Red", options: ["CD Projekt Red", "Bethesda", "Square Enix", "Capcom"] }, { game: "Halo: Combat Evolved", studio: "Bungie", options: ["Bungie", "343 Industries", "EA", "Insomniac Games"] }, { game: "God of War (2018)", studio: "Santa Monica Studio", options: ["Santa Monica Studio", "Naughty Dog", "FromSoftware", "Remedy"] }, { game: "Grand Theft Auto V", studio: "Rockstar North", options: ["Rockstar North", "Ubisoft", "Valve", "Nintendo"] }, { game: "Overwatch", studio: "Blizzard Entertainment", options: ["Blizzard Entertainment", "Epic Games", "Valve", "Riot Games"] }, { game: "Portal 2", studio: "Valve", options: ["Valve", "Bethesda", "Ubisoft", "Nintendo"] }, { game: "Uncharted 4: A Thief's End", studio: "Naughty Dog", options: ["Naughty Dog", "Santa Monica Studio", "Rockstar Games", "CD Projekt Red"] }, { game: "Dark Souls", studio: "FromSoftware", options: ["FromSoftware", "Capcom", "Square Enix", "Remedy"] }, { game: "Red Dead Redemption 2", studio: "Rockstar Games", options: ["Rockstar Games", "Ubisoft", "Valve", "Nintendo"] }, { game: "Assassin's Creed II", studio: "Ubisoft", options: ["Ubisoft", "Rockstar Games", "Valve", "Nintendo"] }, { game: "Half-Life 2", studio: "Valve", options: ["Valve", "Bethesda", "Ubisoft", "CD Projekt Red"] }, { game: "The Last of Us", studio: "Naughty Dog", options: ["Naughty Dog", "Santa Monica Studio", "Rockstar Games", "Remedy"] }, { game: "Bloodborne", studio: "FromSoftware", options: ["FromSoftware", "Capcom", "Square Enix", "Remedy"] }, { game: "Mass Effect 2", studio: "BioWare", options: ["BioWare", "EA", "Ubisoft", "Bethesda"] }, { game: "Elden Ring", studio: "FromSoftware", options: ["FromSoftware", "Capcom", "Square Enix", "Remedy"] }, { game: "Cyberpunk 2077", studio: "CD Projekt Red", options: ["CD Projekt Red", "Bethesda", "Square Enix", "Capcom"] }, { game: "The Elder Scrolls V: Skyrim", studio: "Bethesda", options: ["Bethesda", "CD Projekt Red", "Ubisoft", "Valve"] }, { game: "DOOM (2016)", studio: "id Software", options: ["id Software", "Bethesda", "Valve", "Ubisoft"] }, { game: "Minecraft", studio: "Mojang", options: ["Mojang", "Epic Games", "Valve", "Nintendo"] }, { game: "Fortnite", studio: "Epic Games", options: ["Epic Games", "Riot Games", "Valve", "Ubisoft"] }, { game: "League of Legends", studio: "Riot Games", options: ["Riot Games", "Epic Games", "Valve", "Ubisoft"] }, { game: "Counter-Strike: Global Offensive", studio: "Valve", options: ["Valve", "Ubisoft", "EA", "Rockstar Games"] }, { game: "Animal Crossing: New Horizons", studio: "Nintendo", options: ["Nintendo", "Ubisoft", "Valve", "Rockstar Games"] }, { game: "Persona 5", studio: "Atlus", options: ["Atlus", "Square Enix", "Capcom", "Bandai Namco"] }, { game: "Final Fantasy VII", studio: "Square Enix", options: ["Square Enix", "Capcom", "Atlus", "Nintendo"] }, { game: "Street Fighter II", studio: "Capcom", options: ["Capcom", "Bandai Namco", "Square Enix", "Nintendo"] }, { game: "Tekken 3", studio: "Bandai Namco", options: ["Bandai Namco", "Capcom", "Square Enix", "Nintendo"] }, { game: "Pac-Man", studio: "Namco", options: ["Namco", "Nintendo", "Atari", "Sega"] }, { game: "Sonic the Hedgehog", studio: "Sega", options: ["Sega", "Nintendo", "Namco", "Capcom"] }, { game: "Tetris", studio: "Alexey Pajitnov", options: ["Alexey Pajitnov", "Nintendo", "Sega", "Atari"] }, { game: "Donkey Kong", studio: "Nintendo", options: ["Nintendo", "Sega", "Namco", "Capcom"] }, { game: "Metroid Prime", studio: "Retro Studios", options: ["Retro Studios", "Nintendo", "Capcom", "Ubisoft"] }, { game: "Splatoon", studio: "Nintendo", options: ["Nintendo", "Ubisoft", "Valve", "Rockstar Games"] }, { game: "Fire Emblem: Three Houses", studio: "Intelligent Systems", options: ["Intelligent Systems", "Nintendo", "Capcom", "Square Enix"] }, { game: "Pokémon Red and Blue", studio: "Game Freak", options: ["Game Freak", "Nintendo", "Capcom", "Bandai Namco"] }, { game: "Pokémon GO", studio: "Niantic", options: ["Niantic", "Nintendo", "Game Freak", "Bandai Namco"] }, { game: "Super Smash Bros. Ultimate", studio: "Nintendo", options: ["Nintendo", "Bandai Namco", "Capcom", "Ubisoft"] }, { game: "Mario Kart 8 Deluxe", studio: "Nintendo", options: ["Nintendo", "Ubisoft", "Valve", "Rockstar Games"] }, { game: "Super Mario Odyssey", studio: "Nintendo", options: ["Nintendo", "Ubisoft", "Valve", "Rockstar Games"] }, { game: "The Legend of Zelda: Ocarina of Time", studio: "Nintendo", options: ["Nintendo", "Ubisoft", "Valve", "Rockstar Games"] }, { game: "The Sims", studio: "Maxis", options: ["Maxis", "EA", "Ubisoft", "Valve"] }, { game: "SimCity", studio: "Maxis", options: ["Maxis", "EA", "Ubisoft", "Valve"] }, { game: "Spore", studio: "Maxis", options: ["Maxis", "EA", "Ubisoft", "Valve"] }, { game: "FIFA 21", studio: "EA Sports", options: ["EA Sports", "Konami", "Ubisoft", "Valve"] }, { game: "Pro Evolution Soccer", studio: "Konami", options: ["Konami", "EA Sports", "Ubisoft", "Valve"] }, { game: "Silent Hill 2", studio: "Konami", options: ["Konami", "Capcom", "Square Enix", "Bandai Namco"] }, { game: "Metal Gear Solid", studio: "Konami", options: ["Konami", "Capcom", "Square Enix", "Bandai Namco"] }, { game: "Castlevania: Symphony of the Night", studio: "Konami", options: ["Konami", "Capcom", "Square Enix", "Bandai Namco"] }, { game: "Resident Evil 2", studio: "Capcom", options: ["Capcom", "Konami", "Square Enix", "Bandai Namco"] }, { game: "Monster Hunter: World", studio: "Capcom", options: ["Capcom", "Konami", "Square Enix", "Bandai Namco"] }, { game: "Mega Man 2", studio: "Capcom", options: ["Capcom", "Konami", "Square Enix", "Bandai Namco"] }, { game: "Dragon Quest XI", studio: "Square Enix", options: ["Square Enix", "Capcom", "Atlus", "Nintendo"] }, { game: "Kingdom Hearts", studio: "Square Enix", options: ["Square Enix", "Capcom", "Atlus", "Nintendo"] }, { game: "Chrono Trigger", studio: "Square", options: ["Square", "Enix", "Capcom", "Nintendo"] }, { game: "Persona 4 Golden", studio: "Atlus", options: ["Atlus", "Square Enix", "Capcom", "Bandai Namco"] }, { game: "Yakuza 0", studio: "Sega", options: ["Sega", "Capcom", "Square Enix", "Bandai Namco"] }, { game: "Bayonetta", studio: "PlatinumGames", options: ["PlatinumGames", "Sega", "Capcom", "Nintendo"] }, { game: "NieR: Automata", studio: "PlatinumGames", options: ["PlatinumGames", "Square Enix", "Capcom", "Nintendo"] }, { game: "Journey", studio: "thatgamecompany", options: ["thatgamecompany", "Santa Monica Studio", "Naughty Dog", "Remedy"] }, { game: "Flower", studio: "thatgamecompany", options: ["thatgamecompany", "Santa Monica Studio", "Naughty Dog", "Remedy"] }, { game: "Inside", studio: "Playdead", options: ["Playdead", "Remedy", "Naughty Dog", "Santa Monica Studio"] }, { game: "Limbo", studio: "Playdead", options: ["Playdead", "Remedy", "Naughty Dog", "Santa Monica Studio"] }, { game: "Control", studio: "Remedy", options: ["Remedy", "Playdead", "Naughty Dog", "Santa Monica Studio"] }, { game: "Alan Wake", studio: "Remedy", options: ["Remedy", "Playdead", "Naughty Dog", "Santa Monica Studio"] }, { game: "Max Payne", studio: "Remedy", options: ["Remedy", "Rockstar Games", "Naughty Dog", "Santa Monica Studio"] }, { game: "Grand Theft Auto: San Andreas", studio: "Rockstar North", options: ["Rockstar North", "Ubisoft", "Valve", "Nintendo"] }, { game: "Bully", studio: "Rockstar Vancouver", options: ["Rockstar Vancouver", "Rockstar North", "Ubisoft", "Valve"] }, { game: "L.A. Noire", studio: "Team Bondi", options: ["Team Bondi", "Rockstar North", "Ubisoft", "Valve"] }, { game: "Bioshock", studio: "Irrational Games", options: ["Irrational Games", "2K Games", "Ubisoft", "Valve"] }, { game: "Bioshock Infinite", studio: "Irrational Games", options: ["Irrational Games", "2K Games", "Ubisoft", "Valve"] }, { game: "Borderlands 2", studio: "Gearbox Software", options: ["Gearbox Software", "2K Games", "Ubisoft", "Valve"] }, { game: "Civilization VI", studio: "Firaxis Games", options: ["Firaxis Games", "2K Games", "Ubisoft", "Valve"] }, { game: "XCOM 2", studio: "Firaxis Games", options: ["Firaxis Games", "2K Games", "Ubisoft", "Valve"] }, { game: "Sid Meier's Pirates!", studio: "MicroProse", options: ["MicroProse", "Firaxis Games", "2K Games", "Ubisoft"] }, { game: "The Outer Worlds", studio: "Obsidian Entertainment", options: ["Obsidian Entertainment", "Bethesda", "CD Projekt Red", "BioWare"] }, { game: "Fallout: New Vegas", studio: "Obsidian Entertainment", options: ["Obsidian Entertainment", "Bethesda", "CD Projekt Red", "BioWare"] }, { game: "Fallout 3", studio: "Bethesda", options: ["Bethesda", "Obsidian Entertainment", "CD Projekt Red", "BioWare"] }, { game: "Dishonored", studio: "Arkane Studios", options: ["Arkane Studios", "Bethesda", "Obsidian Entertainment", "BioWare"] }, { game: "Prey (2017)", studio: "Arkane Studios", options: ["Arkane Studios", "Bethesda", "Obsidian Entertainment", "BioWare"] }, { game: "Wolfenstein: The New Order", studio: "MachineGames", options: ["MachineGames", "id Software", "Bethesda", "Obsidian Entertainment"] }, { game: "Quake", studio: "id Software", options: ["id Software", "Bethesda", "Obsidian Entertainment", "MachineGames"] }, { game: "Doom Eternal", studio: "id Software", options: ["id Software", "Bethesda", "Obsidian Entertainment", "MachineGames"] }, { game: "Cuphead", studio: "Studio MDHR", options: ["Studio MDHR", "Team Cherry", "Playdead", "Remedy"] }, { game: "Hollow Knight", studio: "Team Cherry", options: ["Team Cherry", "Studio MDHR", "Playdead", "Remedy"] }, { game: "Celeste", studio: "Matt Makes Games", options: ["Matt Makes Games", "Team Cherry", "Studio MDHR", "Playdead"] }, { game: "Undertale", studio: "Toby Fox", options: ["Toby Fox", "Matt Makes Games", "Team Cherry", "Studio MDHR"] }, { game: "Stardew Valley", studio: "ConcernedApe", options: ["ConcernedApe", "Toby Fox", "Matt Makes Games", "Team Cherry"] }, { game: "Terraria", studio: "Re-Logic", options: ["Re-Logic", "ConcernedApe", "Toby Fox", "Matt Makes Games"] }, { game: "Ori and the Blind Forest", studio: "Moon Studios", options: ["Moon Studios", "Re-Logic", "ConcernedApe", "Toby Fox"] }, { game: "Ori and the Will of the Wisps", studio: "Moon Studios", options: ["Moon Studios", "Re-Logic", "ConcernedApe", "Toby Fox"] }, { game: "Hades", studio: "Supergiant Games", options: ["Supergiant Games", "Moon Studios", "Re-Logic", "ConcernedApe"] }, { game: "Transistor", studio: "Supergiant Games", options: ["Supergiant Games", "Moon Studios", "Re-Logic", "ConcernedApe"] }, { game: "Bastion", studio: "Supergiant Games", options: ["Supergiant Games", "Moon Studios", "Re-Logic", "ConcernedApe"] }, { game: "Dead Cells", studio: "Motion Twin", options: ["Motion Twin", "Supergiant Games", "Moon Studios", "Re-Logic"] }, { game: "Slay the Spire", studio: "MegaCrit", options: ["MegaCrit", "Motion Twin", "Supergiant Games", "Moon Studios"] }, { game: "Into the Breach", studio: "Subset Games", options: ["Subset Games", "MegaCrit", "Motion Twin", "Supergiant Games"] }, { game: "FTL: Faster Than Light", studio: "Subset Games", options: ["Subset Games", "MegaCrit", "Motion Twin", "Supergiant Games"] }, { game: "The Binding of Isaac", studio: "Edmund McMillen", options: ["Edmund McMillen", "Subset Games", "MegaCrit", "Motion Twin"] }, { game: "Super Meat Boy", studio: "Team Meat", options: ["Team Meat", "Edmund McMillen", "Subset Games", "MegaCrit"] }, { game: "Hotline Miami", studio: "Dennaton Games", options: ["Dennaton Games", "Team Meat", "Edmund McMillen", "Subset Games"] }, { game: "Papers, Please", studio: "Lucas Pope", options: ["Lucas Pope", "Dennaton Games", "Team Meat", "Edmund McMillen"] }, { game: "Return of the Obra Dinn", studio: "Lucas Pope", options: ["Lucas Pope", "Dennaton Games", "Team Meat", "Edmund McMillen"] }, { game: "Oxenfree", studio: "Night School Studio", options: ["Night School Studio", "Lucas Pope", "Dennaton Games", "Team Meat"] }, { game: "Firewatch", studio: "Campo Santo", options: ["Campo Santo", "Night School Studio", "Lucas Pope", "Dennaton Games"] }, { game: "Gone Home", studio: "The Fullbright Company", options: ["The Fullbright Company", "Campo Santo", "Night School Studio", "Lucas Pope"] }, { game: "What Remains of Edith Finch", studio: "Giant Sparrow", options: ["Giant Sparrow", "The Fullbright Company", "Campo Santo", "Night School Studio"] }, { game: "Outer Wilds", studio: "Mobius Digital", options: ["Mobius Digital", "Giant Sparrow", "The Fullbright Company", "Campo Santo"] }, { game: "Journey to the Savage Planet", studio: "Typhoon Studios", options: ["Typhoon Studios", "Mobius Digital", "Giant Sparrow", "The Fullbright Company"] }, { game: "Control", studio: "Remedy", options: ["Remedy", "Typhoon Studios", "Mobius Digital", "Giant Sparrow"] }, { game: "Quantum Break", studio: "Remedy", options: ["Remedy", "Typhoon Studios", "Mobius Digital", "Giant Sparrow"] }, { game: "Detroit: Become Human", studio: "Quantic Dream", options: ["Quantic Dream", "Remedy", "Typhoon Studios", "Mobius Digital"] }, { game: "Heavy Rain", studio: "Quantic Dream", options: ["Quantic Dream", "Remedy", "Typhoon Studios", "Mobius Digital"] }, { game: "Beyond: Two Souls", studio: "Quantic Dream", options: ["Quantic Dream", "Remedy", "Typhoon Studios", "Mobius Digital"] }, { game: "Until Dawn", studio: "Supermassive Games", options: ["Supermassive Games", "Quantic Dream", "Remedy", "Typhoon Studios"] }, { game: "Little Nightmares", studio: "Tarsier Studios", options: ["Tarsier Studios", "Supermassive Games", "Quantic Dream", "Remedy"] }, { game: "Inside", studio: "Playdead", options: ["Playdead", "Tarsier Studios", "Supermassive Games", "Quantic Dream"] }, { game: "Limbo", studio: "Playdead", options: ["Playdead", "Tarsier Studios", "Supermassive Games", "Quantic Dream"] }, { game: "Journey", studio: "thatgamecompany", options: ["thatgamecompany", "Playdead", "Tarsier Studios", "Supermassive Games"] }, { game: "Abzû", studio: "Giant Squid", options: ["Giant Squid", "thatgamecompany", "Playdead", "Tarsier Studios"] }, { game: "The Pathless", studio: "Giant Squid", options: ["Giant Squid", "thatgamecompany", "Playdead", "Tarsier Studios"] }, { game: "No Man's Sky", studio: "Hello Games", options: ["Hello Games", "Giant Squid", "thatgamecompany", "Playdead"] }, { game: "Journey to the Savage Planet", studio: "Typhoon Studios", options: ["Typhoon Studios", "Hello Games", "Giant Squid", "thatgamecompany"] }]; // Shuffle quizData for each game session function shuffleArray(arr) { for (var i = arr.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } // --- Game State --- var currentQuestion = 0; var score = 0; var timeLeft = 60; // seconds var timerInterval = null; var optionButtons = []; var isAnswered = false; // --- UI Elements --- // Title var titleTxt = new Text2("Game Studio Guessr", { size: 110, fill: 0xF7C873 }); titleTxt.anchor.set(0.5, 0); LK.gui.top.addChild(titleTxt); layoutUI(); // Ensure initial layout is centered // Score var scoreTxt = new Text2("Score: 0", { size: 70, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Timer var timerTxt = new Text2("Time: 60", { size: 70, fill: 0xFFFFFF }); timerTxt.anchor.set(0.5, 0); LK.gui.top.addChild(timerTxt); // Question text var questionTxt = new Text2("", { size: 90, fill: 0xFFFFFF }); questionTxt.anchor.set(0.5, 0.5); game.addChild(questionTxt); // --- Layout positions --- function layoutUI() { // Title at top center, below safe area if (typeof LK.gui.width !== "undefined") { titleTxt.x = LK.gui.width / 2; if (typeof scoreTxt !== "undefined" && scoreTxt) scoreTxt.x = LK.gui.width / 2 - 500; if (typeof timerTxt !== "undefined" && timerTxt) timerTxt.x = LK.gui.width / 2 + 500; } else { // fallback to center of 2048px if gui.width is not available titleTxt.x = 2048 / 2; if (typeof scoreTxt !== "undefined" && scoreTxt) scoreTxt.x = 2048 / 2 - 500; if (typeof timerTxt !== "undefined" && timerTxt) timerTxt.x = 2048 / 2 + 500; } titleTxt.y = 40; if (typeof scoreTxt !== "undefined" && scoreTxt) scoreTxt.y = 40; if (typeof timerTxt !== "undefined" && timerTxt) timerTxt.y = 40; // Question in center questionTxt.x = 2048 / 2; questionTxt.y = 600; // Option buttons: vertical stack, centered var startY = 1100; var spacing = 260; for (var i = 0; i < optionButtons.length; i++) { var btn = optionButtons[i]; btn.x = 2048 / 2; btn.y = startY + i * spacing; } } // --- Option Buttons --- function createOptionButtons() { // Remove old buttons for (var i = 0; i < optionButtons.length; i++) { optionButtons[i].destroy(); } optionButtons = []; // Create 4 buttons for (var i = 0; i < 4; i++) { var btn = new OptionButton(); btn.setText(""); btn.setEnabled(false); game.addChild(btn); optionButtons.push(btn); } layoutUI(); } // --- Show Question --- function showQuestion(idx) { isAnswered = false; if (idx >= quizData.length) { endGame(); return; } var q = quizData[idx]; questionTxt.setText("Who made:\n" + q.game + "?"); // Shuffle options for this question var options = q.options.slice(); shuffleArray(options); // Set button text and callbacks for (var i = 0; i < optionButtons.length; i++) { var btn = optionButtons[i]; btn.setText(options[i]); btn.setEnabled(true); // Reset tint to default for new question (force immediately) btn.tint = 0x6c4edb; (function (btn, answer) { btn.setCallback(function () { if (isAnswered) return; isAnswered = true; handleAnswer(answer, q.studio, btn); }); })(btn, options[i]); } layoutUI(); } // --- Handle Answer --- function handleAnswer(selected, correct, btn) { // Disable all buttons for (var i = 0; i < optionButtons.length; i++) { optionButtons[i].setEnabled(false); } // Visual feedback if (selected === correct) { // Correct: flash green tween(btn, { tint: 0x4caf50 }, { duration: 200, onFinish: function onFinish() { tween(btn, { tint: 0x6c4edb }, { duration: 300 }); } }); // Confetti animation for correct answer! (function confettiBurst() { var confettiCount = 40; var centerX = 2048 / 2; var centerY = 600; var spread = 400; var colors = [0x4caf50, 0xF7C873, 0xFFFFFF, 0x4e2c92]; for (var i = 0; i < confettiCount; i++) { var angle = Math.PI * 2 * (i / confettiCount); var speed = 8 + Math.random() * 6; var dx = Math.cos(angle) * (Math.random() * spread * 0.5 + spread * 0.5) / 40; var dy = Math.sin(angle) * (Math.random() * spread * 0.5 + spread * 0.5) / 40; var color = colors[Math.floor(Math.random() * colors.length)]; var confetti = LK.getAsset('optionBg', { width: 32 + Math.random() * 16, height: 32 + Math.random() * 16, color: color, anchorX: 0.5, anchorY: 0.5 }); confetti.x = centerX; confetti.y = centerY; confetti.alpha = 1; confetti.rotation = Math.random() * Math.PI * 2; game.addChild(confetti); (function (confetti, dx, dy) { tween(confetti, { x: confetti.x + dx * 40, y: confetti.y + dy * 40, alpha: 0, rotation: confetti.rotation + Math.random() * Math.PI * 2 }, { duration: 700 + Math.random() * 300, onFinish: function onFinish() { confetti.destroy(); } }); })(confetti, dx, dy); } })(); score += 1; scoreTxt.setText("Score: " + score); } else { // Incorrect: flash red tween(btn, { tint: 0xff3b30 }, { duration: 200, onFinish: function onFinish() { tween(btn, { tint: 0x6c4edb }, { duration: 300 }); } }); // Also flash correct button green for (var i = 0; i < optionButtons.length; i++) { if (optionButtons[i].text === correct) { tween(optionButtons[i], { tint: 0x4caf50 }, { duration: 200, onFinish: function onFinish() { tween(optionButtons[i], { tint: 0x6c4edb }, { duration: 300 }); } }); } } } // Next question after short delay LK.setTimeout(function () { currentQuestion += 1; showQuestion(currentQuestion); }, 700); } // --- Timer --- function startTimer() { timeLeft = 60; timerTxt.setText("Time: " + timeLeft); if (timerInterval) LK.clearInterval(timerInterval); timerInterval = LK.setInterval(function () { timeLeft -= 1; timerTxt.setText("Time: " + timeLeft); if (timeLeft <= 0) { LK.clearInterval(timerInterval); endGame(); } }, 1000); } // --- End Game --- function endGame() { // Show game over popup LK.setScore(score); LK.showGameOver(); } // --- Game Start --- function startGame() { // Shuffle questions shuffleArray(quizData); currentQuestion = 0; score = 0; scoreTxt.setText("Score: 0"); startTimer(); createOptionButtons(); showQuestion(currentQuestion); } // --- Responsive Layout --- game.on('resize', function () { layoutUI(); }); // --- Start --- startGame();
===================================================================
--- original.js
+++ change.js
@@ -602,19 +602,19 @@
function layoutUI() {
// Title at top center, below safe area
if (typeof LK.gui.width !== "undefined") {
titleTxt.x = LK.gui.width / 2;
- scoreTxt.x = LK.gui.width / 2 - 500;
- timerTxt.x = LK.gui.width / 2 + 500;
+ if (typeof scoreTxt !== "undefined" && scoreTxt) scoreTxt.x = LK.gui.width / 2 - 500;
+ if (typeof timerTxt !== "undefined" && timerTxt) timerTxt.x = LK.gui.width / 2 + 500;
} else {
// fallback to center of 2048px if gui.width is not available
titleTxt.x = 2048 / 2;
- scoreTxt.x = 2048 / 2 - 500;
- timerTxt.x = 2048 / 2 + 500;
+ if (typeof scoreTxt !== "undefined" && scoreTxt) scoreTxt.x = 2048 / 2 - 500;
+ if (typeof timerTxt !== "undefined" && timerTxt) timerTxt.x = 2048 / 2 + 500;
}
titleTxt.y = 40;
- scoreTxt.y = 40;
- timerTxt.y = 40;
+ if (typeof scoreTxt !== "undefined" && scoreTxt) scoreTxt.y = 40;
+ if (typeof timerTxt !== "undefined" && timerTxt) timerTxt.y = 40;
// Question in center
questionTxt.x = 2048 / 2;
questionTxt.y = 600;
// Option buttons: vertical stack, centered