User prompt
Change clues to picture clues
User prompt
Make PJ image smaller in instructions page
User prompt
Move 4x5 image down 300 in instructions overlay
User prompt
Move images up 300 in instructions page
User prompt
Move images to the top of instructions screen
User prompt
Move PJ picture to the right of cat
User prompt
Remove line of instructions text that says any dot on the board
User prompt
Change second line in instructions to multiple lines for better visibility
User prompt
Change first line in instructions text and make it multiple lines so its visible on the screen
User prompt
Prevent instructions text from going off the screen by adding more lines
User prompt
Prevent instructions text from going off the screen
User prompt
Add detailed how to play guide when info button is clicked use pictures to explain how to play
User prompt
Why is instructions scene all black
User prompt
Add a detailed step by step guide to playing the puzzle in instructions scene
User prompt
Change instructions scene for a detailed step by step guide on how to play the puzzle
User prompt
Change text that says match each row with the correct items to say " Follow the clues to work out the solution"
User prompt
Remove instrument images from how to screen
User prompt
Move blank image to the left of drum image in instructions page
User prompt
In instructions scene Change the info image to a blank image
User prompt
Change text that says tap a dot to cycle through options to say " Tap the question mark to cycle through options"
User prompt
Move images in instructions page up 300
User prompt
Move how to play up 200
User prompt
Move how to play up 100
User prompt
Move how to play up 100
User prompt
Move instructions text up 100
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Character class for main character gameplay elements var Character = Container.expand(function () { var self = Container.call(this); // Example: add a character sprite (replace 'Sprite' with your character asset if needed) var characterSprite = self.attachAsset('Sprite', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Example: character name self.name = "Lyra"; // Example: character state self.isActive = true; // Example: method to set character name self.setName = function (newName) { self.name = newName; }; // Example: method to activate/deactivate character self.setActive = function (active) { self.isActive = !!active; }; // Example: update method for per-frame logic self.update = function () { // Add per-frame logic for the character here }; return self; }); // Dot class for interactive dots in the puzzle var Dot = Container.expand(function () { var self = Container.call(this); // Create a visual representation for the dot var dotGraphics = self.attachAsset('Street', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.8, scaleY: 1.8, alpha: 0 }); // Dot properties self.isActive = false; self.gridX = 0; self.gridY = 0; self.instrumentIndex = 0; self.currentInstrument = null; // Array of instrument image IDs for first row (dots 1-5) self.instruments = ['Blank', 'Saxophone', 'Drum', 'Gutair', 'Harp', 'Flute']; // Array of image IDs for dots 21-25 (bottom row) self.specialInstruments = ['Blank', 'PJ', 'KJ', 'Harmony', 'Khalida', 'Sapphire']; // Method to toggle dot state self.toggle = function () { self.isActive = !self.isActive; }; // Method to cycle through instruments for first row (dots 1-5) self.cycleInstrument = function () { // Remove current instrument if it exists and free it from usedInstruments if (self.currentInstrument) { var currentInstrumentId = self.instruments[self.instrumentIndex]; if (currentInstrumentId !== 'Blank' && usedInstruments[currentInstrumentId] === self) { delete usedInstruments[currentInstrumentId]; } self.removeChild(self.currentInstrument); self.currentInstrument = null; } // Find next available instrument var startIndex = self.instrumentIndex; var found = false; do { self.instrumentIndex = (self.instrumentIndex + 1) % self.instruments.length; var instrumentId = self.instruments[self.instrumentIndex]; // Check if instrument is available (Blank is always available) if (instrumentId === 'Blank' || !usedInstruments[instrumentId]) { found = true; // Mark non-blank instruments as used if (instrumentId !== 'Blank') { usedInstruments[instrumentId] = self; } // Create new instrument image self.currentInstrument = self.attachAsset(instrumentId, { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); break; } } while (self.instrumentIndex !== startIndex); // If no available instrument found, stay on current (shouldn't happen with 6 instruments for 5 dots) if (!found) { self.instrumentIndex = startIndex; } }; // Method to cycle through special images for dots 21-25 (bottom row) self.cycleSpecialInstrument = function () { // Remove current instrument if it exists if (self.currentInstrument) { // Remove from usedSpecialInstruments if not Blank if (typeof usedSpecialInstruments !== "undefined" && self.specialInstruments && typeof self.specialInstrumentIndex === "number") { var prevId = self.specialInstruments[self.specialInstrumentIndex]; if (prevId !== 'Blank' && usedSpecialInstruments[prevId] === self) { delete usedSpecialInstruments[prevId]; } } self.removeChild(self.currentInstrument); self.currentInstrument = null; } // Find next available special instrument (no duplicates except Blank) if (typeof usedSpecialInstruments === "undefined") { usedSpecialInstruments = {}; } if (typeof self.specialInstrumentIndex !== "number") self.specialInstrumentIndex = 0; self.specialInstrumentIndex = typeof self.specialInstrumentIndex === "number" ? self.specialInstrumentIndex : 0; var startIndex = self.specialInstrumentIndex; var found = false; do { self.specialInstrumentIndex = (self.specialInstrumentIndex + 1) % self.specialInstruments.length; var instrumentId = self.specialInstruments[self.specialInstrumentIndex]; // Only allow Blank or unused if (instrumentId === 'Blank' || !usedSpecialInstruments[instrumentId]) { found = true; // Mark as used if not Blank if (instrumentId !== 'Blank') { usedSpecialInstruments[instrumentId] = self; } // Slightly decrease the size of all special images for dots 21-25 var scaleX = 0.85; var scaleY = 0.85; if (instrumentId === 'Harmony') { scaleX = 1.45; scaleY = 1.45; } // Move Khalida or Harmony image up by 10 pixels, move KJ down by 5 pixels var extraY = 0; if (instrumentId === 'Khalida' || instrumentId === 'Harmony') { extraY = -10; } if (instrumentId === 'KJ') { extraY = 5; } self.currentInstrument = self.attachAsset(instrumentId, { anchorX: 0.5, anchorY: 0.5, scaleX: scaleX, scaleY: scaleY, y: extraY }); break; } } while (self.specialInstrumentIndex !== startIndex); // If no available instrument found, stay on current (shouldn't happen) if (!found) { self.specialInstrumentIndex = startIndex; } }; // Touch/click handler self.down = function (x, y, obj) { // Only cycle instruments for dots 1-5 (first row) if (self.gridY === 0) { self.cycleInstrument(); } // Dots 21-25 (bottom row, gridY === 4, gridX 0-4) else if (self.gridY === 4) { self.cycleSpecialInstrument(); } // Dots 16-20 (row 4, gridY === 3, gridX 0-4) else if (self.gridY === 3) { // Animal images to cycle through if (!self.animalImages) { self.animalImages = ['Blank', 'Cat', 'Dog', 'Fish', 'Frog', 'Turtle']; self.animalIndex = 0; } // Setup usedAnimalImages global tracker if not present if (typeof usedAnimalImages === "undefined") { usedAnimalImages = {}; } // Remove current animal image if exists and update usedAnimalImages if (self.currentInstrument) { if (typeof self.animalIndex === "number") { var prevAnimalId = self.animalImages[self.animalIndex]; if (prevAnimalId !== 'Blank' && usedAnimalImages[prevAnimalId] === self) { delete usedAnimalImages[prevAnimalId]; } } self.removeChild(self.currentInstrument); self.currentInstrument = null; } // Cycle to next available animal image (no duplicates except Blank) var startIndex = typeof self.animalIndex === "number" ? self.animalIndex : 0; var found = false; var tries = 0; do { self.animalIndex = (typeof self.animalIndex === "number" ? self.animalIndex : 0) + 1; if (self.animalIndex >= self.animalImages.length) self.animalIndex = 0; var animalId = self.animalImages[self.animalIndex]; // Only allow Blank or unused if (animalId === 'Blank' || !usedAnimalImages[animalId]) { found = true; // Mark as used if not Blank if (animalId !== 'Blank') { usedAnimalImages[animalId] = self; } self.currentInstrument = self.attachAsset(animalId, { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); break; } tries++; } while (self.animalIndex !== startIndex && tries < self.animalImages.length + 1); // If no available animal found, stay on current (shouldn't happen) if (!found) { self.animalIndex = startIndex; } } // Dots 6-10 (row 2, gridY === 1, gridX 0-4) else if (self.gridY === 1) { // Food images to cycle through if (!self.foodImages) { self.foodImages = ['Blank', 'Pizza', 'Chips', 'Icecream', 'Donut', 'Spaghetti']; self.foodIndex = 0; } // Setup usedFoodImages global tracker if not present if (typeof usedFoodImages === "undefined") { usedFoodImages = {}; } // Remove current food image if exists and update usedFoodImages if (self.currentInstrument) { if (typeof self.foodIndex === "number") { var prevFoodId = self.foodImages[self.foodIndex]; if (prevFoodId !== 'Blank' && usedFoodImages[prevFoodId] === self) { delete usedFoodImages[prevFoodId]; } } self.removeChild(self.currentInstrument); self.currentInstrument = null; } // Cycle to next available food image (no duplicates except Blank) var startFoodIndex = typeof self.foodIndex === "number" ? self.foodIndex : 0; var foundFood = false; var foodTries = 0; do { self.foodIndex = (typeof self.foodIndex === "number" ? self.foodIndex : 0) + 1; if (self.foodIndex >= self.foodImages.length) self.foodIndex = 0; var foodId = self.foodImages[self.foodIndex]; // Only allow Blank or unused if (foodId === 'Blank' || !usedFoodImages[foodId]) { foundFood = true; // Mark as used if not Blank if (foodId !== 'Blank') { usedFoodImages[foodId] = self; } self.currentInstrument = self.attachAsset(foodId, { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); break; } foodTries++; } while (self.foodIndex !== startFoodIndex && foodTries < self.foodImages.length + 1); // If no available food found, stay on current (shouldn't happen) if (!foundFood) { self.foodIndex = startFoodIndex; } } else if (self.gridY === 2) { // Toy images to cycle through if (!self.toyImages) { self.toyImages = ['Blank', 'Lego', 'Dolls', 'Basketball', 'Videogame', 'Plushtoy']; self.toyIndex = 0; } // Setup usedToyImages global tracker if not present if (typeof usedToyImages === "undefined") { usedToyImages = {}; } // Remove current toy image if exists and update usedToyImages if (self.currentInstrument) { if (typeof self.toyIndex === "number") { var prevToyId = self.toyImages[self.toyIndex]; if (prevToyId !== 'Blank' && usedToyImages[prevToyId] === self) { delete usedToyImages[prevToyId]; } } self.removeChild(self.currentInstrument); self.currentInstrument = null; } // Cycle to next available toy image (no duplicates except Blank) var startToyIndex = typeof self.toyIndex === "number" ? self.toyIndex : 0; var foundToy = false; var toyTries = 0; do { self.toyIndex = (typeof self.toyIndex === "number" ? self.toyIndex : 0) + 1; if (self.toyIndex >= self.toyImages.length) self.toyIndex = 0; var toyId = self.toyImages[self.toyIndex]; // Only allow Blank or unused if (toyId === 'Blank' || !usedToyImages[toyId]) { foundToy = true; // Mark as used if not Blank if (toyId !== 'Blank') { usedToyImages[toyId] = self; } self.currentInstrument = self.attachAsset(toyId, { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); break; } toyTries++; } while (self.toyIndex !== startToyIndex && toyTries < self.toyImages.length + 1); // If no available toy found, stay on current (shouldn't happen) if (!foundToy) { self.toyIndex = startToyIndex; } } self.toggle(); // Update clues with strikethrough after changing dot if (typeof updateCluesWithStrikethrough === 'function') { updateCluesWithStrikethrough(); } }; // Initialize dot as inactive // Initialize with blank instrument self.currentInstrument = self.attachAsset('Blank', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); return self; }); // Location class for managing a location in the game var Location = Container.expand(function () { var self = Container.call(this); // Example: add a background image to the location (replace 'Street' with your location asset if needed) var bg = self.attachAsset('Street', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Example: location name self.name = "Default Location"; // Example: method to set location name self.setName = function (newName) { self.name = newName; }; // Example: update method for per-frame logic self.update = function () { // Add per-frame logic for the location here }; return self; }); // Puzzle class for managing a puzzle element in the game var Puzzle = Container.expand(function () { var self = Container.call(this); // Add a 4x5 asset to the puzzle and scale it to be exactly 2048 wide var targetWidth = 2048; var assetWidth = 1000; var scale = targetWidth / assetWidth; // Center horizontally, align to top var puzzleImage = self.attachAsset('4x5', { anchorX: 0.5, anchorY: 0, x: 2048 / 2, y: 0, scaleX: scale, scaleY: scale }); // Add story asset at the bottom of the screen var storyAsset = self.attachAsset('Story', { anchorX: 0.5, anchorY: 1, x: 2048 / 2, y: 2732 - 50, // Position at bottom of screen with padding scaleX: 0.0625, // Scale down from 32768 to 2048 width (2048/32768) scaleY: 0.0625 // Maintain aspect ratio }); // Add clues text directly on story asset var cluesText = new Text2('CLUES TO SOLVE THE PUZZLE:\n\n• Row 1 (Music): 1=Drum, 2=Harp, 3=Saxophone, 4=Flute, 5=Guitar\n• Row 2 (Food): 6=Spaghetti, 7=Donut, 8=Chips, 9=Icecream, 10=Pizza\n• Row 3 (Toys): 11=Basketball, 12=Dolls, 13=Lego, 14=Videogame, 15=Plushtoy\n• Row 4 (Animals): 16=Fish, 17=Turtle, 18=Frog, 19=Cat, 20=Dog\n• Row 5 (Family): 21=KJ, 22=Khalida, 23=Sapphire, 24=Harmony, 25=PJ\n\nClick any dot to cycle through options!\nMatch all items to their correct positions to win!', { size: 52, fill: 0x000000, align: 'center', font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma" }); cluesText.anchor.set(0.5, 0.5); cluesText.x = 2048 / 2; cluesText.y = 2732 - 50 - storyAsset.height * 0.0625 / 2; // Track which clues are showing (basic or detailed) self.showingBasicClues = true; // Make clues text clickable to show more detailed clues cluesText.down = function (x, y, obj) { if (self.showingBasicClues) { // Show detailed clues cluesText.setText('DETAILED CLUES TO SOLVE THE PUZZLE:\n\n• Row 1 (Music): Look for musical instruments\n 1=Drum (percussion), 2=Harp (strings), 3=Saxophone (brass),\n 4=Flute (woodwind), 5=Guitar (strings)\n• Row 2 (Food): Delicious treats and meals\n 6=Spaghetti (Italian pasta), 7=Donut (sweet pastry),\n 8=Chips (crispy snack), 9=Icecream (frozen dessert), 10=Pizza (Italian dish)\n• Row 3 (Toys): Fun playthings for children\n 11=Basketball (sports ball), 12=Dolls (figurines),\n 13=Lego (building blocks), 14=Videogame (electronic entertainment), 15=Plushtoy (soft toy)\n• Row 4 (Animals): Living creatures\n 16=Fish (aquatic animal), 17=Turtle (reptile with shell),\n 18=Frog (amphibian), 19=Cat (feline pet), 20=Dog (canine companion)\n• Row 5 (Family): Members of the household\n 21=KJ (family member), 22=Khalida (family member),\n 23=Sapphire (family member), 24=Harmony (family member), 25=PJ (family member)\n\nClick here again for basic clues!'); self.showingBasicClues = false; } else { // Show basic clues cluesText.setText('CLUES TO SOLVE THE PUZZLE:\n\n• Row 1 (Music): 1=Drum, 2=Harp, 3=Saxophone, 4=Flute, 5=Guitar\n• Row 2 (Food): 6=Spaghetti, 7=Donut, 8=Chips, 9=Icecream, 10=Pizza\n• Row 3 (Toys): 11=Basketball, 12=Dolls, 13=Lego, 14=Videogame, 15=Plushtoy\n• Row 4 (Animals): 16=Fish, 17=Turtle, 18=Frog, 19=Cat, 20=Dog\n• Row 5 (Family): 21=KJ, 22=Khalida, 23=Sapphire, 24=Harmony, 25=PJ\n\nClick any dot to cycle through options!\nMatch all items to their correct positions to win!\n\nClick here for more detailed clues!'); self.showingBasicClues = true; } }; self.addChild(cluesText); // Create 25 dots in a 5x5 grid self.dots = []; var gridSize = 5; var dotSpacing = targetWidth / (gridSize + 1); // Distribute dots evenly across the width var gridHeight = puzzleImage.height * scale; var verticalSpacing = gridHeight / (gridSize + 1); for (var row = 0; row < gridSize; row++) { for (var col = 0; col < gridSize; col++) { var dot = new Dot(); dot.gridX = col; dot.gridY = row; // Initialize all indices to 0 for consistent reset state dot.instrumentIndex = 0; dot.specialInstrumentIndex = 0; dot.animalIndex = 0; dot.foodIndex = 0; dot.toyIndex = 0; // Position dots over the 4x5 asset dot.x = (col + 1) * dotSpacing; dot.y = (row + 1) * verticalSpacing; self.dots.push(dot); self.addChild(dot); } } // Example: puzzle state self.isSolved = false; // Method to check if puzzle is solved according to target solution self.checkSolved = function () { // Target solution mapping: dot index -> expected image var targetSolution = { 0: 'Drum', // Dot 1 (row 1, col 1) 1: 'Harp', // Dot 2 (row 1, col 2) 2: 'Saxophone', // Dot 3 (row 1, col 3) 3: 'Flute', // Dot 4 (row 1, col 4) 4: 'Gutair', // Dot 5 (row 1, col 5) 5: 'Spaghetti', // Dot 6 (row 2, col 1) 6: 'Donut', // Dot 7 (row 2, col 2) 7: 'Chips', // Dot 8 (row 2, col 3) 8: 'Icecream', // Dot 9 (row 2, col 4) 9: 'Pizza', // Dot 10 (row 2, col 5) 10: 'Basketball', // Dot 11 (row 3, col 1) 11: 'Dolls', // Dot 12 (row 3, col 2) 12: 'Lego', // Dot 13 (row 3, col 3) 13: 'Videogame', // Dot 14 (row 3, col 4) 14: 'Plushtoy', // Dot 15 (row 3, col 5) 15: 'Fish', // Dot 16 (row 4, col 1) 16: 'Turtle', // Dot 17 (row 4, col 2) 17: 'Frog', // Dot 18 (row 4, col 3) 18: 'Cat', // Dot 19 (row 4, col 4) 19: 'Dog', // Dot 20 (row 4, col 5) 20: 'KJ', // Dot 21 (row 5, col 1) 21: 'Khalida', // Dot 22 (row 5, col 2) 22: 'Sapphire', // Dot 23 (row 5, col 3) 23: 'Harmony', // Dot 24 (row 5, col 4) 24: 'PJ' // Dot 25 (row 5, col 5) }; // Check if all dots match the target solution var allCorrect = true; for (var i = 0; i < self.dots.length; i++) { var dot = self.dots[i]; var expectedImage = targetSolution[i]; // Get current image of the dot based on its row and current index var currentImage = 'Blank'; var row = dot.gridY; if (row === 0 && dot.instruments) { // Row 1: Music instruments currentImage = dot.instruments[dot.instrumentIndex]; } else if (row === 1 && dot.foodImages) { // Row 2: Food currentImage = dot.foodImages[dot.foodIndex]; } else if (row === 2 && dot.toyImages) { // Row 3: Toys currentImage = dot.toyImages[dot.toyIndex]; } else if (row === 3 && dot.animalImages) { // Row 4: Animals currentImage = dot.animalImages[dot.animalIndex]; } else if (row === 4 && dot.specialInstruments) { // Row 5: Family currentImage = dot.specialInstruments[dot.specialInstrumentIndex]; } // Check if current image matches expected if (currentImage !== expectedImage) { allCorrect = false; break; } } // Update solved state only - win display handled by green tick if (allCorrect && !self.isSolved) { self.isSolved = true; } else if (!allCorrect && self.isSolved) { self.isSolved = false; } }; // Example: update method for per-frame logic self.update = function () { // Add per-frame puzzle logic here // For example, check for completion self.checkSolved(); }; return self; }); // Scene class for managing a scene in the game var Scene = Container.expand(function () { var self = Container.call(this); // Example: add a background image to the scene // (Replace 'Dream' with the desired asset for your scene) var bg = self.attachAsset('Dream', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Add any additional scene setup here // Scene update method (called every tick if attached to game) self.update = function () { // Add per-frame logic for the scene here }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Track which instruments are currently in use var usedInstruments = {}; // Add Puzzle to the game when it starts var puzzle = new Puzzle(); game.addChild(puzzle); // Add green tick to bottom right corner var greenTick = LK.getAsset('Greentick', { anchorX: 1.0, anchorY: 1.0, x: 2048 - 50, y: 2732 - 50, scaleX: 0.8, scaleY: 0.8 }); game.addChild(greenTick); // Add info button to bottom left corner var infoButton = LK.getAsset('Info', { anchorX: 0.0, anchorY: 1.0, x: 50, y: 2732 - 50, scaleX: 1.5, scaleY: 1.5 }); game.addChild(infoButton); // Variable to track instructions screen var instructionsScreen = null; // Make info button clickable to show instructions screen infoButton.down = function (x, y, obj) { // If instructions screen is already showing, hide it if (instructionsScreen && instructionsScreen.parent) { instructionsScreen.parent.removeChild(instructionsScreen); instructionsScreen = null; return; } // Create instructions screen container instructionsScreen = new Container(); // Add semi-transparent background var instructionsBg = LK.getAsset('Street', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 20.48, scaleY: 27.32, alpha: 0.9 }); instructionsScreen.addChild(instructionsBg); // Add instructions title var instructionsTitle = new Text2('HOW TO PLAY', { size: 110, fill: 0xffffff, align: 'center', font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma" }); instructionsTitle.anchor.set(0.5, 0.5); instructionsTitle.x = 2048 / 2; instructionsTitle.y = 2732 / 2 - 650; instructionsScreen.addChild(instructionsTitle); // Add a visual example row (music row) with dots and images var exampleY = 2732 / 2 - 400; var exampleSpacing = 260; var exampleStartX = 2048 / 2 - 2 * exampleSpacing; var exampleImages = ['Drum', 'Harp', 'Saxophone', 'Flute', 'Gutair']; var exampleDots = []; for (var i = 0; i < 5; i++) { // Dot background var dotBg = LK.getAsset('Street', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5, x: exampleStartX + i * exampleSpacing, y: exampleY }); instructionsScreen.addChild(dotBg); // Instrument image var img = LK.getAsset(exampleImages[i], { anchorX: 0.5, anchorY: 0.5, x: exampleStartX + i * exampleSpacing, y: exampleY }); instructionsScreen.addChild(img); // Dot number var num = new Text2('' + (i + 1), { size: 48, fill: 0x222222, align: 'center', font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma" }); num.anchor.set(0.5, 0.5); num.x = exampleStartX + i * exampleSpacing; num.y = exampleY + 110; instructionsScreen.addChild(num); exampleDots.push({ dotBg: dotBg, img: img, num: num }); } // Add a hand icon to show clicking (using 'Info' asset as a placeholder for a hand) var handIcon = LK.getAsset('Info', { anchorX: 0.5, anchorY: 0.5, x: exampleStartX + 0 * exampleSpacing, y: exampleY + 180, scaleX: 1.2, scaleY: 1.2, alpha: 0.7 }); instructionsScreen.addChild(handIcon); // Add a text label under the example row var exampleLabel = new Text2('Tap a dot to cycle through options', { size: 60, fill: 0xffffff, align: 'center', font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma" }); exampleLabel.anchor.set(0.5, 0.5); exampleLabel.x = 2048 / 2; exampleLabel.y = exampleY + 260; instructionsScreen.addChild(exampleLabel); // Add a short text summary below the example var summaryText = new Text2('Match each row with the correct items!\nWhen you finish, tap the green tick to check your solution.\n\nTap anywhere to close this screen.', { size: 70, fill: 0xffffff, align: 'center', font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma" }); summaryText.anchor.set(0.5, 0.5); summaryText.x = 2048 / 2; summaryText.y = 2732 / 2 + 100; instructionsScreen.addChild(summaryText); // Make the entire instructions screen clickable to close instructionsScreen.down = function (x, y, obj) { if (instructionsScreen && instructionsScreen.parent) { instructionsScreen.parent.removeChild(instructionsScreen); instructionsScreen = null; } }; // Add instructions screen to game game.addChild(instructionsScreen); }; // Helper to show/hide info button function setInfoButtonVisible(visible) { if (infoButton && infoButton.parent) { infoButton.visible = !!visible; } } // Function to update clues text with strikethrough for solved items function updateCluesWithStrikethrough() { if (!puzzle || !puzzle.dots) return; // Get current state of all dots var dotStates = []; for (var i = 0; i < puzzle.dots.length; i++) { var dot = puzzle.dots[i]; var currentImage = 'Blank'; var row = dot.gridY; if (row === 0 && dot.instruments) { currentImage = dot.instruments[dot.instrumentIndex]; } else if (row === 1 && dot.foodImages) { currentImage = dot.foodImages[dot.foodIndex]; } else if (row === 2 && dot.toyImages) { currentImage = dot.toyImages[dot.toyIndex]; } else if (row === 3 && dot.animalImages) { currentImage = dot.animalImages[dot.animalIndex]; } else if (row === 4 && dot.specialInstruments) { currentImage = dot.specialInstruments[dot.specialInstrumentIndex]; } dotStates.push(currentImage); } // Target solution mapping var targetSolution = { 0: 'Drum', 1: 'Harp', 2: 'Saxophone', 3: 'Flute', 4: 'Gutair', 5: 'Spaghetti', 6: 'Donut', 7: 'Chips', 8: 'Icecream', 9: 'Pizza', 10: 'Basketball', 11: 'Dolls', 12: 'Lego', 13: 'Videogame', 14: 'Plushtoy', 15: 'Fish', 16: 'Turtle', 17: 'Frog', 18: 'Cat', 19: 'Dog', 20: 'KJ', 21: 'Khalida', 22: 'Sapphire', 23: 'Harmony', 24: 'PJ' }; // Check which rows are completely solved var rowSolved = [false, false, false, false, false]; for (var row = 0; row < 5; row++) { var allCorrectInRow = true; for (var col = 0; col < 5; col++) { var dotIndex = row * 5 + col; if (dotStates[dotIndex] !== targetSolution[dotIndex]) { allCorrectInRow = false; break; } } rowSolved[row] = allCorrectInRow; } // Update clues text with strikethrough for solved rows var cluesText = ''; if (puzzle.showingBasicClues) { cluesText = 'CLUES TO SOLVE THE PUZZLE:\n\n'; cluesText += (rowSolved[0] ? '<s>• Row 1 (Music): 1=Drum, 2=Harp, 3=Saxophone, 4=Flute, 5=Guitar</s>' : '• Row 1 (Music): 1=Drum, 2=Harp, 3=Saxophone, 4=Flute, 5=Guitar') + '\n'; cluesText += (rowSolved[1] ? '<s>• Row 2 (Food): 6=Spaghetti, 7=Donut, 8=Chips, 9=Icecream, 10=Pizza</s>' : '• Row 2 (Food): 6=Spaghetti, 7=Donut, 8=Chips, 9=Icecream, 10=Pizza') + '\n'; cluesText += (rowSolved[2] ? '<s>• Row 3 (Toys): 11=Basketball, 12=Dolls, 13=Lego, 14=Videogame, 15=Plushtoy</s>' : '• Row 3 (Toys): 11=Basketball, 12=Dolls, 13=Lego, 14=Videogame, 15=Plushtoy') + '\n'; cluesText += (rowSolved[3] ? '<s>• Row 4 (Animals): 16=Fish, 17=Turtle, 18=Frog, 19=Cat, 20=Dog</s>' : '• Row 4 (Animals): 16=Fish, 17=Turtle, 18=Frog, 19=Cat, 20=Dog') + '\n'; cluesText += (rowSolved[4] ? '<s>• Row 5 (Family): 21=KJ, 22=Khalida, 23=Sapphire, 24=Harmony, 25=PJ</s>' : '• Row 5 (Family): 21=KJ, 22=Khalida, 23=Sapphire, 24=Harmony, 25=PJ') + '\n'; cluesText += '\nClick any dot to cycle through options!\nMatch all items to their correct positions to win!\n\nClick here for more detailed clues!'; } else { cluesText = 'DETAILED CLUES TO SOLVE THE PUZZLE:\n\n'; cluesText += (rowSolved[0] ? '<s>• Row 1 (Music): Look for musical instruments\n 1=Drum (percussion), 2=Harp (strings), 3=Saxophone (brass),\n 4=Flute (woodwind), 5=Guitar (strings)</s>' : '• Row 1 (Music): Look for musical instruments\n 1=Drum (percussion), 2=Harp (strings), 3=Saxophone (brass),\n 4=Flute (woodwind), 5=Guitar (strings)') + '\n'; cluesText += (rowSolved[1] ? '<s>• Row 2 (Food): Delicious treats and meals\n 6=Spaghetti (Italian pasta), 7=Donut (sweet pastry),\n 8=Chips (crispy snack), 9=Icecream (frozen dessert), 10=Pizza (Italian dish)</s>' : '• Row 2 (Food): Delicious treats and meals\n 6=Spaghetti (Italian pasta), 7=Donut (sweet pastry),\n 8=Chips (crispy snack), 9=Icecream (frozen dessert), 10=Pizza (Italian dish)') + '\n'; cluesText += (rowSolved[2] ? '<s>• Row 3 (Toys): Fun playthings for children\n 11=Basketball (sports ball), 12=Dolls (figurines),\n 13=Lego (building blocks), 14=Videogame (electronic entertainment), 15=Plushtoy (soft toy)</s>' : '• Row 3 (Toys): Fun playthings for children\n 11=Basketball (sports ball), 12=Dolls (figurines),\n 13=Lego (building blocks), 14=Videogame (electronic entertainment), 15=Plushtoy (soft toy)') + '\n'; cluesText += (rowSolved[3] ? '<s>• Row 4 (Animals): Living creatures\n 16=Fish (aquatic animal), 17=Turtle (reptile with shell),\n 18=Frog (amphibian), 19=Cat (feline pet), 20=Dog (canine companion)</s>' : '• Row 4 (Animals): Living creatures\n 16=Fish (aquatic animal), 17=Turtle (reptile with shell),\n 18=Frog (amphibian), 19=Cat (feline pet), 20=Dog (canine companion)') + '\n'; cluesText += (rowSolved[4] ? '<s>• Row 5 (Family): Members of the household\n 21=KJ (family member), 22=Khalida (family member),\n 23=Sapphire (family member), 24=Harmony (family member), 25=PJ (family member)</s>' : '• Row 5 (Family): Members of the household\n 21=KJ (family member), 22=Khalida (family member),\n 23=Sapphire (family member), 24=Harmony (family member), 25=PJ (family member)') + '\n'; cluesText += '\nClick here again for basic clues!'; } // Find and update the clues text in puzzle for (var i = 0; i < puzzle.children.length; i++) { var child = puzzle.children[i]; if (child && child.setText && typeof child.setText === 'function') { child.setText(cluesText); break; } } } // Make green tick clickable to enter puzzle attempt greenTick.down = function (x, y, obj) { if (puzzle && typeof puzzle.checkSolved === "function") { // Run the check puzzle.checkSolved(); // If solved, show endpuzzletwo scene if (puzzle.isSolved) { // Remove the puzzle and green tick from the game if (puzzle.parent) puzzle.parent.removeChild(puzzle); if (greenTick.parent) greenTick.parent.removeChild(greenTick); // Hide info button when showing endpuzzletwo setInfoButtonVisible(false); // Show endpuzzletwo asset centered on screen var endpuzzletwo = LK.getAsset('Endpuzzletwo', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2.2, scaleY: 2.2 }); game.addChild(endpuzzletwo); // After 3 seconds, swap to correct scene with correct word under the correct image LK.setTimeout(function () { if (endpuzzletwo.parent) endpuzzletwo.parent.removeChild(endpuzzletwo); // Show Correct scene (centered) var correctScene = LK.getAsset('Correct', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2.2, scaleY: 2.2 }); game.addChild(correctScene); // No winning image displayed - just show the correct word // Show the correct word asset at the bottom of the screen var correctWord = LK.getAsset('Correctword', { anchorX: 0.5, anchorY: 1.0, x: 2048 / 2, y: 2732 - 50, scaleX: 2.2, scaleY: 2.2 }); game.addChild(correctWord); }, 3000); } else { // If not solved, show endgame1 scene if (puzzle.parent) puzzle.parent.removeChild(puzzle); if (greenTick.parent) greenTick.parent.removeChild(greenTick); // Hide info button when showing endgame1 setInfoButtonVisible(false); // Show endgame1 asset centered on screen var endgame1 = LK.getAsset('Endpuzzleone', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2.2, scaleY: 2.2 }); game.addChild(endgame1); // After 3 seconds, swap to incorrect scene with incorrect word under the incorrect image LK.setTimeout(function () { if (endgame1.parent) endgame1.parent.removeChild(endgame1); // Show Incorrect scene (centered) var incorrectScene = LK.getAsset('Incorrect', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 2.2, scaleY: 2.2 }); game.addChild(incorrectScene); // Find the first incorrect dot and its expected word var targetSolution = { 0: 'Drum', 1: 'Harp', 2: 'Saxophone', 3: 'Flute', 4: 'Gutair', 5: 'Spaghetti', 6: 'Donut', 7: 'Chips', 8: 'Icecream', 9: 'Pizza', 10: 'Basketball', 11: 'Dolls', 12: 'Lego', 13: 'Videogame', 14: 'Plushtoy', 15: 'Fish', 16: 'Turtle', 17: 'Frog', 18: 'Cat', 19: 'Dog', 20: 'KJ', 21: 'Khalida', 22: 'Sapphire', 23: 'Harmony', 24: 'PJ' }; var firstWrongIdx = -1; var wrongActual = ''; var wrongExpected = ''; for (var i = 0; i < puzzle.dots.length; i++) { var dot = puzzle.dots[i]; var expected = targetSolution[i]; var actual = 'Blank'; var row = dot.gridY; // Get current image based on row and index if (row === 0 && dot.instruments) { actual = dot.instruments[dot.instrumentIndex]; } else if (row === 1 && dot.foodImages) { actual = dot.foodImages[dot.foodIndex]; } else if (row === 2 && dot.toyImages) { actual = dot.toyImages[dot.toyIndex]; } else if (row === 3 && dot.animalImages) { actual = dot.animalImages[dot.animalIndex]; } else if (row === 4 && dot.specialInstruments) { actual = dot.specialInstruments[dot.specialInstrumentIndex]; } if (actual !== expected) { firstWrongIdx = i; wrongActual = actual; wrongExpected = expected; break; } } // If found, show the incorrect image and word under it if (firstWrongIdx !== -1) { var wrongImg = null; var imgY = 2732 / 2 + 100; var wordY = imgY; // Only show the image if it's not 'Blank' if (wrongActual !== 'Blank') { wrongImg = LK.getAsset(wrongActual, { anchorX: 0.5, anchorY: 1.0, x: 2048 / 2, y: imgY }); game.addChild(wrongImg); wordY = 2732 / 2 + 120 + (wrongImg.height || 100); // 20px below image } else { // If blank, just show the word lower down wordY = 2732 / 2 + 120; } // Show the incorrect word asset at the bottom of the screen var incorrectWord = LK.getAsset('Incorrectword', { anchorX: 0.5, anchorY: 1.0, x: 2048 / 2, y: 2732 - 50, // 50px padding from bottom scaleX: 2.2, scaleY: 2.2 }); game.addChild(incorrectWord); // Add retry button below the incorrect image/word var retryBtnY = 2732 - 50 - incorrectWord.height * 2.2 - 40; // 40px above incorrect word var retryBtn = LK.getAsset('Retry', { anchorX: 0.5, anchorY: 1.0, x: 2048 / 2, y: retryBtnY, scaleX: 1.8, scaleY: 1.8 }); game.addChild(retryBtn); // Retry button handler: remove incorrect scene and restart puzzle retryBtn.down = function (x, y, obj) { // Remove all incorrect scene assets if (incorrectScene && incorrectScene.parent) incorrectScene.parent.removeChild(incorrectScene); if (wrongImg && wrongImg.parent) wrongImg.parent.removeChild(wrongImg); if (incorrectWord && incorrectWord.parent) incorrectWord.parent.removeChild(incorrectWord); if (retryBtn && retryBtn.parent) retryBtn.parent.removeChild(retryBtn); // Reset all used image trackers so dots can be reused usedInstruments = {}; usedSpecialInstruments = {}; usedAnimalImages = {}; usedFoodImages = {}; usedToyImages = {}; // Re-add puzzle and green tick puzzle = new Puzzle(); game.addChild(puzzle); game.addChild(greenTick); // Re-add info button after story asset if (infoButton && infoButton.parent) { infoButton.parent.removeChild(infoButton); } // Find the story asset in the puzzle and add infoButton after it var storyAssetIdx = -1; for (var i = 0; i < puzzle.children.length; i++) { var child = puzzle.children[i]; if (child && child.assetId === 'Story') { storyAssetIdx = i; break; } } if (storyAssetIdx !== -1) { // Insert infoButton after story asset if (puzzle.children.length > storyAssetIdx + 1) { puzzle.addChildAt(infoButton, storyAssetIdx + 1); } else { puzzle.addChild(infoButton); } } else { // Fallback: add to puzzle if not found puzzle.addChild(infoButton); } // Show info button again after retry setInfoButtonVisible(true); }; } }, 3000); } } }; ;
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Character class for main character gameplay elements
var Character = Container.expand(function () {
var self = Container.call(this);
// Example: add a character sprite (replace 'Sprite' with your character asset if needed)
var characterSprite = self.attachAsset('Sprite', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Example: character name
self.name = "Lyra";
// Example: character state
self.isActive = true;
// Example: method to set character name
self.setName = function (newName) {
self.name = newName;
};
// Example: method to activate/deactivate character
self.setActive = function (active) {
self.isActive = !!active;
};
// Example: update method for per-frame logic
self.update = function () {
// Add per-frame logic for the character here
};
return self;
});
// Dot class for interactive dots in the puzzle
var Dot = Container.expand(function () {
var self = Container.call(this);
// Create a visual representation for the dot
var dotGraphics = self.attachAsset('Street', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.8,
alpha: 0
});
// Dot properties
self.isActive = false;
self.gridX = 0;
self.gridY = 0;
self.instrumentIndex = 0;
self.currentInstrument = null;
// Array of instrument image IDs for first row (dots 1-5)
self.instruments = ['Blank', 'Saxophone', 'Drum', 'Gutair', 'Harp', 'Flute'];
// Array of image IDs for dots 21-25 (bottom row)
self.specialInstruments = ['Blank', 'PJ', 'KJ', 'Harmony', 'Khalida', 'Sapphire'];
// Method to toggle dot state
self.toggle = function () {
self.isActive = !self.isActive;
};
// Method to cycle through instruments for first row (dots 1-5)
self.cycleInstrument = function () {
// Remove current instrument if it exists and free it from usedInstruments
if (self.currentInstrument) {
var currentInstrumentId = self.instruments[self.instrumentIndex];
if (currentInstrumentId !== 'Blank' && usedInstruments[currentInstrumentId] === self) {
delete usedInstruments[currentInstrumentId];
}
self.removeChild(self.currentInstrument);
self.currentInstrument = null;
}
// Find next available instrument
var startIndex = self.instrumentIndex;
var found = false;
do {
self.instrumentIndex = (self.instrumentIndex + 1) % self.instruments.length;
var instrumentId = self.instruments[self.instrumentIndex];
// Check if instrument is available (Blank is always available)
if (instrumentId === 'Blank' || !usedInstruments[instrumentId]) {
found = true;
// Mark non-blank instruments as used
if (instrumentId !== 'Blank') {
usedInstruments[instrumentId] = self;
}
// Create new instrument image
self.currentInstrument = self.attachAsset(instrumentId, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
break;
}
} while (self.instrumentIndex !== startIndex);
// If no available instrument found, stay on current (shouldn't happen with 6 instruments for 5 dots)
if (!found) {
self.instrumentIndex = startIndex;
}
};
// Method to cycle through special images for dots 21-25 (bottom row)
self.cycleSpecialInstrument = function () {
// Remove current instrument if it exists
if (self.currentInstrument) {
// Remove from usedSpecialInstruments if not Blank
if (typeof usedSpecialInstruments !== "undefined" && self.specialInstruments && typeof self.specialInstrumentIndex === "number") {
var prevId = self.specialInstruments[self.specialInstrumentIndex];
if (prevId !== 'Blank' && usedSpecialInstruments[prevId] === self) {
delete usedSpecialInstruments[prevId];
}
}
self.removeChild(self.currentInstrument);
self.currentInstrument = null;
}
// Find next available special instrument (no duplicates except Blank)
if (typeof usedSpecialInstruments === "undefined") {
usedSpecialInstruments = {};
}
if (typeof self.specialInstrumentIndex !== "number") self.specialInstrumentIndex = 0;
self.specialInstrumentIndex = typeof self.specialInstrumentIndex === "number" ? self.specialInstrumentIndex : 0;
var startIndex = self.specialInstrumentIndex;
var found = false;
do {
self.specialInstrumentIndex = (self.specialInstrumentIndex + 1) % self.specialInstruments.length;
var instrumentId = self.specialInstruments[self.specialInstrumentIndex];
// Only allow Blank or unused
if (instrumentId === 'Blank' || !usedSpecialInstruments[instrumentId]) {
found = true;
// Mark as used if not Blank
if (instrumentId !== 'Blank') {
usedSpecialInstruments[instrumentId] = self;
}
// Slightly decrease the size of all special images for dots 21-25
var scaleX = 0.85;
var scaleY = 0.85;
if (instrumentId === 'Harmony') {
scaleX = 1.45;
scaleY = 1.45;
}
// Move Khalida or Harmony image up by 10 pixels, move KJ down by 5 pixels
var extraY = 0;
if (instrumentId === 'Khalida' || instrumentId === 'Harmony') {
extraY = -10;
}
if (instrumentId === 'KJ') {
extraY = 5;
}
self.currentInstrument = self.attachAsset(instrumentId, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: scaleX,
scaleY: scaleY,
y: extraY
});
break;
}
} while (self.specialInstrumentIndex !== startIndex);
// If no available instrument found, stay on current (shouldn't happen)
if (!found) {
self.specialInstrumentIndex = startIndex;
}
};
// Touch/click handler
self.down = function (x, y, obj) {
// Only cycle instruments for dots 1-5 (first row)
if (self.gridY === 0) {
self.cycleInstrument();
}
// Dots 21-25 (bottom row, gridY === 4, gridX 0-4)
else if (self.gridY === 4) {
self.cycleSpecialInstrument();
}
// Dots 16-20 (row 4, gridY === 3, gridX 0-4)
else if (self.gridY === 3) {
// Animal images to cycle through
if (!self.animalImages) {
self.animalImages = ['Blank', 'Cat', 'Dog', 'Fish', 'Frog', 'Turtle'];
self.animalIndex = 0;
}
// Setup usedAnimalImages global tracker if not present
if (typeof usedAnimalImages === "undefined") {
usedAnimalImages = {};
}
// Remove current animal image if exists and update usedAnimalImages
if (self.currentInstrument) {
if (typeof self.animalIndex === "number") {
var prevAnimalId = self.animalImages[self.animalIndex];
if (prevAnimalId !== 'Blank' && usedAnimalImages[prevAnimalId] === self) {
delete usedAnimalImages[prevAnimalId];
}
}
self.removeChild(self.currentInstrument);
self.currentInstrument = null;
}
// Cycle to next available animal image (no duplicates except Blank)
var startIndex = typeof self.animalIndex === "number" ? self.animalIndex : 0;
var found = false;
var tries = 0;
do {
self.animalIndex = (typeof self.animalIndex === "number" ? self.animalIndex : 0) + 1;
if (self.animalIndex >= self.animalImages.length) self.animalIndex = 0;
var animalId = self.animalImages[self.animalIndex];
// Only allow Blank or unused
if (animalId === 'Blank' || !usedAnimalImages[animalId]) {
found = true;
// Mark as used if not Blank
if (animalId !== 'Blank') {
usedAnimalImages[animalId] = self;
}
self.currentInstrument = self.attachAsset(animalId, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
break;
}
tries++;
} while (self.animalIndex !== startIndex && tries < self.animalImages.length + 1);
// If no available animal found, stay on current (shouldn't happen)
if (!found) {
self.animalIndex = startIndex;
}
}
// Dots 6-10 (row 2, gridY === 1, gridX 0-4)
else if (self.gridY === 1) {
// Food images to cycle through
if (!self.foodImages) {
self.foodImages = ['Blank', 'Pizza', 'Chips', 'Icecream', 'Donut', 'Spaghetti'];
self.foodIndex = 0;
}
// Setup usedFoodImages global tracker if not present
if (typeof usedFoodImages === "undefined") {
usedFoodImages = {};
}
// Remove current food image if exists and update usedFoodImages
if (self.currentInstrument) {
if (typeof self.foodIndex === "number") {
var prevFoodId = self.foodImages[self.foodIndex];
if (prevFoodId !== 'Blank' && usedFoodImages[prevFoodId] === self) {
delete usedFoodImages[prevFoodId];
}
}
self.removeChild(self.currentInstrument);
self.currentInstrument = null;
}
// Cycle to next available food image (no duplicates except Blank)
var startFoodIndex = typeof self.foodIndex === "number" ? self.foodIndex : 0;
var foundFood = false;
var foodTries = 0;
do {
self.foodIndex = (typeof self.foodIndex === "number" ? self.foodIndex : 0) + 1;
if (self.foodIndex >= self.foodImages.length) self.foodIndex = 0;
var foodId = self.foodImages[self.foodIndex];
// Only allow Blank or unused
if (foodId === 'Blank' || !usedFoodImages[foodId]) {
foundFood = true;
// Mark as used if not Blank
if (foodId !== 'Blank') {
usedFoodImages[foodId] = self;
}
self.currentInstrument = self.attachAsset(foodId, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
break;
}
foodTries++;
} while (self.foodIndex !== startFoodIndex && foodTries < self.foodImages.length + 1);
// If no available food found, stay on current (shouldn't happen)
if (!foundFood) {
self.foodIndex = startFoodIndex;
}
} else if (self.gridY === 2) {
// Toy images to cycle through
if (!self.toyImages) {
self.toyImages = ['Blank', 'Lego', 'Dolls', 'Basketball', 'Videogame', 'Plushtoy'];
self.toyIndex = 0;
}
// Setup usedToyImages global tracker if not present
if (typeof usedToyImages === "undefined") {
usedToyImages = {};
}
// Remove current toy image if exists and update usedToyImages
if (self.currentInstrument) {
if (typeof self.toyIndex === "number") {
var prevToyId = self.toyImages[self.toyIndex];
if (prevToyId !== 'Blank' && usedToyImages[prevToyId] === self) {
delete usedToyImages[prevToyId];
}
}
self.removeChild(self.currentInstrument);
self.currentInstrument = null;
}
// Cycle to next available toy image (no duplicates except Blank)
var startToyIndex = typeof self.toyIndex === "number" ? self.toyIndex : 0;
var foundToy = false;
var toyTries = 0;
do {
self.toyIndex = (typeof self.toyIndex === "number" ? self.toyIndex : 0) + 1;
if (self.toyIndex >= self.toyImages.length) self.toyIndex = 0;
var toyId = self.toyImages[self.toyIndex];
// Only allow Blank or unused
if (toyId === 'Blank' || !usedToyImages[toyId]) {
foundToy = true;
// Mark as used if not Blank
if (toyId !== 'Blank') {
usedToyImages[toyId] = self;
}
self.currentInstrument = self.attachAsset(toyId, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
break;
}
toyTries++;
} while (self.toyIndex !== startToyIndex && toyTries < self.toyImages.length + 1);
// If no available toy found, stay on current (shouldn't happen)
if (!foundToy) {
self.toyIndex = startToyIndex;
}
}
self.toggle();
// Update clues with strikethrough after changing dot
if (typeof updateCluesWithStrikethrough === 'function') {
updateCluesWithStrikethrough();
}
};
// Initialize dot as inactive
// Initialize with blank instrument
self.currentInstrument = self.attachAsset('Blank', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.0,
scaleY: 1.0
});
return self;
});
// Location class for managing a location in the game
var Location = Container.expand(function () {
var self = Container.call(this);
// Example: add a background image to the location (replace 'Street' with your location asset if needed)
var bg = self.attachAsset('Street', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Example: location name
self.name = "Default Location";
// Example: method to set location name
self.setName = function (newName) {
self.name = newName;
};
// Example: update method for per-frame logic
self.update = function () {
// Add per-frame logic for the location here
};
return self;
});
// Puzzle class for managing a puzzle element in the game
var Puzzle = Container.expand(function () {
var self = Container.call(this);
// Add a 4x5 asset to the puzzle and scale it to be exactly 2048 wide
var targetWidth = 2048;
var assetWidth = 1000;
var scale = targetWidth / assetWidth;
// Center horizontally, align to top
var puzzleImage = self.attachAsset('4x5', {
anchorX: 0.5,
anchorY: 0,
x: 2048 / 2,
y: 0,
scaleX: scale,
scaleY: scale
});
// Add story asset at the bottom of the screen
var storyAsset = self.attachAsset('Story', {
anchorX: 0.5,
anchorY: 1,
x: 2048 / 2,
y: 2732 - 50,
// Position at bottom of screen with padding
scaleX: 0.0625,
// Scale down from 32768 to 2048 width (2048/32768)
scaleY: 0.0625 // Maintain aspect ratio
});
// Add clues text directly on story asset
var cluesText = new Text2('CLUES TO SOLVE THE PUZZLE:\n\n• Row 1 (Music): 1=Drum, 2=Harp, 3=Saxophone, 4=Flute, 5=Guitar\n• Row 2 (Food): 6=Spaghetti, 7=Donut, 8=Chips, 9=Icecream, 10=Pizza\n• Row 3 (Toys): 11=Basketball, 12=Dolls, 13=Lego, 14=Videogame, 15=Plushtoy\n• Row 4 (Animals): 16=Fish, 17=Turtle, 18=Frog, 19=Cat, 20=Dog\n• Row 5 (Family): 21=KJ, 22=Khalida, 23=Sapphire, 24=Harmony, 25=PJ\n\nClick any dot to cycle through options!\nMatch all items to their correct positions to win!', {
size: 52,
fill: 0x000000,
align: 'center',
font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma"
});
cluesText.anchor.set(0.5, 0.5);
cluesText.x = 2048 / 2;
cluesText.y = 2732 - 50 - storyAsset.height * 0.0625 / 2;
// Track which clues are showing (basic or detailed)
self.showingBasicClues = true;
// Make clues text clickable to show more detailed clues
cluesText.down = function (x, y, obj) {
if (self.showingBasicClues) {
// Show detailed clues
cluesText.setText('DETAILED CLUES TO SOLVE THE PUZZLE:\n\n• Row 1 (Music): Look for musical instruments\n 1=Drum (percussion), 2=Harp (strings), 3=Saxophone (brass),\n 4=Flute (woodwind), 5=Guitar (strings)\n• Row 2 (Food): Delicious treats and meals\n 6=Spaghetti (Italian pasta), 7=Donut (sweet pastry),\n 8=Chips (crispy snack), 9=Icecream (frozen dessert), 10=Pizza (Italian dish)\n• Row 3 (Toys): Fun playthings for children\n 11=Basketball (sports ball), 12=Dolls (figurines),\n 13=Lego (building blocks), 14=Videogame (electronic entertainment), 15=Plushtoy (soft toy)\n• Row 4 (Animals): Living creatures\n 16=Fish (aquatic animal), 17=Turtle (reptile with shell),\n 18=Frog (amphibian), 19=Cat (feline pet), 20=Dog (canine companion)\n• Row 5 (Family): Members of the household\n 21=KJ (family member), 22=Khalida (family member),\n 23=Sapphire (family member), 24=Harmony (family member), 25=PJ (family member)\n\nClick here again for basic clues!');
self.showingBasicClues = false;
} else {
// Show basic clues
cluesText.setText('CLUES TO SOLVE THE PUZZLE:\n\n• Row 1 (Music): 1=Drum, 2=Harp, 3=Saxophone, 4=Flute, 5=Guitar\n• Row 2 (Food): 6=Spaghetti, 7=Donut, 8=Chips, 9=Icecream, 10=Pizza\n• Row 3 (Toys): 11=Basketball, 12=Dolls, 13=Lego, 14=Videogame, 15=Plushtoy\n• Row 4 (Animals): 16=Fish, 17=Turtle, 18=Frog, 19=Cat, 20=Dog\n• Row 5 (Family): 21=KJ, 22=Khalida, 23=Sapphire, 24=Harmony, 25=PJ\n\nClick any dot to cycle through options!\nMatch all items to their correct positions to win!\n\nClick here for more detailed clues!');
self.showingBasicClues = true;
}
};
self.addChild(cluesText);
// Create 25 dots in a 5x5 grid
self.dots = [];
var gridSize = 5;
var dotSpacing = targetWidth / (gridSize + 1); // Distribute dots evenly across the width
var gridHeight = puzzleImage.height * scale;
var verticalSpacing = gridHeight / (gridSize + 1);
for (var row = 0; row < gridSize; row++) {
for (var col = 0; col < gridSize; col++) {
var dot = new Dot();
dot.gridX = col;
dot.gridY = row;
// Initialize all indices to 0 for consistent reset state
dot.instrumentIndex = 0;
dot.specialInstrumentIndex = 0;
dot.animalIndex = 0;
dot.foodIndex = 0;
dot.toyIndex = 0;
// Position dots over the 4x5 asset
dot.x = (col + 1) * dotSpacing;
dot.y = (row + 1) * verticalSpacing;
self.dots.push(dot);
self.addChild(dot);
}
}
// Example: puzzle state
self.isSolved = false;
// Method to check if puzzle is solved according to target solution
self.checkSolved = function () {
// Target solution mapping: dot index -> expected image
var targetSolution = {
0: 'Drum',
// Dot 1 (row 1, col 1)
1: 'Harp',
// Dot 2 (row 1, col 2)
2: 'Saxophone',
// Dot 3 (row 1, col 3)
3: 'Flute',
// Dot 4 (row 1, col 4)
4: 'Gutair',
// Dot 5 (row 1, col 5)
5: 'Spaghetti',
// Dot 6 (row 2, col 1)
6: 'Donut',
// Dot 7 (row 2, col 2)
7: 'Chips',
// Dot 8 (row 2, col 3)
8: 'Icecream',
// Dot 9 (row 2, col 4)
9: 'Pizza',
// Dot 10 (row 2, col 5)
10: 'Basketball',
// Dot 11 (row 3, col 1)
11: 'Dolls',
// Dot 12 (row 3, col 2)
12: 'Lego',
// Dot 13 (row 3, col 3)
13: 'Videogame',
// Dot 14 (row 3, col 4)
14: 'Plushtoy',
// Dot 15 (row 3, col 5)
15: 'Fish',
// Dot 16 (row 4, col 1)
16: 'Turtle',
// Dot 17 (row 4, col 2)
17: 'Frog',
// Dot 18 (row 4, col 3)
18: 'Cat',
// Dot 19 (row 4, col 4)
19: 'Dog',
// Dot 20 (row 4, col 5)
20: 'KJ',
// Dot 21 (row 5, col 1)
21: 'Khalida',
// Dot 22 (row 5, col 2)
22: 'Sapphire',
// Dot 23 (row 5, col 3)
23: 'Harmony',
// Dot 24 (row 5, col 4)
24: 'PJ' // Dot 25 (row 5, col 5)
};
// Check if all dots match the target solution
var allCorrect = true;
for (var i = 0; i < self.dots.length; i++) {
var dot = self.dots[i];
var expectedImage = targetSolution[i];
// Get current image of the dot based on its row and current index
var currentImage = 'Blank';
var row = dot.gridY;
if (row === 0 && dot.instruments) {
// Row 1: Music instruments
currentImage = dot.instruments[dot.instrumentIndex];
} else if (row === 1 && dot.foodImages) {
// Row 2: Food
currentImage = dot.foodImages[dot.foodIndex];
} else if (row === 2 && dot.toyImages) {
// Row 3: Toys
currentImage = dot.toyImages[dot.toyIndex];
} else if (row === 3 && dot.animalImages) {
// Row 4: Animals
currentImage = dot.animalImages[dot.animalIndex];
} else if (row === 4 && dot.specialInstruments) {
// Row 5: Family
currentImage = dot.specialInstruments[dot.specialInstrumentIndex];
}
// Check if current image matches expected
if (currentImage !== expectedImage) {
allCorrect = false;
break;
}
}
// Update solved state only - win display handled by green tick
if (allCorrect && !self.isSolved) {
self.isSolved = true;
} else if (!allCorrect && self.isSolved) {
self.isSolved = false;
}
};
// Example: update method for per-frame logic
self.update = function () {
// Add per-frame puzzle logic here
// For example, check for completion
self.checkSolved();
};
return self;
});
// Scene class for managing a scene in the game
var Scene = Container.expand(function () {
var self = Container.call(this);
// Example: add a background image to the scene
// (Replace 'Dream' with the desired asset for your scene)
var bg = self.attachAsset('Dream', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
// Add any additional scene setup here
// Scene update method (called every tick if attached to game)
self.update = function () {
// Add per-frame logic for the scene here
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Track which instruments are currently in use
var usedInstruments = {};
// Add Puzzle to the game when it starts
var puzzle = new Puzzle();
game.addChild(puzzle);
// Add green tick to bottom right corner
var greenTick = LK.getAsset('Greentick', {
anchorX: 1.0,
anchorY: 1.0,
x: 2048 - 50,
y: 2732 - 50,
scaleX: 0.8,
scaleY: 0.8
});
game.addChild(greenTick);
// Add info button to bottom left corner
var infoButton = LK.getAsset('Info', {
anchorX: 0.0,
anchorY: 1.0,
x: 50,
y: 2732 - 50,
scaleX: 1.5,
scaleY: 1.5
});
game.addChild(infoButton);
// Variable to track instructions screen
var instructionsScreen = null;
// Make info button clickable to show instructions screen
infoButton.down = function (x, y, obj) {
// If instructions screen is already showing, hide it
if (instructionsScreen && instructionsScreen.parent) {
instructionsScreen.parent.removeChild(instructionsScreen);
instructionsScreen = null;
return;
}
// Create instructions screen container
instructionsScreen = new Container();
// Add semi-transparent background
var instructionsBg = LK.getAsset('Street', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 20.48,
scaleY: 27.32,
alpha: 0.9
});
instructionsScreen.addChild(instructionsBg);
// Add instructions title
var instructionsTitle = new Text2('HOW TO PLAY', {
size: 110,
fill: 0xffffff,
align: 'center',
font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma"
});
instructionsTitle.anchor.set(0.5, 0.5);
instructionsTitle.x = 2048 / 2;
instructionsTitle.y = 2732 / 2 - 650;
instructionsScreen.addChild(instructionsTitle);
// Add a visual example row (music row) with dots and images
var exampleY = 2732 / 2 - 400;
var exampleSpacing = 260;
var exampleStartX = 2048 / 2 - 2 * exampleSpacing;
var exampleImages = ['Drum', 'Harp', 'Saxophone', 'Flute', 'Gutair'];
var exampleDots = [];
for (var i = 0; i < 5; i++) {
// Dot background
var dotBg = LK.getAsset('Street', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5,
x: exampleStartX + i * exampleSpacing,
y: exampleY
});
instructionsScreen.addChild(dotBg);
// Instrument image
var img = LK.getAsset(exampleImages[i], {
anchorX: 0.5,
anchorY: 0.5,
x: exampleStartX + i * exampleSpacing,
y: exampleY
});
instructionsScreen.addChild(img);
// Dot number
var num = new Text2('' + (i + 1), {
size: 48,
fill: 0x222222,
align: 'center',
font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma"
});
num.anchor.set(0.5, 0.5);
num.x = exampleStartX + i * exampleSpacing;
num.y = exampleY + 110;
instructionsScreen.addChild(num);
exampleDots.push({
dotBg: dotBg,
img: img,
num: num
});
}
// Add a hand icon to show clicking (using 'Info' asset as a placeholder for a hand)
var handIcon = LK.getAsset('Info', {
anchorX: 0.5,
anchorY: 0.5,
x: exampleStartX + 0 * exampleSpacing,
y: exampleY + 180,
scaleX: 1.2,
scaleY: 1.2,
alpha: 0.7
});
instructionsScreen.addChild(handIcon);
// Add a text label under the example row
var exampleLabel = new Text2('Tap a dot to cycle through options', {
size: 60,
fill: 0xffffff,
align: 'center',
font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma"
});
exampleLabel.anchor.set(0.5, 0.5);
exampleLabel.x = 2048 / 2;
exampleLabel.y = exampleY + 260;
instructionsScreen.addChild(exampleLabel);
// Add a short text summary below the example
var summaryText = new Text2('Match each row with the correct items!\nWhen you finish, tap the green tick to check your solution.\n\nTap anywhere to close this screen.', {
size: 70,
fill: 0xffffff,
align: 'center',
font: "'Times New Roman Bold','Times New Roman','GillSans-Bold',Impact,'Arial Black',Tahoma"
});
summaryText.anchor.set(0.5, 0.5);
summaryText.x = 2048 / 2;
summaryText.y = 2732 / 2 + 100;
instructionsScreen.addChild(summaryText);
// Make the entire instructions screen clickable to close
instructionsScreen.down = function (x, y, obj) {
if (instructionsScreen && instructionsScreen.parent) {
instructionsScreen.parent.removeChild(instructionsScreen);
instructionsScreen = null;
}
};
// Add instructions screen to game
game.addChild(instructionsScreen);
};
// Helper to show/hide info button
function setInfoButtonVisible(visible) {
if (infoButton && infoButton.parent) {
infoButton.visible = !!visible;
}
}
// Function to update clues text with strikethrough for solved items
function updateCluesWithStrikethrough() {
if (!puzzle || !puzzle.dots) return;
// Get current state of all dots
var dotStates = [];
for (var i = 0; i < puzzle.dots.length; i++) {
var dot = puzzle.dots[i];
var currentImage = 'Blank';
var row = dot.gridY;
if (row === 0 && dot.instruments) {
currentImage = dot.instruments[dot.instrumentIndex];
} else if (row === 1 && dot.foodImages) {
currentImage = dot.foodImages[dot.foodIndex];
} else if (row === 2 && dot.toyImages) {
currentImage = dot.toyImages[dot.toyIndex];
} else if (row === 3 && dot.animalImages) {
currentImage = dot.animalImages[dot.animalIndex];
} else if (row === 4 && dot.specialInstruments) {
currentImage = dot.specialInstruments[dot.specialInstrumentIndex];
}
dotStates.push(currentImage);
}
// Target solution mapping
var targetSolution = {
0: 'Drum',
1: 'Harp',
2: 'Saxophone',
3: 'Flute',
4: 'Gutair',
5: 'Spaghetti',
6: 'Donut',
7: 'Chips',
8: 'Icecream',
9: 'Pizza',
10: 'Basketball',
11: 'Dolls',
12: 'Lego',
13: 'Videogame',
14: 'Plushtoy',
15: 'Fish',
16: 'Turtle',
17: 'Frog',
18: 'Cat',
19: 'Dog',
20: 'KJ',
21: 'Khalida',
22: 'Sapphire',
23: 'Harmony',
24: 'PJ'
};
// Check which rows are completely solved
var rowSolved = [false, false, false, false, false];
for (var row = 0; row < 5; row++) {
var allCorrectInRow = true;
for (var col = 0; col < 5; col++) {
var dotIndex = row * 5 + col;
if (dotStates[dotIndex] !== targetSolution[dotIndex]) {
allCorrectInRow = false;
break;
}
}
rowSolved[row] = allCorrectInRow;
}
// Update clues text with strikethrough for solved rows
var cluesText = '';
if (puzzle.showingBasicClues) {
cluesText = 'CLUES TO SOLVE THE PUZZLE:\n\n';
cluesText += (rowSolved[0] ? '<s>• Row 1 (Music): 1=Drum, 2=Harp, 3=Saxophone, 4=Flute, 5=Guitar</s>' : '• Row 1 (Music): 1=Drum, 2=Harp, 3=Saxophone, 4=Flute, 5=Guitar') + '\n';
cluesText += (rowSolved[1] ? '<s>• Row 2 (Food): 6=Spaghetti, 7=Donut, 8=Chips, 9=Icecream, 10=Pizza</s>' : '• Row 2 (Food): 6=Spaghetti, 7=Donut, 8=Chips, 9=Icecream, 10=Pizza') + '\n';
cluesText += (rowSolved[2] ? '<s>• Row 3 (Toys): 11=Basketball, 12=Dolls, 13=Lego, 14=Videogame, 15=Plushtoy</s>' : '• Row 3 (Toys): 11=Basketball, 12=Dolls, 13=Lego, 14=Videogame, 15=Plushtoy') + '\n';
cluesText += (rowSolved[3] ? '<s>• Row 4 (Animals): 16=Fish, 17=Turtle, 18=Frog, 19=Cat, 20=Dog</s>' : '• Row 4 (Animals): 16=Fish, 17=Turtle, 18=Frog, 19=Cat, 20=Dog') + '\n';
cluesText += (rowSolved[4] ? '<s>• Row 5 (Family): 21=KJ, 22=Khalida, 23=Sapphire, 24=Harmony, 25=PJ</s>' : '• Row 5 (Family): 21=KJ, 22=Khalida, 23=Sapphire, 24=Harmony, 25=PJ') + '\n';
cluesText += '\nClick any dot to cycle through options!\nMatch all items to their correct positions to win!\n\nClick here for more detailed clues!';
} else {
cluesText = 'DETAILED CLUES TO SOLVE THE PUZZLE:\n\n';
cluesText += (rowSolved[0] ? '<s>• Row 1 (Music): Look for musical instruments\n 1=Drum (percussion), 2=Harp (strings), 3=Saxophone (brass),\n 4=Flute (woodwind), 5=Guitar (strings)</s>' : '• Row 1 (Music): Look for musical instruments\n 1=Drum (percussion), 2=Harp (strings), 3=Saxophone (brass),\n 4=Flute (woodwind), 5=Guitar (strings)') + '\n';
cluesText += (rowSolved[1] ? '<s>• Row 2 (Food): Delicious treats and meals\n 6=Spaghetti (Italian pasta), 7=Donut (sweet pastry),\n 8=Chips (crispy snack), 9=Icecream (frozen dessert), 10=Pizza (Italian dish)</s>' : '• Row 2 (Food): Delicious treats and meals\n 6=Spaghetti (Italian pasta), 7=Donut (sweet pastry),\n 8=Chips (crispy snack), 9=Icecream (frozen dessert), 10=Pizza (Italian dish)') + '\n';
cluesText += (rowSolved[2] ? '<s>• Row 3 (Toys): Fun playthings for children\n 11=Basketball (sports ball), 12=Dolls (figurines),\n 13=Lego (building blocks), 14=Videogame (electronic entertainment), 15=Plushtoy (soft toy)</s>' : '• Row 3 (Toys): Fun playthings for children\n 11=Basketball (sports ball), 12=Dolls (figurines),\n 13=Lego (building blocks), 14=Videogame (electronic entertainment), 15=Plushtoy (soft toy)') + '\n';
cluesText += (rowSolved[3] ? '<s>• Row 4 (Animals): Living creatures\n 16=Fish (aquatic animal), 17=Turtle (reptile with shell),\n 18=Frog (amphibian), 19=Cat (feline pet), 20=Dog (canine companion)</s>' : '• Row 4 (Animals): Living creatures\n 16=Fish (aquatic animal), 17=Turtle (reptile with shell),\n 18=Frog (amphibian), 19=Cat (feline pet), 20=Dog (canine companion)') + '\n';
cluesText += (rowSolved[4] ? '<s>• Row 5 (Family): Members of the household\n 21=KJ (family member), 22=Khalida (family member),\n 23=Sapphire (family member), 24=Harmony (family member), 25=PJ (family member)</s>' : '• Row 5 (Family): Members of the household\n 21=KJ (family member), 22=Khalida (family member),\n 23=Sapphire (family member), 24=Harmony (family member), 25=PJ (family member)') + '\n';
cluesText += '\nClick here again for basic clues!';
}
// Find and update the clues text in puzzle
for (var i = 0; i < puzzle.children.length; i++) {
var child = puzzle.children[i];
if (child && child.setText && typeof child.setText === 'function') {
child.setText(cluesText);
break;
}
}
}
// Make green tick clickable to enter puzzle attempt
greenTick.down = function (x, y, obj) {
if (puzzle && typeof puzzle.checkSolved === "function") {
// Run the check
puzzle.checkSolved();
// If solved, show endpuzzletwo scene
if (puzzle.isSolved) {
// Remove the puzzle and green tick from the game
if (puzzle.parent) puzzle.parent.removeChild(puzzle);
if (greenTick.parent) greenTick.parent.removeChild(greenTick);
// Hide info button when showing endpuzzletwo
setInfoButtonVisible(false);
// Show endpuzzletwo asset centered on screen
var endpuzzletwo = LK.getAsset('Endpuzzletwo', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 2.2,
scaleY: 2.2
});
game.addChild(endpuzzletwo);
// After 3 seconds, swap to correct scene with correct word under the correct image
LK.setTimeout(function () {
if (endpuzzletwo.parent) endpuzzletwo.parent.removeChild(endpuzzletwo);
// Show Correct scene (centered)
var correctScene = LK.getAsset('Correct', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 2.2,
scaleY: 2.2
});
game.addChild(correctScene);
// No winning image displayed - just show the correct word
// Show the correct word asset at the bottom of the screen
var correctWord = LK.getAsset('Correctword', {
anchorX: 0.5,
anchorY: 1.0,
x: 2048 / 2,
y: 2732 - 50,
scaleX: 2.2,
scaleY: 2.2
});
game.addChild(correctWord);
}, 3000);
} else {
// If not solved, show endgame1 scene
if (puzzle.parent) puzzle.parent.removeChild(puzzle);
if (greenTick.parent) greenTick.parent.removeChild(greenTick);
// Hide info button when showing endgame1
setInfoButtonVisible(false);
// Show endgame1 asset centered on screen
var endgame1 = LK.getAsset('Endpuzzleone', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 2.2,
scaleY: 2.2
});
game.addChild(endgame1);
// After 3 seconds, swap to incorrect scene with incorrect word under the incorrect image
LK.setTimeout(function () {
if (endgame1.parent) endgame1.parent.removeChild(endgame1);
// Show Incorrect scene (centered)
var incorrectScene = LK.getAsset('Incorrect', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 2.2,
scaleY: 2.2
});
game.addChild(incorrectScene);
// Find the first incorrect dot and its expected word
var targetSolution = {
0: 'Drum',
1: 'Harp',
2: 'Saxophone',
3: 'Flute',
4: 'Gutair',
5: 'Spaghetti',
6: 'Donut',
7: 'Chips',
8: 'Icecream',
9: 'Pizza',
10: 'Basketball',
11: 'Dolls',
12: 'Lego',
13: 'Videogame',
14: 'Plushtoy',
15: 'Fish',
16: 'Turtle',
17: 'Frog',
18: 'Cat',
19: 'Dog',
20: 'KJ',
21: 'Khalida',
22: 'Sapphire',
23: 'Harmony',
24: 'PJ'
};
var firstWrongIdx = -1;
var wrongActual = '';
var wrongExpected = '';
for (var i = 0; i < puzzle.dots.length; i++) {
var dot = puzzle.dots[i];
var expected = targetSolution[i];
var actual = 'Blank';
var row = dot.gridY;
// Get current image based on row and index
if (row === 0 && dot.instruments) {
actual = dot.instruments[dot.instrumentIndex];
} else if (row === 1 && dot.foodImages) {
actual = dot.foodImages[dot.foodIndex];
} else if (row === 2 && dot.toyImages) {
actual = dot.toyImages[dot.toyIndex];
} else if (row === 3 && dot.animalImages) {
actual = dot.animalImages[dot.animalIndex];
} else if (row === 4 && dot.specialInstruments) {
actual = dot.specialInstruments[dot.specialInstrumentIndex];
}
if (actual !== expected) {
firstWrongIdx = i;
wrongActual = actual;
wrongExpected = expected;
break;
}
}
// If found, show the incorrect image and word under it
if (firstWrongIdx !== -1) {
var wrongImg = null;
var imgY = 2732 / 2 + 100;
var wordY = imgY;
// Only show the image if it's not 'Blank'
if (wrongActual !== 'Blank') {
wrongImg = LK.getAsset(wrongActual, {
anchorX: 0.5,
anchorY: 1.0,
x: 2048 / 2,
y: imgY
});
game.addChild(wrongImg);
wordY = 2732 / 2 + 120 + (wrongImg.height || 100); // 20px below image
} else {
// If blank, just show the word lower down
wordY = 2732 / 2 + 120;
}
// Show the incorrect word asset at the bottom of the screen
var incorrectWord = LK.getAsset('Incorrectword', {
anchorX: 0.5,
anchorY: 1.0,
x: 2048 / 2,
y: 2732 - 50,
// 50px padding from bottom
scaleX: 2.2,
scaleY: 2.2
});
game.addChild(incorrectWord);
// Add retry button below the incorrect image/word
var retryBtnY = 2732 - 50 - incorrectWord.height * 2.2 - 40; // 40px above incorrect word
var retryBtn = LK.getAsset('Retry', {
anchorX: 0.5,
anchorY: 1.0,
x: 2048 / 2,
y: retryBtnY,
scaleX: 1.8,
scaleY: 1.8
});
game.addChild(retryBtn);
// Retry button handler: remove incorrect scene and restart puzzle
retryBtn.down = function (x, y, obj) {
// Remove all incorrect scene assets
if (incorrectScene && incorrectScene.parent) incorrectScene.parent.removeChild(incorrectScene);
if (wrongImg && wrongImg.parent) wrongImg.parent.removeChild(wrongImg);
if (incorrectWord && incorrectWord.parent) incorrectWord.parent.removeChild(incorrectWord);
if (retryBtn && retryBtn.parent) retryBtn.parent.removeChild(retryBtn);
// Reset all used image trackers so dots can be reused
usedInstruments = {};
usedSpecialInstruments = {};
usedAnimalImages = {};
usedFoodImages = {};
usedToyImages = {};
// Re-add puzzle and green tick
puzzle = new Puzzle();
game.addChild(puzzle);
game.addChild(greenTick);
// Re-add info button after story asset
if (infoButton && infoButton.parent) {
infoButton.parent.removeChild(infoButton);
}
// Find the story asset in the puzzle and add infoButton after it
var storyAssetIdx = -1;
for (var i = 0; i < puzzle.children.length; i++) {
var child = puzzle.children[i];
if (child && child.assetId === 'Story') {
storyAssetIdx = i;
break;
}
}
if (storyAssetIdx !== -1) {
// Insert infoButton after story asset
if (puzzle.children.length > storyAssetIdx + 1) {
puzzle.addChildAt(infoButton, storyAssetIdx + 1);
} else {
puzzle.addChild(infoButton);
}
} else {
// Fallback: add to puzzle if not found
puzzle.addChild(infoButton);
}
// Show info button again after retry
setInfoButtonVisible(true);
};
}
}, 3000);
}
}
};
;
Add more vibrant colours to picture
Make this scene more modern like in the present
A 4x5 grid in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Remove man
Saxophone in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Harp in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Drum in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Flute in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Question mark professor Layton game style. In-Game asset. 2d. High contrast. No shadows
12yo blonde girl in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Cute little10yo girl brown hair in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Cute little 7yo girl with blonde curly hair. Professor Layton game style In-Game asset. 2d. High contrast. No shadows
15 yo boy with short scruffy blonde hair professor Layton game style. In-Game asset. 2d. High contrast. No shadows
18yo girl with short brown hair professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Cat in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
White dog with brown patch on eyes professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Turtle in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Frog in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Goldfish in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Basketball ball professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Lego bricks professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Video game console professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Teddy bear professor Layton game style. In-Game asset. 2d. High contrast. No shadows
These dolls in professor Layton game art style
Hot chips or fries in professor Layton game style artwork. In-Game asset. 2d. High contrast. No shadows
Bowl of spaghetti in professor Layton game style artwork. In-Game asset. 2d. High contrast. No shadows
Pizza in professor Layton game style artwork. In-Game asset. 2d. High contrast. No shadows
Chocolate donut in professor Layton game style artwork. In-Game asset. 2d. High contrast. No shadows
Ice cream cone in professor Layton game style artwork. In-Game asset. 2d. High contrast. No shadows
Make her crack a small smile
The word "correct" in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
The word " incorrect" in professor Layton game style. In-Game asset. 2d. High contrast. No shadows
Green tick in professor Layton gamestyle. In-Game asset. 2d. High contrast. No shadows
Button with RETRY PUZZLE on it in professor Layton game style artwork In-Game asset. 2d. High contrast. No shadows
Information symbol in professor Layton game style artwork. In-Game asset. 2d. High contrast. No shadows
Number 1 button professor Layton game style artwork. In-Game asset. 2d. High contrast. No shadows
Number 2
Number 3
Number 4
Number 5
Remove clock
Make sure J and Y is not cut off
How to play button in professor Layton game style font. In-Game asset. 2d. High contrast. No shadows
Make robe hang lower so you can't see it's feet
Make it say play new puzzle
A 16:9 title banner