User prompt
arregla lo siguiente. toma a cada tipo de memes como un individuo diferente para evitar casos como el siguiente: Se combinaron 4 memes del mismo tipo pero como el movimiento conbino otros 3 no se creo el meme especial porque toma como si fueran 7 memes en vez de 4 del mismo tipo y 3 de otro
User prompt
El meme especial se activa solo cuando se combina con memes de su mismo tipo. Agrega un detector para ver si un meme de la combinación es especial. Si hay un meme especial en la combinación, se rompen todos menos la especial. Esta se activara una vez caiga
User prompt
arregla lo siguiente: el meme especial se rompe al combinarlo en vez de activar su habilidad ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
arregla lo siguiente: el meme especial se activa solo cuando se combina con memes de su mismo tipo. Agrega un detector para ver si un meme de la combinación es especial. Si hay, se rompen todos los de la combinación menos el especial, este tendra un diley y se activara
User prompt
arregla lo siguiente: el meme especial se activa solo cuando se combina con memes de su mismo tipo. Si un meme de la combinación es especial se activa la habilidad primero
User prompt
arregla lo siguiente: el meme especial se activa solo cuando se combina con memes de su mismo tipo. Si un meme de la combinación es especial se prioriza la habilidad en vez dela ruptura
User prompt
arregla lo siguiente: el meme especial no se activa al cambiar de lugar, se activa cuando se combina con memes de su mismo tipo. Se prioriza la habilidad en vez de la ruptura individual
User prompt
crea la siguiente caracteristica: si un meme se junta con un grupo de exactamente 4 este se transformara en un meme especial con un tinte naranja. Los demás memes se romperán y este permanecerá en pantalla. su habilidad sea romper toda una fila/columna, si se crea de manera horizontal rompera la columna y si se crea de una manera vertical rompera la fila. esta solo se activa si se vuelve a juntar
User prompt
agrega un modo visual de ver que meme haz seleccionado
User prompt
arregla el siguiente caso: en la parte visible se unen 3 memes pero no se rompen porque en la parte invisible hay 1 que conecta que impide la roptura a pesar que el usuario ve que se cumplen los requisitos
User prompt
haz que las ropturas se generen paralelo a cualquier otra roptura en pantalla. Esto con la finalidad de que una rotura nueva generada a la vez no tenga que esperar a que la otra finalice primero
User prompt
mejora las ropturas para que empiecen desde el meme que provoco el efecto, en forma expansiva desde el más cercano al más lejano. caso 1: se coloco la ficha horizontalmente en el lado derecho en un conjunto de 3, el primero en explotar sera el movido, el segundo el de su lado y el ultimo el más lejano haciendo un efecto domino. caso 2: Se coloco la ficha al centro de los memes, se repite el efecto domino pero los memes adyacentes se rompen simultáneamente ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
mejora la función con la siguiente especificación: SI se coloca al medio todos los adyacentes se rompera al mismo tiempo
User prompt
mejora las ropturas para que empiecen desde el meme que provoco el efecto, en forma expansiva desde el más cercano al más lejano. ej: se coloco la ficha horizontalmente en el lado derecho en un conjunto de 3, el primero en explotar sera el movido, el segundo el de su lado y el ultimo el más lejano haciendo un efecto domino ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
mejora las ropturas para que empiecen desde el meme que provoco el efecto en forma expansiva desde e más cercano al más lejano ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Evita el siguiente caso: Se juntan 3 del mismos meme 1 de ellos en el area visible y los demás en la invisible
User prompt
mejora las flag, aun se rompen memes aunque se este aplicando las caidas por gravedad
User prompt
elimina los comentarios del codigo
User prompt
mejora el codigo, optimizalo y borra comentarios
User prompt
agrega una flag para que solo se puedan romper por gravedad los grid visibles
User prompt
haz que las filas extras no se rompan por gravedad
User prompt
haz que las filas extras no se rompan por gravedad
User prompt
agrega al meme seleccionado una animación de pulso en bucle
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'easeInOutQuad')' in or related to this line: 'var pulseAnimation = tween(cell.sprite.scale, {' Line Number: 117 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'easeInOutQuad')' in or related to this line: 'var pulseAnimation = tween(cell.sprite.scale, {' Line Number: 117
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var GridCell = Container.expand(function () { var self = Container.call(this); // Method to initialize or reset a cell self.init = function () { // Create the background square for the cell if it doesn't exist if (!self.background) { self.background = self.attachAsset('cuadricula', { anchorX: 0.5, anchorY: 0.5 }); } // Initialize or reset properties self.value = 0; self.sprite = null; self.row = -1; self.col = -1; return self; // Enable chaining }; // Method to set value and corresponding sprite self.setValue = function (newValue) { // Skip if same value if (self.value === newValue) { return; } self.value = newValue; // Remove previous sprite if exists if (self.sprite) { self.removeChild(self.sprite); } // Create new sprite based on value var spriteId = 'meme' + newValue; self.sprite = LK.getAsset(spriteId, { anchorX: 0.5, anchorY: 0.5 }); self.addChild(self.sprite); }; // Handle tap event self.down = function (x, y, obj) { handleCellTap(self); }; // Initialize the cell self.init(); return self; }); /**** * Initialize Game ****/ // Factory function to get a GridCell (from pool or new) // Grid configuration var game = new LK.Game({ backgroundColor: 0xF4FFFF }); /**** * Game Code ****/ // Grid configuration // Cell pool for object reuse var cellPool = []; // Factory function to get a GridCell (from pool or new) function getGridCell() { if (cellPool.length > 0) { return cellPool.pop().init(); // Reuse a cell from the pool } return new GridCell(); // Create a new cell } // Function to return a cell to the pool function recycleGridCell(cell) { if (cell) { cellPool.push(cell); // Add to pool for later reuse } } var selectedCell = null; var isAnimating = false; // Additional animation flags to prevent race conditions window.gravityInProgress = false; window.fillInProgress = false; window.destructionInProgress = false; window.pendingDestructions = []; function handleCellTap(tappedCell) { // Check all animation flags to ensure no animations are in progress if (isAnimating || window.gravityInProgress || window.fillInProgress || window.destructionInProgress) { return; } if (selectedCell === null) { selectedCell = tappedCell; return; } var cell1 = selectedCell; var cell2 = tappedCell; if (cell1 === cell2) { selectedCell = null; return; } var isAdjacent = Math.abs(cell1.row - cell2.row) === 1 && cell1.col === cell2.col || Math.abs(cell1.col - cell2.col) === 1 && cell1.row === cell2.row; if (!isAdjacent) { selectedCell = tappedCell; return; } // Case 5: Adjacent cell - perform the swap // Store original positions for animation var pos1_x = cell1.x; var pos1_y = cell1.y; var pos2_x = cell2.x; var pos2_y = cell2.y; // Store original grid indices var row1 = cell1.row; var col1 = cell1.col; var row2 = cell2.row; var col2 = cell2.col; // Swap cells in the gridCells array gridCells[row1][col1] = cell2; gridCells[row2][col2] = cell1; // Swap row/col properties on the cell objects cell1.row = row2; cell1.col = col2; cell2.row = row1; cell2.col = col1; // Animate the visual swap of positions tween(cell1, { x: pos2_x, y: pos2_y }, { duration: 300 }); tween(cell2, { x: pos1_x, y: pos1_y }, { duration: 300 }); selectedCell = null; // Reset selection after swap // Schedule the match check and destruction slightly after the animation completes LK.setTimeout(function () { checkForAndDestroyMatches(cell1, cell2); // Pass the swapped cells // Future enhancement: After destruction, new cells might fall, // and new matches could form. This would require a loop of: // check/destroy -> fill -> check/destroy ... until no more matches. // For now, we just check once after the swap. }, 350); // Animation is 300ms, add a small buffer of 50ms } // Helper functions for match detection and destruction function getMatches() { var matches = []; // Helper function to find matches in a specific direction function findDirectionalMatches(isHorizontal) { var primary, secondary; var primaryMax = isHorizontal ? gridSize + extraRows : gridSize; var secondaryMax = isHorizontal ? gridSize : gridSize + extraRows; // Only check visible grid (rows >= extraRows) for (primary = isHorizontal ? extraRows : 0; primary < primaryMax; primary++) { for (secondary = 0; secondary < secondaryMax;) { // Skip if not enough cells left for a match of 3 if (secondary > secondaryMax - 3) { secondary++; continue; } // Get current cell based on direction var cell1 = isHorizontal ? gridCells[primary][secondary] : gridCells[secondary][primary]; // For vertical matches, only check visible cells if (isHorizontal === false && secondary < extraRows) { secondary = extraRows; continue; } if (!cell1) { // Skip empty cells secondary++; continue; } var currentMatchValue = cell1.value; var currentMatchCells = [cell1]; // Check subsequent cells for matches for (var k = secondary + 1; k < secondaryMax; k++) { // For vertical matches, skip checking cells in the hidden rows if (isHorizontal === false && k < extraRows) { continue; } var nextCell = isHorizontal ? gridCells[primary][k] : gridCells[k][primary]; if (nextCell && nextCell.value === currentMatchValue) { currentMatchCells.push(nextCell); } else { break; // End of current potential match } } // Add to matches if we found 3 or more if (currentMatchCells.length >= 3) { matches.push(currentMatchCells); } // Move index forward based on match length secondary += currentMatchCells.length > 0 ? currentMatchCells.length : 1; } } } // Find horizontal matches findDirectionalMatches(true); // Find vertical matches findDirectionalMatches(false); return matches; } function destroyCells(cellsToDestroy) { // Set animation flag to prevent user interaction during destruction isAnimating = true; // Check if we're already processing destruction if (window.destructionInProgress) { // Queue this destruction for later instead of running now if (!window.pendingDestructions) { window.pendingDestructions = []; } window.pendingDestructions.push(cellsToDestroy); return; } window.destructionInProgress = true; // Process each cell with a slight delay for more satisfying destruction var delay = 0; var delayIncrement = 100; // 100ms delay between each meme destruction // Calculate total destruction time for this sequence only var totalDestructionTime = cellsToDestroy.length * delayIncrement; cellsToDestroy.forEach(function (cell) { // Schedule destruction with increasing delay LK.setTimeout(function () { // Defensive checks: ensure cell exists and is the one we expect in the grid if (cell && gridCells[cell.row] && gridCells[cell.row][cell.col] === cell) { // Play explosion sound LK.getSound('Explosion').play(); // Visual flash effect LK.effects.flashObject(cell, 0xFFFFFF, 200); // Remove from display gridContainer.removeChild(cell); cell.destroy(); // Destroy the cell object (releases resources) gridCells[cell.row][cell.col] = null; // Mark as empty in the logical grid } }, delay); // Increase delay for next cell delay += delayIncrement; }); // After destroying cells, make memes fall to fill empty spaces // Wait until all cells are destroyed using the exact time for this sequence LK.setTimeout(function () { window.destructionInProgress = false; // Check for pending destructions before applying gravity if (window.pendingDestructions && window.pendingDestructions.length > 0) { var nextDestructions = window.pendingDestructions.shift(); LK.setTimeout(function () { destroyCells(nextDestructions); }, 50); return; } applyGravity(); }, totalDestructionTime + 50); // Use exact time based on this destruction sequence } // Function to make memes fall down to fill empty spaces function applyGravity() { // Set animation flag to prevent user interaction isAnimating = true; // Track all cells that need to fall for sequencing var cellsToFall = []; // Track if we're already processing gravity to prevent multiple calls if (window.gravityInProgress) { return; } window.gravityInProgress = true; // First pass: identify all cells that need to fall for (var col = 0; col < gridSize; col++) { // Start from the bottom row and work upwards for (var row = gridSize + extraRows - 1; row >= extraRows; row--) { // If current cell is empty if (!gridCells[row][col]) { // Look for the nearest non-empty cell above var sourceRow = row - 1; while (sourceRow >= extraRows && !gridCells[sourceRow][col]) { sourceRow--; } // If we found a cell to move down (only consider visible cells) if (sourceRow >= extraRows) { var cellToMove = gridCells[sourceRow][col]; // Store the cell along with destination info cellsToFall.push({ cell: cellToMove, fromRow: sourceRow, toRow: row, col: col }); // Update grid array gridCells[row][col] = cellToMove; gridCells[sourceRow][col] = null; // Update cell's logical position cellToMove.row = row; } } } } // Second pass: animate falls with sequential delays var longestDelay = 0; var baseDelay = 30; // Base delay in ms between each meme starting to fall var constantDuration = 400; // Constant duration for all fall animations regardless of distance // Sort by column and row to make the animation more coherent cellsToFall.sort(function (a, b) { // Sort by column first if (a.col !== b.col) { return a.col - b.col; } // Then by destination row (lower row falls first) - this makes the animation go from bottom to top return b.toRow - a.toRow; }); // Apply animations with sequential delays cellsToFall.forEach(function (fallInfo, index) { var delay = index * baseDelay; // Each meme starts falling after the previous one // Calculate destination position var newPos = getCellPosition(fallInfo.toRow, fallInfo.col); // Track the longest delay + duration for later use var totalTime = delay + constantDuration; if (totalTime > longestDelay) { longestDelay = totalTime; } // Schedule the animation with proper delay LK.setTimeout(function () { // Linear falling animation without bounce tween(fallInfo.cell, { y: newPos.y }, { duration: constantDuration, easing: tween.linear }); }, delay); }); // After all cells have fallen, fill in empty spaces at the top with new memes // Use the actual total animation time rather than a fixed value LK.setTimeout(function () { window.gravityInProgress = false; fillEmptySpacesWithNewMemes(); }, longestDelay + 50); // Add a small buffer to ensure all falls are complete } // Create new memes to fill empty spots at the top of the grid function fillEmptySpacesWithNewMemes() { // Check if we're already processing fill operation if (window.fillInProgress) { return; } window.fillInProgress = true; var anyNewMemeAdded = false; // Collect all new cells to add for sequenced animation var newCellsToAdd = []; // Check each column for empty spaces for (var col = 0; col < gridSize; col++) { // Only fill visible rows (rows >= extraRows) for (var row = extraRows; row < gridSize + extraRows; row++) { if (!gridCells[row][col]) { anyNewMemeAdded = true; // Create a new meme cell var newCell = getGridCell(); var pos = getCellPosition(row, col); // Position the new cell above the grid (for animation) newCell.x = pos.x; newCell.y = pos.y - 400; // Start above the visible grid // Set random value for the new meme var randomValue = Math.floor(Math.random() * 5) + 1; newCell.setValue(randomValue); // Set logical position newCell.row = row; newCell.col = col; // Add to grid array gridCells[row][col] = newCell; // Store cell data for animation newCellsToAdd.push({ cell: newCell, destY: pos.y, row: row, col: col }); // Add to display since we're only processing visible rows gridContainer.addChild(newCell); } } } // Animate cell drops with sequential delays var longestDelay = 0; var baseDelay = 30; // Delay between each meme starting to fall var constantDuration = 400; // Constant duration for all fall animations regardless of distance // Sort by column first, then by row for coherent animation - bottom to top newCellsToAdd.sort(function (a, b) { if (a.col !== b.col) { return a.col - b.col; } return b.row - a.row; // Higher rows (lower in grid) fall first - bottom to top animation }); // Apply animations with sequential delays newCellsToAdd.forEach(function (cellData, index) { var delay = index * baseDelay; // Track total animation time var totalTime = delay + constantDuration; if (totalTime > longestDelay) { longestDelay = totalTime; } // Schedule the animation with proper delay LK.setTimeout(function () { // Linear falling with no bounce tween(cellData.cell, { y: cellData.destY }, { duration: constantDuration, easing: tween.linear }); }, delay); }); // If new memes were added, check for matches only after all fall animations are complete if (anyNewMemeAdded) { LK.setTimeout(function () { // Reset fill flag when animations are done window.fillInProgress = false; // Now that all falling animations are complete, check for matches var newMatches = getMatches(); if (newMatches.length > 0) { // Get all cells from all new match groups var newCellsToDestroy = []; var newCellTracker = {}; newMatches.forEach(function (group) { group.forEach(function (cell) { var cellKey = cell.row + "_" + cell.col; if (!newCellTracker[cellKey]) { newCellsToDestroy.push(cell); newCellTracker[cellKey] = true; } }); }); // Destroy these new matches only after all falling has fully completed if (newCellsToDestroy.length) { destroyCells(newCellsToDestroy); } } else { // No more matches, animations are complete, allow user interaction again isAnimating = false; } }, longestDelay + 50); // Use actual animation time plus buffer } else { // No new memes were added, animations are complete, allow user interaction again window.fillInProgress = false; isAnimating = false; } } function checkForAndDestroyMatches(swappedCellA, swappedCellB) { // Get all potential matches on the board var allMatchGroupsOnBoard = getMatches(); // Quick return if no matches if (!allMatchGroupsOnBoard.length) { return; // No matches found anywhere, nothing to do } // Filter to only match groups containing one of the swapped cells var relevantMatchGroups = allMatchGroupsOnBoard.filter(function (group) { // Check if any cell in the group is one of our swapped cells return group.some(function (cellInGroup) { return cellInGroup === swappedCellA || cellInGroup === swappedCellB; }); }); if (!relevantMatchGroups.length) { return; } var uniqueCellTracker = {}; var cellsToDestroy = []; relevantMatchGroups.forEach(function (group) { group.forEach(function (cell) { var cellKey = cell.row + "_" + cell.col; if (!uniqueCellTracker[cellKey]) { cellsToDestroy.push(cell); uniqueCellTracker[cellKey] = true; } }); }); if (cellsToDestroy.length) { destroyCells(cellsToDestroy); LK.setTimeout(function () { var newMatches = getMatches(); if (newMatches.length > 0) { var newCellsToDestroy = []; var newCellTracker = {}; newMatches.forEach(function (group) { group.forEach(function (cell) { var cellKey = cell.row + "_" + cell.col; if (!newCellTracker[cellKey]) { newCellsToDestroy.push(cell); newCellTracker[cellKey] = true; } }); }); if (newCellsToDestroy.length) { destroyCells(newCellsToDestroy); } } }, 400); } } var gridSize = 8; var extraRows = 9; var cellSpacing = 10; var cellSize = 208; var gridCells = []; var totalGridWidth = gridSize * cellSize + (gridSize - 1) * cellSpacing; var totalVisibleGridHeight = totalGridWidth; var totalGridHeight = totalVisibleGridHeight + extraRows * (cellSize + cellSpacing); var startX = (2048 - totalGridWidth) / 2 + cellSize / 2; var startY = (-1300 - totalVisibleGridHeight) / 2 + cellSize / 2 + extraRows * (cellSize + cellSpacing); function getCellPosition(row, col) { return { x: startX + col * (cellSize + cellSpacing), y: startY + row * (cellSize + cellSpacing) - extraRows * (cellSize + cellSpacing) }; } var gridContainer = new Container(); game.addChild(gridContainer); function initializeGrid() { gridCells = []; for (var row = 0; row < gridSize + extraRows; row++) { gridCells[row] = []; for (var col = 0; col < gridSize; col++) { var pos = getCellPosition(row, col); var cell = getGridCell ? getGridCell() : new GridCell(); cell.x = pos.x; cell.y = pos.y; cell.row = row; cell.col = col; var randomValue; var attempts = 0; do { randomValue = Math.floor(Math.random() * 5) + 1; attempts++; var leftMatchCount = 0; var aboveMatchCount = 0; if (col >= 2) { if (gridCells[row][col - 1].value === randomValue && gridCells[row][col - 2].value === randomValue) { leftMatchCount = 2; } } if (row >= 2) { if (gridCells[row - 1][col].value === randomValue && gridCells[row - 2][col].value === randomValue) { aboveMatchCount = 2; } } } while ((leftMatchCount >= 2 || aboveMatchCount >= 2) && attempts < 10); cell.setValue(randomValue); if (row >= extraRows) { gridContainer.addChild(cell); } gridCells[row][col] = cell; } } } initializeGrid(); function ensureNoInitialMatches() { var matches = getMatches(); if (matches.length > 0) { matches.forEach(function (group) { group.forEach(function (cell) { var currentValue = cell.value; var newValue; do { newValue = Math.floor(Math.random() * 5) + 1; } while (newValue === currentValue); cell.setValue(newValue); }); }); ensureNoInitialMatches(); } } ensureNoInitialMatches();
===================================================================
--- original.js
+++ change.js
@@ -66,41 +66,8 @@
****/
// Grid configuration
// Cell pool for object reuse
var cellPool = [];
-// Track pulse animation
-var pulseAnimation = null;
-// Function to start pulse animation on selected cell
-function startPulseAnimation(cell) {
- // Clear any existing pulse animation
- if (pulseAnimation) {
- pulseAnimation.stop();
- }
- // Create pulse animation loop
- function createPulseLoop() {
- // Scale up
- return tween(cell, {
- scaleX: 1.15,
- scaleY: 1.15
- }, {
- duration: 400,
- easing: tween.easeInOutQuad,
- onComplete: function onComplete() {
- // Scale down
- tween(cell, {
- scaleX: 1.0,
- scaleY: 1.0
- }, {
- duration: 400,
- easing: tween.easeInOutQuad,
- onComplete: createPulseLoop
- });
- }
- });
- }
- // Start pulse loop
- pulseAnimation = createPulseLoop();
-}
// Factory function to get a GridCell (from pool or new)
function getGridCell() {
if (cellPool.length > 0) {
return cellPool.pop().init(); // Reuse a cell from the pool
@@ -126,44 +93,22 @@
return;
}
if (selectedCell === null) {
selectedCell = tappedCell;
- // Start pulse animation for the newly selected cell
- startPulseAnimation(selectedCell);
return;
}
var cell1 = selectedCell;
var cell2 = tappedCell;
if (cell1 === cell2) {
- // Stop pulse animation
- if (pulseAnimation) {
- pulseAnimation.stop();
- selectedCell.scaleX = 1.0;
- selectedCell.scaleY = 1.0;
- }
selectedCell = null;
return;
}
var isAdjacent = Math.abs(cell1.row - cell2.row) === 1 && cell1.col === cell2.col || Math.abs(cell1.col - cell2.col) === 1 && cell1.row === cell2.row;
if (!isAdjacent) {
- // Stop current pulse animation
- if (pulseAnimation) {
- pulseAnimation.stop();
- cell1.scaleX = 1.0;
- cell1.scaleY = 1.0;
- }
selectedCell = tappedCell;
- // Start pulse animation for the newly selected cell
- startPulseAnimation(selectedCell);
return;
}
// Case 5: Adjacent cell - perform the swap
- // Stop pulse animation
- if (pulseAnimation) {
- pulseAnimation.stop();
- cell1.scaleX = 1.0;
- cell1.scaleY = 1.0;
- }
// Store original positions for animation
var pos1_x = cell1.x;
var pos1_y = cell1.y;
var pos2_x = cell2.x;
@@ -211,9 +156,9 @@
function findDirectionalMatches(isHorizontal) {
var primary, secondary;
var primaryMax = isHorizontal ? gridSize + extraRows : gridSize;
var secondaryMax = isHorizontal ? gridSize : gridSize + extraRows;
- // Only check visible grid plus extra rows above
+ // Only check visible grid (rows >= extraRows)
for (primary = isHorizontal ? extraRows : 0; primary < primaryMax; primary++) {
for (secondary = 0; secondary < secondaryMax;) {
// Skip if not enough cells left for a match of 3
if (secondary > secondaryMax - 3) {
@@ -221,8 +166,13 @@
continue;
}
// Get current cell based on direction
var cell1 = isHorizontal ? gridCells[primary][secondary] : gridCells[secondary][primary];
+ // For vertical matches, only check visible cells
+ if (isHorizontal === false && secondary < extraRows) {
+ secondary = extraRows;
+ continue;
+ }
if (!cell1) {
// Skip empty cells
secondary++;
continue;
@@ -230,8 +180,12 @@
var currentMatchValue = cell1.value;
var currentMatchCells = [cell1];
// Check subsequent cells for matches
for (var k = secondary + 1; k < secondaryMax; k++) {
+ // For vertical matches, skip checking cells in the hidden rows
+ if (isHorizontal === false && k < extraRows) {
+ continue;
+ }
var nextCell = isHorizontal ? gridCells[primary][k] : gridCells[k][primary];
if (nextCell && nextCell.value === currentMatchValue) {
currentMatchCells.push(nextCell);
} else {
@@ -322,13 +276,13 @@
// If current cell is empty
if (!gridCells[row][col]) {
// Look for the nearest non-empty cell above
var sourceRow = row - 1;
- while (sourceRow >= 0 && !gridCells[sourceRow][col]) {
+ while (sourceRow >= extraRows && !gridCells[sourceRow][col]) {
sourceRow--;
}
- // If we found a cell to move down
- if (sourceRow >= 0) {
+ // If we found a cell to move down (only consider visible cells)
+ if (sourceRow >= extraRows) {
var cellToMove = gridCells[sourceRow][col];
// Store the cell along with destination info
cellsToFall.push({
cell: cellToMove,
@@ -340,12 +294,8 @@
gridCells[row][col] = cellToMove;
gridCells[sourceRow][col] = null;
// Update cell's logical position
cellToMove.row = row;
- // Add the cell to the grid container if it was previously hidden
- if (sourceRow < extraRows) {
- gridContainer.addChild(cellToMove);
- }
}
}
}
}
@@ -401,10 +351,10 @@
// Collect all new cells to add for sequenced animation
var newCellsToAdd = [];
// Check each column for empty spaces
for (var col = 0; col < gridSize; col++) {
- // Start from the top (row 0) and fill any empty spaces
- for (var row = 0; row < gridSize + extraRows; row++) {
+ // Only fill visible rows (rows >= extraRows)
+ for (var row = extraRows; row < gridSize + extraRows; row++) {
if (!gridCells[row][col]) {
anyNewMemeAdded = true;
// Create a new meme cell
var newCell = getGridCell();
@@ -426,12 +376,10 @@
destY: pos.y,
row: row,
col: col
});
- // Only add to display if in visible area
- if (row >= extraRows) {
- gridContainer.addChild(newCell);
- }
+ // Add to display since we're only processing visible rows
+ gridContainer.addChild(newCell);
}
}
}
// Animate cell drops with sequential delays
la figura de una casa color blanca simple para una interfaz. In-Game asset. 2d. High contrast. No shadows
haz el fondo color morado
circular check logo. In-Game asset. 2d. High contrast. No shadows
Cuadrado con los bordes redondeado negro. In-Game asset. 2d. High contrast. No shadows
hazlo un gris claro
Que sea blanco
Que sea blanco