User prompt
now they are all dark
User prompt
when a button is clicked on one question, it should not be darkended for the next
User prompt
Please fix the bug: 'Uncaught TypeError: LK.effects.confetti is not a function' in or related to this line: 'LK.effects.confetti({' Line Number: 697
User prompt
can we make the UI more fun? Ideally some animations when you guess correct - like confetti
User prompt
okay. we need at least 100
Code edit (1 edits merged)
Please save this source code
User prompt
Game Studio Guessr
Initial prompt
Hi - i want to create a quiz game. It can pretty much be any format but the questions will be about guessing what studio made waht gaem
/**** * 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) { // Button bounce animation tween(self, { scaleX: 0.92, scaleY: 0.92 }, { duration: 60, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 80 }); } }); 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; } } // --- Difficulty Sorting --- // Assign a difficulty to each question (easy, medium, hard) based on heuristics function getDifficulty(q) { // Heuristic: If the studio is Nintendo, Valve, Ubisoft, EA, Capcom, Sega, Konami, Bandai Namco, Square Enix, Rockstar, Bethesda, Naughty Dog, Blizzard, CD Projekt Red, Mojang, Epic Games, id Software, FromSoftware, BioWare, Santa Monica Studio, Insomniac Games, Maxis, Atari, Namco, or Game Freak, it's easy. // If the studio is a well-known but not top-tier household name, it's medium. // Otherwise, hard. var easyStudios = ["Nintendo", "Valve", "Ubisoft", "EA", "Capcom", "Sega", "Konami", "Bandai Namco", "Square Enix", "Rockstar North", "Rockstar Games", "Bethesda", "Naughty Dog", "Blizzard Entertainment", "CD Projekt Red", "Mojang", "Epic Games", "id Software", "FromSoftware", "BioWare", "Santa Monica Studio", "Insomniac Games", "Maxis", "Atari", "Namco", "Game Freak"]; var mediumStudios = ["Remedy", "PlatinumGames", "Retro Studios", "Intelligent Systems", "Atlus", "Team Cherry", "Moon Studios", "Supergiant Games", "Motion Twin", "MegaCrit", "Subset Games", "Edmund McMillen", "Team Meat", "Dennaton Games", "Lucas Pope", "Night School Studio", "Campo Santo", "The Fullbright Company", "Giant Sparrow", "Mobius Digital", "Typhoon Studios", "Giant Squid", "Hello Games", "Obsidian Entertainment", "Arkane Studios", "MachineGames", "Studio MDHR", "Matt Makes Games", "ConcernedApe", "Re-Logic", "Playdead", "Irrational Games", "2K Games", "Firaxis Games", "MicroProse"]; if (easyStudios.indexOf(q.studio) !== -1) return "easy"; if (mediumStudios.indexOf(q.studio) !== -1) return "medium"; return "hard"; } // Sort questions by difficulty, then shuffle within each group function sortAndShuffleQuizData() { var easy = [], medium = [], hard = []; for (var i = 0; i < quizData.length; i++) { var q = quizData[i]; var diff = getDifficulty(q); if (diff === "easy") easy.push(q);else if (diff === "medium") medium.push(q);else hard.push(q); } shuffleArray(easy); shuffleArray(medium); shuffleArray(hard); // Concatenate: easy first, then medium, then hard quizData = easy.concat(medium).concat(hard); } // --- 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 = 120; if (typeof scoreTxt !== "undefined" && scoreTxt) scoreTxt.y = 120; if (typeof timerTxt !== "undefined" && timerTxt) timerTxt.y = 120; // Question in center if (typeof questionTxt !== "undefined" && questionTxt) questionTxt.x = 2048 / 2; if (typeof questionTxt !== "undefined" && questionTxt) questionTxt.y = 600; // Option buttons: vertical stack, centered, large for mobile 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; btn.width = 1400; btn.height = 220; btn.scale.set(1, 1); } } // --- 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]; // Animate out old question (if any) questionTxt.alpha = 0; questionTxt.setText("Who made:\n" + q.game + "?"); tween(questionTxt, { alpha: 1 }, { duration: 250 }); // 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 }); } }); // Play celebratory sound for correct answer! LK.getSound('celebrate').play(); // Confetti animation for correct answer! (much bigger, more celebratory) (function confettiBurst() { var confettiCount = 80; var centerX = 2048 / 2; var centerY = 600; var spread = 900; var colors = [0x4caf50, 0xF7C873, 0xFFFFFF, 0x4e2c92, 0xFF69B4, 0x00E6FF, 0xFFD700, 0xFF3B30]; for (var i = 0; i < confettiCount; i++) { var angle = Math.PI * 2 * (i / confettiCount) + Math.random() * 0.2; var speed = 18 + Math.random() * 12; var dx = Math.cos(angle) * (Math.random() * spread * 0.5 + spread * 0.5) / 20; var dy = Math.sin(angle) * (Math.random() * spread * 0.5 + spread * 0.5) / 20; var color = colors[Math.floor(Math.random() * colors.length)]; var confetti = LK.getAsset('optionBg', { width: 48 + Math.random() * 32, height: 24 + Math.random() * 32, 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 * (30 + Math.random() * 30), y: confetti.y + dy * (30 + Math.random() * 30), alpha: 0, rotation: confetti.rotation + Math.random() * Math.PI * 4 }, { duration: 900 + Math.random() * 400, onFinish: function onFinish() { confetti.destroy(); } }); })(confetti, dx, dy); } })(); score += 1; scoreTxt.setText("Score: " + score); // Score pop animation (much bigger and bouncier) scoreTxt.scale.set(2.2, 2.2); tween(scoreTxt, { scaleX: 1, scaleY: 1 }, { duration: 420, easing: tween.elasticOut }); // Question text celebratory pop and color flash questionTxt.scale.set(2.5, 2.5); questionTxt.tint = 0xF7C873; tween(questionTxt, { scaleX: 1, scaleY: 1, tint: 0xFFFFFF }, { duration: 500, easing: tween.elasticOut }); // Go to next question after short delay for feedback LK.setTimeout(function () { currentQuestion += 1; showQuestion(currentQuestion); }, 700); } else { // Incorrect: flash red tween(btn, { tint: 0xff3b30 }, { duration: 200, onFinish: function onFinish() { tween(btn, { tint: 0x6c4edb }, { duration: 300 }); } }); // Big red pop and color flash on question text for incorrect answer questionTxt.scale.set(2.2, 2.2); questionTxt.tint = 0xff3b30; tween(questionTxt, { scaleX: 1, scaleY: 1, tint: 0xFFFFFF }, { duration: 400, easing: tween.elasticOut }); // Screen shake effect (function screenShake() { var shakeMagnitude = 32; var shakeTimes = 8; var originalX = game.x || 0; var originalY = game.y || 0; var i = 0; function doShake() { if (i < shakeTimes) { game.x = originalX + (Math.random() - 0.5) * shakeMagnitude; game.y = originalY + (Math.random() - 0.5) * shakeMagnitude; i++; LK.setTimeout(doShake, 20); } else { game.x = originalX; game.y = originalY; } } doShake(); })(); // 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 }); } }); } } } // End game immediately on wrong answer if (selected !== correct) { LK.setTimeout(function () { endGame(); }, 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() { // Sort and shuffle questions by difficulty sortAndShuffleQuizData(); currentQuestion = 0; score = 0; scoreTxt.setText("Score: 0"); startTimer(); createOptionButtons(); showQuestion(currentQuestion); } // --- Responsive Layout --- game.on('resize', function () { layoutUI(); }); // --- Start --- startGame();
/****
* 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) {
// Button bounce animation
tween(self, {
scaleX: 0.92,
scaleY: 0.92
}, {
duration: 60,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 80
});
}
});
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;
}
}
// --- Difficulty Sorting ---
// Assign a difficulty to each question (easy, medium, hard) based on heuristics
function getDifficulty(q) {
// Heuristic: If the studio is Nintendo, Valve, Ubisoft, EA, Capcom, Sega, Konami, Bandai Namco, Square Enix, Rockstar, Bethesda, Naughty Dog, Blizzard, CD Projekt Red, Mojang, Epic Games, id Software, FromSoftware, BioWare, Santa Monica Studio, Insomniac Games, Maxis, Atari, Namco, or Game Freak, it's easy.
// If the studio is a well-known but not top-tier household name, it's medium.
// Otherwise, hard.
var easyStudios = ["Nintendo", "Valve", "Ubisoft", "EA", "Capcom", "Sega", "Konami", "Bandai Namco", "Square Enix", "Rockstar North", "Rockstar Games", "Bethesda", "Naughty Dog", "Blizzard Entertainment", "CD Projekt Red", "Mojang", "Epic Games", "id Software", "FromSoftware", "BioWare", "Santa Monica Studio", "Insomniac Games", "Maxis", "Atari", "Namco", "Game Freak"];
var mediumStudios = ["Remedy", "PlatinumGames", "Retro Studios", "Intelligent Systems", "Atlus", "Team Cherry", "Moon Studios", "Supergiant Games", "Motion Twin", "MegaCrit", "Subset Games", "Edmund McMillen", "Team Meat", "Dennaton Games", "Lucas Pope", "Night School Studio", "Campo Santo", "The Fullbright Company", "Giant Sparrow", "Mobius Digital", "Typhoon Studios", "Giant Squid", "Hello Games", "Obsidian Entertainment", "Arkane Studios", "MachineGames", "Studio MDHR", "Matt Makes Games", "ConcernedApe", "Re-Logic", "Playdead", "Irrational Games", "2K Games", "Firaxis Games", "MicroProse"];
if (easyStudios.indexOf(q.studio) !== -1) return "easy";
if (mediumStudios.indexOf(q.studio) !== -1) return "medium";
return "hard";
}
// Sort questions by difficulty, then shuffle within each group
function sortAndShuffleQuizData() {
var easy = [],
medium = [],
hard = [];
for (var i = 0; i < quizData.length; i++) {
var q = quizData[i];
var diff = getDifficulty(q);
if (diff === "easy") easy.push(q);else if (diff === "medium") medium.push(q);else hard.push(q);
}
shuffleArray(easy);
shuffleArray(medium);
shuffleArray(hard);
// Concatenate: easy first, then medium, then hard
quizData = easy.concat(medium).concat(hard);
}
// --- 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 = 120;
if (typeof scoreTxt !== "undefined" && scoreTxt) scoreTxt.y = 120;
if (typeof timerTxt !== "undefined" && timerTxt) timerTxt.y = 120;
// Question in center
if (typeof questionTxt !== "undefined" && questionTxt) questionTxt.x = 2048 / 2;
if (typeof questionTxt !== "undefined" && questionTxt) questionTxt.y = 600;
// Option buttons: vertical stack, centered, large for mobile
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;
btn.width = 1400;
btn.height = 220;
btn.scale.set(1, 1);
}
}
// --- 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];
// Animate out old question (if any)
questionTxt.alpha = 0;
questionTxt.setText("Who made:\n" + q.game + "?");
tween(questionTxt, {
alpha: 1
}, {
duration: 250
});
// 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
});
}
});
// Play celebratory sound for correct answer!
LK.getSound('celebrate').play();
// Confetti animation for correct answer! (much bigger, more celebratory)
(function confettiBurst() {
var confettiCount = 80;
var centerX = 2048 / 2;
var centerY = 600;
var spread = 900;
var colors = [0x4caf50, 0xF7C873, 0xFFFFFF, 0x4e2c92, 0xFF69B4, 0x00E6FF, 0xFFD700, 0xFF3B30];
for (var i = 0; i < confettiCount; i++) {
var angle = Math.PI * 2 * (i / confettiCount) + Math.random() * 0.2;
var speed = 18 + Math.random() * 12;
var dx = Math.cos(angle) * (Math.random() * spread * 0.5 + spread * 0.5) / 20;
var dy = Math.sin(angle) * (Math.random() * spread * 0.5 + spread * 0.5) / 20;
var color = colors[Math.floor(Math.random() * colors.length)];
var confetti = LK.getAsset('optionBg', {
width: 48 + Math.random() * 32,
height: 24 + Math.random() * 32,
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 * (30 + Math.random() * 30),
y: confetti.y + dy * (30 + Math.random() * 30),
alpha: 0,
rotation: confetti.rotation + Math.random() * Math.PI * 4
}, {
duration: 900 + Math.random() * 400,
onFinish: function onFinish() {
confetti.destroy();
}
});
})(confetti, dx, dy);
}
})();
score += 1;
scoreTxt.setText("Score: " + score);
// Score pop animation (much bigger and bouncier)
scoreTxt.scale.set(2.2, 2.2);
tween(scoreTxt, {
scaleX: 1,
scaleY: 1
}, {
duration: 420,
easing: tween.elasticOut
});
// Question text celebratory pop and color flash
questionTxt.scale.set(2.5, 2.5);
questionTxt.tint = 0xF7C873;
tween(questionTxt, {
scaleX: 1,
scaleY: 1,
tint: 0xFFFFFF
}, {
duration: 500,
easing: tween.elasticOut
});
// Go to next question after short delay for feedback
LK.setTimeout(function () {
currentQuestion += 1;
showQuestion(currentQuestion);
}, 700);
} else {
// Incorrect: flash red
tween(btn, {
tint: 0xff3b30
}, {
duration: 200,
onFinish: function onFinish() {
tween(btn, {
tint: 0x6c4edb
}, {
duration: 300
});
}
});
// Big red pop and color flash on question text for incorrect answer
questionTxt.scale.set(2.2, 2.2);
questionTxt.tint = 0xff3b30;
tween(questionTxt, {
scaleX: 1,
scaleY: 1,
tint: 0xFFFFFF
}, {
duration: 400,
easing: tween.elasticOut
});
// Screen shake effect
(function screenShake() {
var shakeMagnitude = 32;
var shakeTimes = 8;
var originalX = game.x || 0;
var originalY = game.y || 0;
var i = 0;
function doShake() {
if (i < shakeTimes) {
game.x = originalX + (Math.random() - 0.5) * shakeMagnitude;
game.y = originalY + (Math.random() - 0.5) * shakeMagnitude;
i++;
LK.setTimeout(doShake, 20);
} else {
game.x = originalX;
game.y = originalY;
}
}
doShake();
})();
// 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
});
}
});
}
}
}
// End game immediately on wrong answer
if (selected !== correct) {
LK.setTimeout(function () {
endGame();
}, 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() {
// Sort and shuffle questions by difficulty
sortAndShuffleQuizData();
currentQuestion = 0;
score = 0;
scoreTxt.setText("Score: 0");
startTimer();
createOptionButtons();
showQuestion(currentQuestion);
}
// --- Responsive Layout ---
game.on('resize', function () {
layoutUI();
});
// --- Start ---
startGame();