User prompt
Make a custom keyboard for entering words into text boxes like username and password
User prompt
Please fix the bug: 'Uncaught TypeError: LK.showLeaderboard is not a function' in or related to this line: 'LK.showLeaderboard();' Line Number: 868 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Restart all the way back to when we had leaderboards a log out button and a log in button a play button ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
It didn't work fix it so the exit button teleports you back to home screen
User prompt
Change the brown back to light blue and make the exit button teleport you to home screen
User prompt
Wait no keep leaderboard and change back the background and fix the exit button ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Nevermind go back to how we were
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'y')' in or related to this line: 'createAccountButton.y = 1200;' Line Number: 1063
User prompt
Before you play a level you must create a account ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
When you get into a level there's a button that says exit under the board of foods
User prompt
Try again when I get 4 in a square it doesn't clear a row
User prompt
When ur target hits 1 make sure a 2x2 square of the same food appears on the front of the board of foods then click it and it will clear a row
User prompt
Make a chance of making a 2x2 square bigger
User prompt
When you get the same food in a square 2x2 it clears a row
User prompt
If the same food gets 4 in a row in a square it clears a row
User prompt
Try again didn't work
User prompt
Try again didn't work
User prompt
If you get 4 foods in a square it clears a row
User prompt
Now add pizza as red circles
User prompt
Now add hot dogs as light brown circles
User prompt
Try again didn't work
User prompt
While in game your profile picture and info should be hidden
User prompt
Get rid of the guest players on the leaderboard ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Now remove everyone from the leaderboard ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Change the leaderboard theme when people's names are displayed don't use a rose use a long pink line with the players name on it
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var FoodItem = Container.expand(function (foodType) { var self = Container.call(this); self.foodType = foodType; self.gridX = -1; self.gridY = -1; self.isMatched = false; self.isAnimating = false; var foodGraphics = self.attachAsset(foodType, { anchorX: 0.5, anchorY: 0.5 }); self.setGridPosition = function (gridX, gridY) { self.gridX = gridX; self.gridY = gridY; self.x = GRID_START_X + gridX * CELL_SIZE + CELL_SIZE / 2; self.y = GRID_START_Y + gridY * CELL_SIZE + CELL_SIZE / 2; }; self.animateToPosition = function (targetX, targetY, callback) { self.isAnimating = true; tween(self, { x: targetX, y: targetY }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { self.isAnimating = false; if (callback) callback(); } }); }; self.animateMatch = function (callback) { self.isMatched = true; // First make it bigger and sparkly tween(self, { scaleX: 1.3, scaleY: 1.3, tint: 0xFFD700 }, { duration: 150, easing: tween.bounceOut }); // Then shrink away with stars effect tween(self, { scaleX: 0, scaleY: 0, alpha: 0, rotation: Math.PI * 2 }, { duration: 300, easing: tween.easeIn, onFinish: callback }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var GRID_SIZE = 8; var CELL_SIZE = 240; var GRID_START_X = (2048 - GRID_SIZE * CELL_SIZE) / 2; var GRID_START_Y = 300; var FOOD_TYPES = ['apple', 'banana', 'orange', 'grape', 'lemon', 'hamburger', 'hotdog', 'pizza']; var grid = []; var selectedFood = null; var isProcessingMatches = false; var movesLeft = 30; var currentScore = 0; var targetMatches = 10; var matchesCleared = 0; var swipeStartX = 0; var swipeStartY = 0; var swipeFood = null; var isSwipeActive = false; var SWIPE_THRESHOLD = 50; var currentLevel = 1; var maxUnlockedLevel = 1; var totalScore = 0; var gameState = 'playing'; var levelCompleteShown = false; // Initialize grid array for (var x = 0; x < GRID_SIZE; x++) { grid[x] = []; for (var y = 0; y < GRID_SIZE; y++) { grid[x][y] = null; } } // Create grid background var gridBackground = new Container(); game.addChild(gridBackground); for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { var cell = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5 }); cell.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2; cell.y = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2; cell.alpha = 0.3; gridBackground.addChild(cell); } } // Create UI var scoreText = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); scoreText.y = 120; var movesText = new Text2('Moves: 30', { size: 80, fill: 0xFFFFFF }); movesText.anchor.set(0, 0); LK.gui.topLeft.addChild(movesText); movesText.x = 150; movesText.y = 50; var tutorialText = new Text2('Lvl' + currentLevel, { size: 120, fill: 0xFFFFFF }); tutorialText.anchor.set(0.5, 0); LK.gui.top.addChild(tutorialText); tutorialText.y = 20; var targetText = new Text2('Target: ' + targetMatches, { size: 100, fill: 0xFFFFFF }); targetText.anchor.set(0, 0); LK.gui.top.addChild(targetText); targetText.x = tutorialText.x + tutorialText.width / 2 + 50; targetText.y = tutorialText.y; function getRandomFoodType(x, y) { // If position is provided, try to create squares by matching nearby foods if (x !== undefined && y !== undefined) { // Collect nearby food types that could form squares var nearbyTypes = []; // Check adjacent positions for potential square formation var positions = [{ dx: -1, dy: 0 }, { dx: 1, dy: 0 }, { dx: 0, dy: -1 }, { dx: 0, dy: 1 }, // Adjacent { dx: -1, dy: -1 }, { dx: 1, dy: -1 }, { dx: -1, dy: 1 }, { dx: 1, dy: 1 } // Diagonal ]; for (var i = 0; i < positions.length; i++) { var checkX = x + positions[i].dx; var checkY = y + positions[i].dy; if (isValidPosition(checkX, checkY) && grid[checkX] && grid[checkX][checkY]) { nearbyTypes.push(grid[checkX][checkY].foodType); } } // 40% chance to match a nearby type if any exist if (nearbyTypes.length > 0 && Math.random() < 0.4) { return nearbyTypes[Math.floor(Math.random() * nearbyTypes.length)]; } } return FOOD_TYPES[Math.floor(Math.random() * FOOD_TYPES.length)]; } function createFoodItem(x, y) { var foodType = getRandomFoodType(x, y); var food = new FoodItem(foodType); food.setGridPosition(x, y); grid[x][y] = food; game.addChild(food); // Add fun spawn animation with rainbow colors food.scaleX = 0; food.scaleY = 0; food.alpha = 0; var rainbowColors = [0xFF6B6B, 0x4ECDC4, 0x45B7D1, 0x96CEB4, 0xFECA57, 0xFF9FF3, 0x54A0FF]; var randomColor = rainbowColors[Math.floor(Math.random() * rainbowColors.length)]; food.tint = randomColor; tween(food, { scaleX: 1, scaleY: 1, alpha: 1 }, { duration: 500, easing: tween.bounceOut }); // Reset to normal color after spawn tween(food, { tint: 0xFFFFFF }, { duration: 800, easing: tween.easeOut }); return food; } function initializeGrid() { for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { createFoodItem(x, y); } } // Remove initial matches var foundMatches = true; while (foundMatches) { var matches = findAllMatches(); if (matches.length > 0) { for (var i = 0; i < matches.length; i++) { var match = matches[i]; if (grid[match.x] && grid[match.x][match.y]) { grid[match.x][match.y].destroy(); grid[match.x][match.y] = null; } } fillEmptySpaces(); } else { foundMatches = false; } } } function isValidPosition(x, y) { return x >= 0 && x < GRID_SIZE && y >= 0 && y < GRID_SIZE; } function isAdjacent(x1, y1, x2, y2) { var dx = Math.abs(x1 - x2); var dy = Math.abs(y1 - y2); return dx === 1 && dy === 0 || dx === 0 && dy === 1; } function swapFoods(food1, food2) { if (!food1 || !food2) return false; var x1 = food1.gridX; var y1 = food1.gridY; var x2 = food2.gridX; var y2 = food2.gridY; // Swap in grid grid[x1][y1] = food2; grid[x2][y2] = food1; // Update grid positions food1.setGridPosition(x2, y2); food2.setGridPosition(x1, y1); // Animate swap var targetX1 = GRID_START_X + x2 * CELL_SIZE + CELL_SIZE / 2; var targetY1 = GRID_START_Y + y2 * CELL_SIZE + CELL_SIZE / 2; var targetX2 = GRID_START_X + x1 * CELL_SIZE + CELL_SIZE / 2; var targetY2 = GRID_START_Y + y1 * CELL_SIZE + CELL_SIZE / 2; food1.animateToPosition(targetX1, targetY1); food2.animateToPosition(targetX2, targetY2); return true; } function findMatches(x, y) { var matches = []; if (!grid[x] || !grid[x][y]) return matches; var foodType = grid[x][y].foodType; // Check horizontal matches var horizontalMatches = [{ x: x, y: y }]; // Check left for (var i = x - 1; i >= 0; i--) { if (grid[i] && grid[i][y] && grid[i][y].foodType === foodType) { horizontalMatches.push({ x: i, y: y }); } else { break; } } // Check right for (var i = x + 1; i < GRID_SIZE; i++) { if (grid[i] && grid[i][y] && grid[i][y].foodType === foodType) { horizontalMatches.push({ x: i, y: y }); } else { break; } } if (horizontalMatches.length >= 3) { matches = matches.concat(horizontalMatches); } // Check vertical matches var verticalMatches = [{ x: x, y: y }]; // Check up for (var i = y - 1; i >= 0; i--) { if (grid[x] && grid[x][i] && grid[x][i].foodType === foodType) { verticalMatches.push({ x: x, y: i }); } else { break; } } // Check down for (var i = y + 1; i < GRID_SIZE; i++) { if (grid[x] && grid[x][i] && grid[x][i].foodType === foodType) { verticalMatches.push({ x: x, y: i }); } else { break; } } if (verticalMatches.length >= 3) { matches = matches.concat(verticalMatches); } return matches; } function findSquares() { var allSquares = []; // Check for 2x2 squares for (var x = 0; x < GRID_SIZE - 1; x++) { for (var y = 0; y < GRID_SIZE - 1; y++) { // Check if all positions have valid food items if (grid[x] && grid[x][y] && grid[x + 1] && grid[x + 1][y] && grid[x] && grid[x][y + 1] && grid[x + 1] && grid[x + 1][y + 1]) { var topLeft = grid[x][y]; var topRight = grid[x + 1][y]; var bottomLeft = grid[x][y + 1]; var bottomRight = grid[x + 1][y + 1]; // Check if all 4 foods exist, are the same type and not already matched if (topLeft && topRight && bottomLeft && bottomRight && topLeft.foodType === topRight.foodType && topLeft.foodType === bottomLeft.foodType && topLeft.foodType === bottomRight.foodType && !topLeft.isMatched && !topRight.isMatched && !bottomLeft.isMatched && !bottomRight.isMatched) { allSquares.push([{ x: x, y: y }, { x: x + 1, y: y }, { x: x, y: y + 1 }, { x: x + 1, y: y + 1 }]); } } } } return allSquares; } function findAllMatches() { var allMatches = []; var processed = {}; for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { if (grid[x] && grid[x][y] && !processed[x + ',' + y]) { var matches = findMatches(x, y); for (var i = 0; i < matches.length; i++) { var match = matches[i]; var key = match.x + ',' + match.y; if (!processed[key]) { allMatches.push(match); processed[key] = true; } } } } } return allMatches; } function processMatches() { if (isProcessingMatches) return; // First check for squares var squares = findSquares(); var matches = findAllMatches(); if (squares.length === 0 && matches.length === 0) return; isProcessingMatches = true; LK.getSound('match').play(); var totalClearedCount = 0; var finalMatches = []; // Process squares first - clear entire rows if (squares.length > 0) { var rowsToClear = []; // Collect all unique rows that contain squares for (var s = 0; s < squares.length; s++) { var square = squares[s]; for (var p = 0; p < square.length; p++) { var rowY = square[p].y; if (rowsToClear.indexOf(rowY) === -1) { rowsToClear.push(rowY); } } } // Clear all foods in the identified rows for (var r = 0; r < rowsToClear.length; r++) { var row = rowsToClear[r]; for (var x = 0; x < GRID_SIZE; x++) { if (grid[x] && grid[x][row] && !grid[x][row].isMatched) { finalMatches.push({ x: x, y: row }); grid[x][row].isMatched = true; // Mark as matched immediately } } } totalClearedCount = finalMatches.length; // Special celebration for square clearing LK.effects.flashScreen(0x00FF00, 800); currentScore += totalClearedCount * 20; // Bonus points for row clearing } else { // Regular match processing finalMatches = matches; totalClearedCount = matches.length; currentScore += totalClearedCount * 10; } matchesCleared += totalClearedCount; targetMatches = Math.max(0, targetMatches - Math.floor(totalClearedCount / 3)); updateUI(); // Update total score totalScore += squares.length > 0 ? totalClearedCount * 20 : totalClearedCount * 10; // Save high score to storage var highScore = storage.highScore || 0; if (totalScore > highScore) { storage.highScore = totalScore; } // Play squeaky voice when getting points LK.getSound('goodJobBooby').play(); // Add celebration effects for bigger matches if (totalClearedCount >= 4 || squares.length > 0) { // Big match celebration! if (squares.length === 0) { LK.effects.flashScreen(0xFFD700, 500); } // Make score text dance tween(scoreText, { scaleX: 1.3, scaleY: 1.3 }, { duration: 300, easing: tween.bounceOut }); tween(scoreText, { scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.bounceOut }); } var animationsCompleted = 0; for (var i = 0; i < finalMatches.length; i++) { var match = finalMatches[i]; if (grid[match.x] && grid[match.x][match.y]) { // Mark as matched before animation grid[match.x][match.y].isMatched = true; grid[match.x][match.y].animateMatch(function () { animationsCompleted++; if (animationsCompleted === totalClearedCount) { // Remove matched foods for (var j = 0; j < finalMatches.length; j++) { var m = finalMatches[j]; if (grid[m.x] && grid[m.x][m.y]) { grid[m.x][m.y].destroy(); grid[m.x][m.y] = null; } } fillEmptySpaces(); LK.setTimeout(function () { isProcessingMatches = false; processMatches(); // Check for cascade matches }, 300); } }); } } if (totalClearedCount === 0) { isProcessingMatches = false; } } function fillEmptySpaces() { // Drop existing foods for (var x = 0; x < GRID_SIZE; x++) { var writeIndex = GRID_SIZE - 1; for (var y = GRID_SIZE - 1; y >= 0; y--) { if (grid[x][y] !== null) { if (y !== writeIndex) { grid[x][writeIndex] = grid[x][y]; grid[x][y] = null; grid[x][writeIndex].setGridPosition(x, writeIndex); var targetY = GRID_START_Y + writeIndex * CELL_SIZE + CELL_SIZE / 2; grid[x][writeIndex].animateToPosition(grid[x][writeIndex].x, targetY); } writeIndex--; } } // Create new foods for empty spaces at top for (var y = 0; y <= writeIndex; y++) { var food = new FoodItem(getRandomFoodType(x, y)); food.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2; food.y = GRID_START_Y - (writeIndex - y + 1) * CELL_SIZE + CELL_SIZE / 2; food.gridX = x; food.gridY = y; grid[x][y] = food; game.addChild(food); var targetY = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2; food.animateToPosition(food.x, targetY); } } } function updateUI() { if (scoreText) { scoreText.setText('Score: ' + currentScore); } if (movesText) { movesText.setText('Moves: ' + movesLeft); } if (targetText) { targetText.setText('Target: ' + targetMatches); } } function checkGameEnd() { if (targetMatches <= 1 && targetMatches > 0) { // Create guaranteed 2x2 square at front of board createGuaranteedSquare(); } if (targetMatches <= 0) { if (currentLevel === 1 && !levelCompleteShown) { showLevelComplete(); } else { completeLevel(); } } else if (movesLeft <= 0) { LK.showGameOver(); } } function createGuaranteedSquare() { // Choose a random food type for the square var squareFoodType = FOOD_TYPES[Math.floor(Math.random() * FOOD_TYPES.length)]; // Find the best 2x2 position at the front (top rows) of the board var bestX = 0; var bestY = 0; // Try to place in top-left area first for visibility for (var x = 0; x <= GRID_SIZE - 2; x++) { for (var y = 0; y <= 2; y++) { // Focus on top 3 rows if (isValidPosition(x, y) && isValidPosition(x + 1, y) && isValidPosition(x, y + 1) && isValidPosition(x + 1, y + 1)) { bestX = x; bestY = y; break; } } if (bestY <= 2) break; } // Create the 2x2 square by replacing existing foods var positions = [{ x: bestX, y: bestY }, { x: bestX + 1, y: bestY }, { x: bestX, y: bestY + 1 }, { x: bestX + 1, y: bestY + 1 }]; for (var i = 0; i < positions.length; i++) { var pos = positions[i]; // Remove existing food if any if (grid[pos.x] && grid[pos.x][pos.y]) { grid[pos.x][pos.y].destroy(); } // Create new food of the same type var newFood = new FoodItem(squareFoodType); newFood.setGridPosition(pos.x, pos.y); grid[pos.x][pos.y] = newFood; game.addChild(newFood); // Add special visual effect to highlight the square newFood.tint = 0xFFD700; // Gold tint // Add pulsing animation to make it obvious tween(newFood, { scaleX: 1.2, scaleY: 1.2 }, { duration: 500, easing: tween.easeInOut }); tween(newFood, { scaleX: 1, scaleY: 1 }, { duration: 500, easing: tween.easeInOut }); } // Flash screen to draw attention LK.effects.flashScreen(0xFFD700, 1000); } function showLevelComplete() { levelCompleteShown = true; gameState = 'levelComplete'; // Play celebration music LK.playMusic('celebrationMusic', { loop: false }); // Play level complete sound LK.getSound('levelComplete').play(); // Add celebration effects LK.effects.flashScreen(0xFFD700, 1000); // Make all UI elements dance tween(scoreText, { scaleX: 1.5, scaleY: 1.5, rotation: 0.2 }, { duration: 500, easing: tween.bounceOut }); tween(tutorialText, { scaleX: 1.3, scaleY: 1.3, rotation: -0.1 }, { duration: 600, easing: tween.bounceOut }); tween(targetText, { scaleX: 1.2, scaleY: 1.2, rotation: 0.15 }, { duration: 700, easing: tween.bounceOut }); LK.setTimeout(function () { showWhiteScreen(); }, 3000); } function showWhiteScreen() { gameState = 'whiteScreen'; // Clear all game elements game.removeChildren(); // Clear tutorial UI elements if (tutorialText && tutorialText.parent) { tutorialText.destroy(); tutorialText = null; } if (targetText && targetText.parent) { targetText.destroy(); targetText = null; } if (scoreText && scoreText.parent) { scoreText.destroy(); scoreText = null; } if (movesText && movesText.parent) { movesText.destroy(); movesText = null; } // Set white background game.setBackgroundColor(0xFFFFFF); // Show white screen for 2 seconds then show home screen LK.setTimeout(function () { showHomeScreen(); }, 2000); } function showHomeScreen() { gameState = 'playing'; // Clear all game elements game.removeChildren(); // Set game background color game.setBackgroundColor(0x87CEEB); // Start playing happy background music LK.playMusic('happyBgMusic', { loop: true }); // Clear all UI elements from the screen if (tutorialText && tutorialText.parent) { tutorialText.destroy(); tutorialText = null; } if (targetText && targetText.parent) { targetText.destroy(); targetText = null; } if (scoreText && scoreText.parent) { scoreText.destroy(); scoreText = null; } if (movesText && movesText.parent) { movesText.destroy(); movesText = null; } // Start the game directly startLevel(1); } function completeLevel() { // Add current score to total score totalScore += currentScore; // Save high score to storage var highScore = storage.highScore || 0; if (totalScore > highScore) { storage.highScore = totalScore; } // Show leaderboard LK.showLeaderboard(); // Show home screen to restart the game showHomeScreen(); } function startLevel(levelNum) { currentLevel = levelNum; gameState = 'playing'; levelCompleteShown = false; // Continue playing background music during gameplay LK.playMusic('happyBgMusic', { loop: true }); // Adjust difficulty based on level targetMatches = Math.min(10 + (levelNum - 1) * 5, 100); movesLeft = Math.max(30 - Math.floor((levelNum - 1) / 3), 15); currentScore = 0; matchesCleared = 0; // Clear existing UI game.removeChildren(); // Recreate game setupGame(); } function setupGame() { // Recreate grid background gridBackground = new Container(); game.addChild(gridBackground); for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { var cell = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5 }); cell.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2; cell.y = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2; cell.alpha = 0.3; gridBackground.addChild(cell); } } // Clear existing UI elements if (tutorialText && tutorialText.parent) { tutorialText.destroy(); } if (targetText && targetText.parent) { targetText.destroy(); } // Recreate UI elements if they don't exist if (!scoreText) { scoreText = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); scoreText.y = 120; } if (!movesText) { movesText = new Text2('Moves: ' + movesLeft, { size: 80, fill: 0xFFFFFF }); movesText.anchor.set(0, 0); LK.gui.topLeft.addChild(movesText); movesText.x = 150; movesText.y = 50; } // Update UI scoreText.setText('Score: 0'); movesText.setText('Moves: ' + movesLeft); tutorialText = new Text2('Lvl' + currentLevel, { size: 120, fill: 0xFFFFFF }); tutorialText.anchor.set(0.5, 0); LK.gui.top.addChild(tutorialText); tutorialText.y = 20; targetText = new Text2('Target: ' + targetMatches, { size: 100, fill: 0xFFFFFF }); targetText.anchor.set(0, 0); LK.gui.top.addChild(targetText); targetText.x = tutorialText.x + tutorialText.width / 2 + 50; targetText.y = tutorialText.y; // Add exit button below the game grid var exitButton = new Container(); var exitBg = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 0.6 }); exitBg.tint = 0xFF4444; // Red tint for exit button exitButton.addChild(exitBg); var exitText = new Text2('EXIT', { size: 60, fill: 0xFFFFFF }); exitText.anchor.set(0.5, 0.5); exitButton.addChild(exitText); // Position button below the game grid, centered exitButton.x = 2048 / 2; exitButton.y = GRID_START_Y + GRID_SIZE * CELL_SIZE + 100; exitButton.down = function () { // Play button click sound LK.getSound('buttonClick').play(); // Add button press animation tween(exitButton, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100, easing: tween.easeOut }); tween(exitButton, { scaleX: 1, scaleY: 1 }, { duration: 150, easing: tween.bounceOut }); // Teleport to home screen showHomeScreen(); }; game.addChild(exitButton); // Initialize grid initializeGrid(); updateUI(); } function getFoodAtPosition(x, y) { var gridX = Math.floor((x - GRID_START_X) / CELL_SIZE); var gridY = Math.floor((y - GRID_START_Y) / CELL_SIZE); if (isValidPosition(gridX, gridY) && grid[gridX] && grid[gridX][gridY]) { return grid[gridX][gridY]; } return null; } game.down = function (x, y, obj) { if (isProcessingMatches) return; var food = getFoodAtPosition(x, y); if (food && !food.isAnimating) { swipeStartX = x; swipeStartY = y; swipeFood = food; isSwipeActive = true; swipeFood.alpha = 0.7; // Add fun wobble animation when selected tween(swipeFood, { scaleX: 1.1, scaleY: 1.1 }, { duration: 200, easing: tween.bounceOut }); } }; game.up = function (x, y, obj) { if (!isSwipeActive || !swipeFood) return; var deltaX = x - swipeStartX; var deltaY = y - swipeStartY; var swipeDistance = Math.sqrt(deltaX * deltaX + deltaY * deltaY); if (swipeDistance < SWIPE_THRESHOLD) { // Not a swipe, reset swipeFood.alpha = 1; isSwipeActive = false; swipeFood = null; return; } // Determine swipe direction var targetGridX = swipeFood.gridX; var targetGridY = swipeFood.gridY; var absDeltaX = Math.abs(deltaX); var absDeltaY = Math.abs(deltaY); if (absDeltaX > absDeltaY) { // Horizontal swipe if (deltaX > 0) { targetGridX++; // Swipe right } else { targetGridX--; // Swipe left } } else { // Vertical swipe if (deltaY > 0) { targetGridY++; // Swipe down } else { targetGridY--; // Swipe up } } // Check if target position is valid if (isValidPosition(targetGridX, targetGridY) && grid[targetGridX] && grid[targetGridX][targetGridY]) { var targetFood = grid[targetGridX][targetGridY]; if (!targetFood.isAnimating) { LK.getSound('swap').play(); // Store original positions BEFORE any swap var tempFood1 = swipeFood; var tempFood2 = targetFood; var originalX1 = tempFood1.gridX; var originalY1 = tempFood1.gridY; var originalX2 = tempFood2.gridX; var originalY2 = tempFood2.gridY; // Try swap swapFoods(tempFood1, tempFood2); LK.setTimeout(function () { var matches = findAllMatches(); if (matches.length === 0) { // Invalid move, animate swap back to original positions var targetX1 = GRID_START_X + originalX1 * CELL_SIZE + CELL_SIZE / 2; var targetY1 = GRID_START_Y + originalY1 * CELL_SIZE + CELL_SIZE / 2; var targetX2 = GRID_START_X + originalX2 * CELL_SIZE + CELL_SIZE / 2; var targetY2 = GRID_START_Y + originalY2 * CELL_SIZE + CELL_SIZE / 2; tempFood1.animateToPosition(targetX1, targetY1); tempFood2.animateToPosition(targetX2, targetY2); // Restore original grid positions grid[originalX1][originalY1] = tempFood1; grid[originalX2][originalY2] = tempFood2; tempFood1.gridX = originalX1; tempFood1.gridY = originalY1; tempFood2.gridX = originalX2; tempFood2.gridY = originalY2; } else { // Valid move movesLeft--; updateUI(); processMatches(); checkGameEnd(); } }, 350); } } // Reset swipe state with fun bounce back animation tween(swipeFood, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.bounceOut }); isSwipeActive = false; swipeFood = null; }; // Start background music when game loads LK.playMusic('happyBgMusic', { loop: true }); // Initialize the game - start with home screen showHomeScreen();
===================================================================
--- original.js
+++ change.js
@@ -67,9 +67,9 @@
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x1a0f08
+ backgroundColor: 0x87CEEB
});
/****
* Game Code
@@ -700,9 +700,9 @@
gameState = 'playing';
// Clear all game elements
game.removeChildren();
// Set game background color
- game.setBackgroundColor(0x1a0f08);
+ game.setBackgroundColor(0x87CEEB);
// Start playing happy background music
LK.playMusic('happyBgMusic', {
loop: true
});
@@ -854,9 +854,9 @@
}, {
duration: 150,
easing: tween.bounceOut
});
- // Exit to home screen
+ // Teleport to home screen
showHomeScreen();
};
game.addChild(exitButton);
// Initialize grid