User prompt
make an eye button to let people see their paassword if they forgot
User prompt
make the letters on the keyboard easier to see
User prompt
make the password button the same color as the username one
User prompt
make it dark red
User prompt
make the letters on the keyboard red
User prompt
make the keys on the keyboard red
User prompt
Noooo add the letters to the keyboard even tho u already have them make them easier to see
User prompt
Then the keyboard when it types the letters should be black
User prompt
Remove the text password from the button and move the text password to the side of the password button
User prompt
When you start typing in the password field the text password should dissappear
User prompt
When I click on password the keyboard doesn't pop up fix that
User prompt
I can use the keyboard on username but not on password fix it
User prompt
Remove the cherry asset from the buttons username and password
User prompt
Make the keys bigger on the custom keyboard
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of null (reading 'setText')' in or related to this line: 'usernameText.setText(usernameValue + '|');' Line Number: 710
User prompt
Please fix the bug: 'Uncaught ReferenceError: usernameValue is not defined' in or related to this line: 'if (usernameValue.length < 20) {' Line Number: 706
User prompt
Then after u click on username u should be able to make your own name so add a custom keyboard that types in the system
User prompt
When you click on create account the username button should be compatible with keyboard and mobile keyboard
User prompt
Actually remove the cherry asset
User prompt
Wait no keep the cherries
User prompt
Remove the roses all of them
User prompt
Remove the texts that says lvl3 target(amount)score(amount)moves(amount) when you start the game
User prompt
When you start the game you should be on lvl1
User prompt
Remove select level buttons and text when you start the game
User prompt
Remove the thing that pops up and says select level
/**** * 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; tween(self, { scaleX: 0, scaleY: 0, alpha: 0 }, { duration: 200, easing: tween.easeIn, onFinish: callback }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c1810 }); /**** * 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']; 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 = storage.currentLevel || 1; var maxUnlockedLevel = storage.maxUnlockedLevel || 1; var gameState = 'playing'; // 'playing', 'levelComplete', 'levelSelect' var levelCompleteShown = false; var usernameValue = ''; var usernameFocused = false; var usernameText = null; var passwordValue = ''; var passwordFocused = false; var passwordText = null; // 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() { return FOOD_TYPES[Math.floor(Math.random() * FOOD_TYPES.length)]; } function createFoodItem(x, y) { var foodType = getRandomFoodType(); var food = new FoodItem(foodType); food.setGridPosition(x, y); grid[x][y] = food; game.addChild(food); 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 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; var matches = findAllMatches(); if (matches.length === 0) return; isProcessingMatches = true; LK.getSound('match').play(); var matchCount = matches.length; currentScore += matchCount * 10; matchesCleared += matchCount; targetMatches = Math.max(0, targetMatches - 2); updateUI(); var animationsCompleted = 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].animateMatch(function () { animationsCompleted++; if (animationsCompleted === matchCount) { // Remove matched foods for (var j = 0; j < matches.length; j++) { var m = matches[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 (matchCount === 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()); 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() { scoreText.setText('Score: ' + currentScore); movesText.setText('Moves: ' + movesLeft); targetText.setText('Target: ' + targetMatches); } function checkGameEnd() { if (matchesCleared >= targetMatches) { if (currentLevel === 1 && !levelCompleteShown) { showLevelComplete(); } else { completeLevel(); } } else if (movesLeft <= 0) { LK.showGameOver(); } } function showLevelComplete() { levelCompleteShown = true; gameState = 'levelComplete'; 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 = 'homeScreen'; // Set green background for home screen game.setBackgroundColor(0x00FF00); // 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; } // Create buttons container var buttonsContainer = new Container(); game.addChild(buttonsContainer); // Create Account button var createAccountButton = new Container(); var createAccountBg = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 0.8 }); createAccountBg.tint = 0x4CAF50; // Green tint createAccountButton.addChild(createAccountBg); var createAccountText = new Text2('Create Account', { size: 80, fill: 0xFFFFFF }); createAccountText.anchor.set(0.5, 0.5); createAccountButton.addChild(createAccountText); createAccountButton.x = 1024; createAccountButton.y = 1200; createAccountButton.down = function () { // Handle create account action console.log('Create Account pressed'); showCreateAccountScreen(); }; buttonsContainer.addChild(createAccountButton); // Play as Guest button var playAsGuestButton = new Container(); var playAsGuestBg = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 0.8 }); playAsGuestBg.tint = 0x2196F3; // Blue tint playAsGuestButton.addChild(playAsGuestBg); var playAsGuestText = new Text2('Play as Guest', { size: 80, fill: 0xFFFFFF }); playAsGuestText.anchor.set(0.5, 0.5); playAsGuestButton.addChild(playAsGuestText); playAsGuestButton.x = 1024; playAsGuestButton.y = 1500; playAsGuestButton.down = function () { // Handle play as guest action console.log('Play as Guest pressed'); // Start the game startLevel(1); }; buttonsContainer.addChild(playAsGuestButton); } function showCreateAccountScreen() { gameState = 'createAccount'; // Clear existing elements game.removeChildren(); // Keep green background game.setBackgroundColor(0x00FF00); // Create container for account creation elements var accountContainer = new Container(); game.addChild(accountContainer); // Title var titleText = new Text2('Create Account', { size: 120, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 400; accountContainer.addChild(titleText); // Username input field var usernameField = new Container(); var usernameBg = LK.getAsset('inputField', { width: 720, height: 144, color: 0xFFFFFF, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); usernameField.addChild(usernameBg); usernameText = new Text2('Enter username...', { size: 60, fill: 0x666666 }); usernameText.anchor.set(0.5, 0.5); usernameField.addChild(usernameText); usernameField.x = 1024; usernameField.y = 800; usernameField.down = function () { usernameFocused = true; if (usernameValue === '') { usernameText.setText('|'); usernameText.fill = 0x000000; } showCustomKeyboard(); }; accountContainer.addChild(usernameField); // Password input field var passwordField = new Container(); var passwordBg = LK.getAsset('passwordField', { width: 720, height: 144, color: 0xFFFFFF, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); passwordField.addChild(passwordBg); passwordField.x = 1024; passwordField.y = 1100; passwordText = new Text2('Enter password...', { size: 60, fill: 0x666666 }); passwordText.anchor.set(0.5, 0.5); passwordField.addChild(passwordText); // Password label beside the button var passwordLabel = new Text2('Password:', { size: 60, fill: 0x000000 }); passwordLabel.anchor.set(1, 0.5); passwordLabel.x = 1024 - 360 - 20; // Position to the left of the password field passwordLabel.y = 1100; accountContainer.addChild(passwordLabel); passwordField.down = function () { usernameFocused = false; passwordFocused = true; if (passwordValue === '') { passwordText.setText('|'); passwordText.fill = 0x000000; } showCustomKeyboard(); }; accountContainer.addChild(passwordField); // Create Account button var createButton = new Container(); var createBg = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 0.8 }); createBg.tint = 0x4CAF50; // Green tint createButton.addChild(createBg); var createText = new Text2('Create', { size: 80, fill: 0xFFFFFF }); createText.anchor.set(0.5, 0.5); createButton.addChild(createText); createButton.x = 1024; createButton.y = 1400; createButton.down = function () { // Handle account creation (for now just start the game) console.log('Account created'); startLevel(1); }; accountContainer.addChild(createButton); // Back button var backButton = new Container(); var backBg = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 0.6 }); backBg.tint = 0x757575; // Gray tint backButton.addChild(backBg); var backText = new Text2('Back', { size: 60, fill: 0xFFFFFF }); backText.anchor.set(0.5, 0.5); backButton.addChild(backText); backButton.x = 1024; backButton.y = 1600; backButton.down = function () { showHomeScreen(); }; accountContainer.addChild(backButton); } var customKeyboard = null; var keyboardKeys = [['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'], ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L'], ['Z', 'X', 'C', 'V', 'B', 'N', 'M']]; function showCustomKeyboard() { if (customKeyboard) { hideCustomKeyboard(); } customKeyboard = new Container(); game.addChild(customKeyboard); // Keyboard background var keyboardBg = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, scaleX: 8, scaleY: 4 }); keyboardBg.tint = 0x333333; keyboardBg.x = 1024; keyboardBg.y = 2200; customKeyboard.addChild(keyboardBg); // Create keyboard keys var startY = 1900; var keySize = 180; var keySpacing = 200; for (var row = 0; row < keyboardKeys.length; row++) { var rowKeys = keyboardKeys[row]; var rowWidth = rowKeys.length * keySpacing; var startX = 1024 - rowWidth / 2 + keySpacing / 2; for (var col = 0; col < rowKeys.length; col++) { var keyChar = rowKeys[col]; var keyButton = createKeyButton(keyChar, keySize); keyButton.x = startX + col * keySpacing; keyButton.y = startY + row * 220; customKeyboard.addChild(keyButton); } } // Add space bar var spaceButton = createKeyButton(' ', keySize * 4); spaceButton.x = 1024; spaceButton.y = startY + keyboardKeys.length * 220; customKeyboard.addChild(spaceButton); // Add backspace button var backspaceButton = createKeyButton('⌫', keySize * 1.5); backspaceButton.x = 1024 + 400; backspaceButton.y = startY + keyboardKeys.length * 220; customKeyboard.addChild(backspaceButton); // Add done button var doneButton = createKeyButton('Done', keySize * 1.5); doneButton.x = 1024 - 400; doneButton.y = startY + keyboardKeys.length * 220; customKeyboard.addChild(doneButton); } function createKeyButton(keyChar, width) { var keyButton = new Container(); var keyBg = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5, scaleX: width / 240, scaleY: 0.5 }); keyBg.tint = 0xFF0000; keyButton.addChild(keyBg); var keyText = new Text2(keyChar === ' ' ? 'Space' : keyChar, { size: keyChar === 'Done' ? 70 : 90, fill: 0x000000 }); keyText.anchor.set(0.5, 0.5); keyButton.addChild(keyText); keyButton.down = function () { if (keyChar === 'Done') { hideCustomKeyboard(); if (usernameFocused) { usernameFocused = false; if (usernameValue === '') { usernameText.setText('Enter username...'); usernameText.fill = 0x666666; } else { usernameText.setText(usernameValue); } } else if (passwordFocused) { passwordFocused = false; if (passwordValue === '') { passwordText.setText('Enter password...'); passwordText.fill = 0x666666; } else { passwordText.setText('*'.repeat(passwordValue.length)); } } } else if (keyChar === '⌫') { if (usernameFocused && usernameValue.length > 0) { usernameValue = usernameValue.slice(0, -1); if (usernameValue === '') { usernameText.setText('|'); } else { usernameText.setText(usernameValue + '|'); } } else if (passwordFocused && passwordValue.length > 0) { passwordValue = passwordValue.slice(0, -1); if (passwordValue === '') { passwordText.setText('|'); } else { passwordText.setText('*'.repeat(passwordValue.length) + '|'); } } } else { if (usernameFocused && usernameValue.length < 20) { // Limit username length usernameValue += keyChar; usernameText.setText(usernameValue + '|'); } else if (passwordFocused && passwordValue.length < 20) { // Limit password length if (passwordValue === '') { // Clear placeholder text when starting to type passwordText.fill = 0x000000; } passwordValue += keyChar; passwordText.setText('*'.repeat(passwordValue.length) + '|'); } } // Visual feedback keyBg.tint = 0xCC0000; LK.setTimeout(function () { keyBg.tint = 0xFF0000; }, 100); }; return keyButton; } function hideCustomKeyboard() { if (customKeyboard) { customKeyboard.destroy(); customKeyboard = null; } } function completeLevel() { // Update progress if (currentLevel >= maxUnlockedLevel) { maxUnlockedLevel = currentLevel + 1; storage.maxUnlockedLevel = maxUnlockedLevel; } storage.currentLevel = currentLevel; // Show home screen instead of level select showHomeScreen(); } function startLevel(levelNum) { currentLevel = levelNum; gameState = 'playing'; levelCompleteShown = false; // 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; // 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; } }; 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 swipeFood.alpha = 1; isSwipeActive = false; swipeFood = null; }; // Initialize the game - start with home screen showHomeScreen();
===================================================================
--- original.js
+++ change.js
@@ -676,9 +676,9 @@
anchorY: 0.5,
scaleX: width / 240,
scaleY: 0.5
});
- keyBg.tint = 0xCCCCCC;
+ keyBg.tint = 0xFF0000;
keyButton.addChild(keyBg);
var keyText = new Text2(keyChar === ' ' ? 'Space' : keyChar, {
size: keyChar === 'Done' ? 70 : 90,
fill: 0x000000
@@ -736,11 +736,11 @@
passwordText.setText('*'.repeat(passwordValue.length) + '|');
}
}
// Visual feedback
- keyBg.tint = 0xAAAAAA;
+ keyBg.tint = 0xCC0000;
LK.setTimeout(function () {
- keyBg.tint = 0xCCCCCC;
+ keyBg.tint = 0xFF0000;
}, 100);
};
return keyButton;
}