User prompt
Ana ekranın sol altında kod yazın diye bir bölüm olsun oraya tıklayınca kod yazın diye bir eğe ro bölgeye "11012012" yazarsak bize 300 altın versin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Mor bombanın içinde 5 tane normal bomba çıksın ve onları rastgele fırlatsın ama bombalar mor bombanın 5×5 alanını patlasın ve sarı bomba patladığı yere yeşil bir iz bıraksın eğer hangi skorda olduysa o skor 1000 fazlası olduğunda leke kalksın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyunda %0,1 İhtimal ile Sarı Bomba Oluşsun bu bomba TÜM topları yok etsin ve 10000 puan yazsın oyun 15000 puanda bitsin ve eğer oyunu bitirirsem bize 20 altın versin ve 100 altın ile tüm toplara kral tacı eklensin ana ekranda sağ üstte market yazsın oraya tıklayınca o market ekranın sağ üstünde yeşil yazıyla tüm karakterlere kral tacı yazsın altında 100 altın yazsın eğer 100 altın yazan yere tıklarsanız paramız gitsin ve bütün toplara kral tacı eklensin ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Mor bombanın oluşma ihtimalini %1 yap
User prompt
Duvarlar hareket ettirilemez olsun ve oyun başında siyah bur ekran olsun ekranda "duyguları vur" yazsın altında oyna yazsın eğer oyna butonuna basarsak oyunu başlatsın ve oynamaya başlayalım ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'ReferenceError: checkForStuckBalls is not defined' in or related to this line: 'checkForStuckBalls();' Line Number: 979
User prompt
Please fix the bug: 'ReferenceError: checkForStuckBalls is not defined' in or related to this line: 'checkForStuckBalls();' Line Number: 983
User prompt
Rastgele bir zamanda mor bir bomba olsun 5×5 alanda her şeyi yok etsin duvarlar dahil ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Duvarlarda eğer toplar sıkışır ise o bölgeye bir bomba oluştur ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Eğer 122 adet duvar oluşursa ekranda kazandın yazıp altında tekrar oyna yazsın ve en altta :eğer oyunumu beğendiysen yeni oyunlar gelicek" yazsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Her 100 puanda rastgele 5 yere duvar çıksın ve o duvar patlamasın
User prompt
Emojileri biraz büyült
User prompt
Eğer 5 top eşleşirse kırmızı bir bomba oluşsun ve eğer o bomba bir top ile yer değişirse 7×7 bir alanda patlama yapsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'alpha' in null' in or related to this line: 'tween(self.glowEffect, {' Line Number: 126 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Oyun alanını ve topların görüntüsünü büyülü ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Topları diğer toplar ile yer değiştirebililim
Code edit (1 edits merged)
Please save this source code
User prompt
Bomb Blast Match
Initial prompt
Bana 15×15 alanda farklı renklerde toplar oluştur her toplar 3 tanesi yandan veya yukarıdan eşleşirse 10 puan versin rastgele bir zamanda bomba gelsin o bomba başka bir top ile yerini değiştirirsen 3×3 alanda patlasın topları hareket ettirebilelim
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var GridCell = Container.expand(function (row, col) { var self = Container.call(this); self.row = row; self.col = col; self.ballType = null; self.ball = null; self.isBomb = false; self.isWall = false; var cellBg = self.attachAsset('grid_cell', { anchorX: 0.5, anchorY: 0.5 }); self.setBall = function (ballType) { if (self.ball) { self.removeChild(self.ball); } if (self.glowEffect) { self.removeChild(self.glowEffect); self.glowEffect = null; } if (ballType === 'wall') { self.ball = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5 }); self.isWall = true; self.isBomb = false; self.ballType = ballType; } else if (ballType === 'bomb' || ballType === 'red_bomb' || ballType === 'purple_bomb') { var bombAsset = ballType === 'red_bomb' ? 'red_bomb' : ballType === 'purple_bomb' ? 'purple_bomb' : 'bomb'; self.ball = self.attachAsset(bombAsset, { anchorX: 0.5, anchorY: 0.5 }); self.isBomb = true; self.ballType = ballType; // Add magical pulsing effect to bomb tween(self.ball, { scaleX: 1.2, scaleY: 1.2 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(self.ball, { scaleX: 1.0, scaleY: 1.0 }, { duration: 800, easing: tween.easeInOut }); } }); } else if (ballType) { // Add glow effect behind the ball self.glowEffect = self.attachAsset('glow_effect', { anchorX: 0.5, anchorY: 0.5 }); self.glowEffect.alpha = 0.3; self.glowEffect.tint = self.getBallColor(ballType); // Add the main ball self.ball = self.attachAsset('ball_' + ballType, { anchorX: 0.5, anchorY: 0.5 }); self.isBomb = false; self.ballType = ballType; // Add sparkle entrance effect self.ball.scaleX = 0; self.ball.scaleY = 0; tween(self.ball, { scaleX: 1, scaleY: 1 }, { duration: 400, easing: tween.elasticOut }); // Add continuous gentle glow pulsing self.startGlowAnimation(); } else { self.ball = null; self.ballType = null; self.isBomb = false; self.isWall = false; } }; self.down = function (x, y, obj) { if (self.ball) { selectedCell = self; } }; self.getBallColor = function (ballType) { var colors = { 'red': 0xff4444, 'blue': 0x4444ff, 'green': 0x44ff44, 'yellow': 0xffff44, 'purple': 0xff44ff, 'orange': 0xff8844 }; return colors[ballType] || 0xffffff; }; self.startGlowAnimation = function () { if (self.glowEffect) { var _pulseGlow = function pulseGlow() { if (self.glowEffect) { tween(self.glowEffect, { alpha: 0.6 }, { duration: 1500, easing: tween.easeInOut, onFinish: function onFinish() { if (self.glowEffect) { tween(self.glowEffect, { alpha: 0.3 }, { duration: 1500, easing: tween.easeInOut, onFinish: _pulseGlow }); } } }); } }; _pulseGlow(); } }; self.createSparkles = function () { for (var i = 0; i < 5; i++) { var sparkle = self.attachAsset('sparkle', { anchorX: 0.5, anchorY: 0.5 }); sparkle.x = (Math.random() - 0.5) * 80; sparkle.y = (Math.random() - 0.5) * 80; sparkle.alpha = 0.8; sparkle.scaleX = 0.5; sparkle.scaleY = 0.5; tween(sparkle, { x: sparkle.x + (Math.random() - 0.5) * 100, y: sparkle.y + (Math.random() - 0.5) * 100, alpha: 0, scaleX: 0, scaleY: 0 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { if (sparkle.parent) { sparkle.parent.removeChild(sparkle); } } }); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222222 }); /**** * Game Code ****/ var GRID_SIZE = 15; var CELL_SIZE = 126; var BALL_COLORS = ['red', 'blue', 'green', 'yellow', 'purple', 'orange']; var GRID_START_X = (2048 - GRID_SIZE * CELL_SIZE) / 2; var GRID_START_Y = 300; var grid = []; var selectedCell = null; var isAnimating = false; var bombSpawnCounter = 0; var lastWallSpawnScore = 0; var totalWallsCreated = 0; // Create score display var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Initialize grid function initializeGrid() { for (var row = 0; row < GRID_SIZE; row++) { grid[row] = []; for (var col = 0; col < GRID_SIZE; col++) { var cell = new GridCell(row, col); cell.x = GRID_START_X + col * CELL_SIZE + CELL_SIZE / 2; cell.y = GRID_START_Y + row * CELL_SIZE + CELL_SIZE / 2; var randomColor = BALL_COLORS[Math.floor(Math.random() * BALL_COLORS.length)]; cell.setBall(randomColor); grid[row][col] = cell; game.addChild(cell); } } } // Get random ball color function getRandomBallColor() { return BALL_COLORS[Math.floor(Math.random() * BALL_COLORS.length)]; } // Check if two cells are adjacent function areAdjacent(cell1, cell2) { var rowDiff = Math.abs(cell1.row - cell2.row); var colDiff = Math.abs(cell1.col - cell2.col); return rowDiff === 1 && colDiff === 0 || rowDiff === 0 && colDiff === 1; } // Swap balls between two cells function swapBalls(cell1, cell2) { var tempType = cell1.ballType; var tempIsBomb = cell1.isBomb; cell1.setBall(cell2.ballType); cell2.setBall(tempType); } // Check for matches starting from a specific cell function checkMatches() { var matchedCells = []; var fiveBallMatches = []; var visited = []; for (var row = 0; row < GRID_SIZE; row++) { visited[row] = []; for (var col = 0; col < GRID_SIZE; col++) { visited[row][col] = false; } } // Check horizontal matches for (var row = 0; row < GRID_SIZE; row++) { for (var col = 0; col < GRID_SIZE - 2; col++) { var cell = grid[row][col]; if (!cell.ball || cell.isBomb || cell.isWall || visited[row][col]) continue; var matchCount = 1; var matchCells = [cell]; for (var c = col + 1; c < GRID_SIZE; c++) { var nextCell = grid[row][c]; if (nextCell.ball && !nextCell.isBomb && !nextCell.isWall && nextCell.ballType === cell.ballType) { matchCount++; matchCells.push(nextCell); } else { break; } } if (matchCount >= 3) { for (var i = 0; i < matchCells.length; i++) { matchedCells.push(matchCells[i]); visited[matchCells[i].row][matchCells[i].col] = true; } // Check if it's a 5-ball match if (matchCount >= 5) { fiveBallMatches.push({ centerRow: matchCells[Math.floor(matchCells.length / 2)].row, centerCol: matchCells[Math.floor(matchCells.length / 2)].col }); } } } } // Check vertical matches for (var col = 0; col < GRID_SIZE; col++) { for (var row = 0; row < GRID_SIZE - 2; row++) { var cell = grid[row][col]; if (!cell.ball || cell.isBomb || cell.isWall || visited[row][col]) continue; var matchCount = 1; var matchCells = [cell]; for (var r = row + 1; r < GRID_SIZE; r++) { var nextCell = grid[r][col]; if (nextCell.ball && !nextCell.isBomb && !nextCell.isWall && nextCell.ballType === cell.ballType) { matchCount++; matchCells.push(nextCell); } else { break; } } if (matchCount >= 3) { for (var i = 0; i < matchCells.length; i++) { if (!visited[matchCells[i].row][matchCells[i].col]) { matchedCells.push(matchCells[i]); visited[matchCells[i].row][matchCells[i].col] = true; } } // Check if it's a 5-ball match if (matchCount >= 5) { fiveBallMatches.push({ centerRow: matchCells[Math.floor(matchCells.length / 2)].row, centerCol: matchCells[Math.floor(matchCells.length / 2)].col }); } } } } return { matchedCells: matchedCells, fiveBallMatches: fiveBallMatches }; } // Remove matched balls and update score function removeMatches(matchData, fiveBallMatches) { var matchedCells = matchData; if (matchedCells.length === 0) return; LK.setScore(LK.getScore() + matchedCells.length * 10); scoreTxt.setText('Score: ' + LK.getScore()); // Check if we should spawn walls every 100 points var currentScore = LK.getScore(); if (Math.floor(currentScore / 100) > Math.floor(lastWallSpawnScore / 100)) { lastWallSpawnScore = currentScore; LK.setTimeout(function () { spawnWalls(); }, 400); } for (var i = 0; i < matchedCells.length; i++) { // Create sparkle effect before removing matchedCells[i].createSparkles(); // Add magical disappear animation if (matchedCells[i].ball) { tween(matchedCells[i].ball, { scaleX: 0, scaleY: 0, alpha: 0 }, { duration: 300, easing: tween.easeIn }); } if (matchedCells[i].glowEffect) { tween(matchedCells[i].glowEffect, { scaleX: 2, scaleY: 2, alpha: 0 }, { duration: 300, easing: tween.easeOut }); } // Remove after animation LK.setTimeout(function (cell) { return function () { cell.setBall(null); }; }(matchedCells[i]), 300); } // Create red bombs for 5-ball matches if (fiveBallMatches && fiveBallMatches.length > 0) { LK.setTimeout(function () { for (var j = 0; j < fiveBallMatches.length; j++) { var bombPos = fiveBallMatches[j]; if (grid[bombPos.centerRow] && grid[bombPos.centerRow][bombPos.centerCol]) { grid[bombPos.centerRow][bombPos.centerCol].setBall('red_bomb'); } } }, 350); } LK.getSound('match').play(); } // Explode red bomb in 7x7 area function explodeRedBomb(centerRow, centerCol) { var clearedCells = []; // Create magical explosion wave effect var explosionCenter = grid[centerRow][centerCol]; for (var row = Math.max(0, centerRow - 3); row <= Math.min(GRID_SIZE - 1, centerRow + 3); row++) { for (var col = Math.max(0, centerCol - 3); col <= Math.min(GRID_SIZE - 1, centerCol + 3); col++) { var cell = grid[row][col]; if (cell.ball && !cell.isWall) { clearedCells.push(cell); // Create magical explosion effect var distance = Math.sqrt(Math.pow(row - centerRow, 2) + Math.pow(col - centerCol, 2)); var delay = distance * 80; // Stagger the explosions LK.setTimeout(function (targetCell) { return function () { targetCell.createSparkles(); if (targetCell.ball) { // Create explosive scale effect tween(targetCell.ball, { scaleX: 1.8, scaleY: 1.8 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { tween(targetCell.ball, { scaleX: 0, scaleY: 0, alpha: 0 }, { duration: 180, easing: tween.easeIn }); } }); } if (targetCell.glowEffect) { tween(targetCell.glowEffect, { scaleX: 4, scaleY: 4, alpha: 0 }, { duration: 300, easing: tween.easeOut }); } LK.setTimeout(function () { targetCell.setBall(null); }, 300); }; }(cell), delay); } } } LK.setScore(LK.getScore() + clearedCells.length * 8); scoreTxt.setText('Score: ' + LK.getScore()); // Check if we should spawn walls every 100 points var currentScore = LK.getScore(); if (Math.floor(currentScore / 100) > Math.floor(lastWallSpawnScore / 100)) { lastWallSpawnScore = currentScore; LK.setTimeout(function () { spawnWalls(); }, 400); } LK.getSound('bomb_explode').play(); } // Explode purple bomb in 5x5 area including walls function explodePurpleBomb(centerRow, centerCol) { var clearedCells = []; // Create magical explosion wave effect var explosionCenter = grid[centerRow][centerCol]; for (var row = Math.max(0, centerRow - 2); row <= Math.min(GRID_SIZE - 1, centerRow + 2); row++) { for (var col = Math.max(0, centerCol - 2); col <= Math.min(GRID_SIZE - 1, centerCol + 2); col++) { var cell = grid[row][col]; if (cell.ball) { clearedCells.push(cell); // Create magical explosion effect var distance = Math.sqrt(Math.pow(row - centerRow, 2) + Math.pow(col - centerCol, 2)); var delay = distance * 60; // Stagger the explosions LK.setTimeout(function (targetCell) { return function () { targetCell.createSparkles(); if (targetCell.ball) { // Create explosive scale effect tween(targetCell.ball, { scaleX: 2.0, scaleY: 2.0 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(targetCell.ball, { scaleX: 0, scaleY: 0, alpha: 0 }, { duration: 150, easing: tween.easeIn }); } }); } if (targetCell.glowEffect) { tween(targetCell.glowEffect, { scaleX: 5, scaleY: 5, alpha: 0 }, { duration: 250, easing: tween.easeOut }); } LK.setTimeout(function () { targetCell.setBall(null); }, 250); }; }(cell), delay); } } } LK.setScore(LK.getScore() + clearedCells.length * 12); scoreTxt.setText('Score: ' + LK.getScore()); // Check if we should spawn walls every 100 points var currentScore = LK.getScore(); if (Math.floor(currentScore / 100) > Math.floor(lastWallSpawnScore / 100)) { lastWallSpawnScore = currentScore; LK.setTimeout(function () { spawnWalls(); }, 400); } LK.getSound('bomb_explode').play(); } // Explode bomb in 3x3 area function explodeBomb(centerRow, centerCol) { var clearedCells = []; // Create magical explosion wave effect var explosionCenter = grid[centerRow][centerCol]; for (var row = Math.max(0, centerRow - 1); row <= Math.min(GRID_SIZE - 1, centerRow + 1); row++) { for (var col = Math.max(0, centerCol - 1); col <= Math.min(GRID_SIZE - 1, centerCol + 1); col++) { var cell = grid[row][col]; if (cell.ball && !cell.isWall) { clearedCells.push(cell); // Create magical explosion effect var distance = Math.sqrt(Math.pow(row - centerRow, 2) + Math.pow(col - centerCol, 2)); var delay = distance * 100; // Stagger the explosions LK.setTimeout(function (targetCell) { return function () { targetCell.createSparkles(); if (targetCell.ball) { // Create explosive scale effect tween(targetCell.ball, { scaleX: 1.5, scaleY: 1.5 }, { duration: 150, easing: tween.easeOut, onFinish: function onFinish() { tween(targetCell.ball, { scaleX: 0, scaleY: 0, alpha: 0 }, { duration: 200, easing: tween.easeIn }); } }); } if (targetCell.glowEffect) { tween(targetCell.glowEffect, { scaleX: 3, scaleY: 3, alpha: 0 }, { duration: 350, easing: tween.easeOut }); } LK.setTimeout(function () { targetCell.setBall(null); }, 350); }; }(cell), delay); } } } LK.setScore(LK.getScore() + clearedCells.length * 5); scoreTxt.setText('Score: ' + LK.getScore()); // Check if we should spawn walls every 100 points var currentScore = LK.getScore(); if (Math.floor(currentScore / 100) > Math.floor(lastWallSpawnScore / 100)) { lastWallSpawnScore = currentScore; LK.setTimeout(function () { spawnWalls(); }, 400); } LK.getSound('bomb_explode').play(); } // Drop balls down to fill empty spaces function dropBalls() { var moved = false; for (var col = 0; col < GRID_SIZE; col++) { for (var row = GRID_SIZE - 1; row >= 0; row--) { if (!grid[row][col].ball) { // Find the first ball above this empty space for (var r = row - 1; r >= 0; r--) { if (grid[r][col].ball && !grid[r][col].isWall) { grid[row][col].setBall(grid[r][col].ballType); grid[r][col].setBall(null); moved = true; break; } else if (grid[r][col].isWall) { break; } } } } } return moved; } // Fill empty spaces at the top with new balls function fillEmptySpaces() { for (var col = 0; col < GRID_SIZE; col++) { for (var row = 0; row < GRID_SIZE; row++) { if (!grid[row][col].ball) { var randomColor = getRandomBallColor(); grid[row][col].setBall(randomColor); // Add magical appearance delay based on position var delay = row * 50 + Math.random() * 100; if (grid[row][col].ball) { grid[row][col].ball.alpha = 0; grid[row][col].ball.y -= 50; LK.setTimeout(function (cell) { return function () { if (cell.ball) { tween(cell.ball, { alpha: 1, y: cell.ball.y + 50 }, { duration: 400, easing: tween.bounceOut }); } }; }(grid[row][col]), delay); } } } } } // Spawn walls at 5 random positions function spawnWalls() { var availableCells = []; for (var row = 0; row < GRID_SIZE; row++) { for (var col = 0; col < GRID_SIZE; col++) { if (grid[row][col].ball && !grid[row][col].isBomb && !grid[row][col].isWall) { availableCells.push(grid[row][col]); } } } if (availableCells.length >= 5) { for (var i = 0; i < 5; i++) { var randomIndex = Math.floor(Math.random() * availableCells.length); var selectedCell = availableCells[randomIndex]; selectedCell.setBall('wall'); totalWallsCreated++; availableCells.splice(randomIndex, 1); } } // Show win screen with custom text function showWinScreen() { // Create semi-transparent overlay var overlay = LK.getAsset('grid_cell', { anchorX: 0.5, anchorY: 0.5 }); overlay.width = 2048; overlay.height = 2732; overlay.alpha = 0.8; overlay.tint = 0x000000; overlay.x = 1024; overlay.y = 1366; game.addChild(overlay); // Create win text var winText = new Text2('KAZANDIN!', { size: 120, fill: 0x00FF00 }); winText.anchor.set(0.5, 0.5); winText.x = 1024; winText.y = 1200; game.addChild(winText); // Create play again text var playAgainText = new Text2('TEKRAR OYNA', { size: 80, fill: 0xFFFFFF }); playAgainText.anchor.set(0.5, 0.5); playAgainText.x = 1024; playAgainText.y = 1350; game.addChild(playAgainText); // Create bottom message text var bottomText = new Text2('Eğer oyunumu beğendiysen yeni oyunlar gelecek', { size: 60, fill: 0xFFFF00 }); bottomText.anchor.set(0.5, 0.5); bottomText.x = 1024; bottomText.y = 1500; game.addChild(bottomText); // Add click handler for play again playAgainText.down = function () { // Reset game state totalWallsCreated = 0; lastWallSpawnScore = 0; LK.setScore(0); scoreTxt.setText('Score: 0'); // Clear grid for (var row = 0; row < GRID_SIZE; row++) { for (var col = 0; col < GRID_SIZE; col++) { game.removeChild(grid[row][col]); } } grid = []; // Remove win screen elements game.removeChild(overlay); game.removeChild(winText); game.removeChild(playAgainText); game.removeChild(bottomText); // Reinitialize game initializeGrid(); isAnimating = false; selectedCell = null; }; // Add glow animation to win text tween(winText, { scaleX: 1.1, scaleY: 1.1 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(winText, { scaleX: 1.0, scaleY: 1.0 }, { duration: 1000, easing: tween.easeInOut }); } }); } // Check if balls are stuck around walls and create bombs function checkForStuckBalls() { var stuckAreas = []; // Find all wall positions for (var row = 0; row < GRID_SIZE; row++) { for (var col = 0; col < GRID_SIZE; col++) { if (grid[row][col].isWall) { // Check 3x3 area around this wall for stuck balls var surroundingBalls = []; var hasEmptySpace = false; for (var dr = -1; dr <= 1; dr++) { for (var dc = -1; dc <= 1; dc++) { var checkRow = row + dr; var checkCol = col + dc; if (checkRow >= 0 && checkRow < GRID_SIZE && checkCol >= 0 && checkCol < GRID_SIZE) { var checkCell = grid[checkRow][checkCol]; if (checkCell.ball && !checkCell.isWall && !checkCell.isBomb) { surroundingBalls.push(checkCell); } else if (!checkCell.ball) { hasEmptySpace = true; } } } } // If there are 6 or more balls around wall with no empty spaces // and no possible matches, consider them stuck if (surroundingBalls.length >= 6 && !hasEmptySpace) { var hasValidMove = false; // Check if any surrounding ball can make a match for (var i = 0; i < surroundingBalls.length; i++) { var ball = surroundingBalls[i]; // Check if this ball has matching neighbors var neighbors = [{ r: ball.row - 1, c: ball.col }, { r: ball.row + 1, c: ball.col }, { r: ball.row, c: ball.col - 1 }, { r: ball.row, c: ball.col + 1 }]; for (var j = 0; j < neighbors.length; j++) { var nr = neighbors[j].r; var nc = neighbors[j].c; if (nr >= 0 && nr < GRID_SIZE && nc >= 0 && nc < GRID_SIZE) { var neighborCell = grid[nr][nc]; if (neighborCell.ball && !neighborCell.isWall && neighborCell.ballType === ball.ballType) { hasValidMove = true; break; } } } if (hasValidMove) break; } if (!hasValidMove) { // Find best position for bomb (center of stuck area) var centerRow = Math.round(row); var centerCol = Math.round(col); // Find nearest non-wall cell to place bomb for (var radius = 1; radius <= 3; radius++) { for (var dr = -radius; dr <= radius; dr++) { for (var dc = -radius; dc <= radius; dc++) { var bombRow = centerRow + dr; var bombCol = centerCol + dc; if (bombRow >= 0 && bombRow < GRID_SIZE && bombCol >= 0 && bombCol < GRID_SIZE) { var bombCell = grid[bombRow][bombCol]; if (bombCell.ball && !bombCell.isWall && !bombCell.isBomb) { stuckAreas.push({ row: bombRow, col: bombCol }); radius = 4; // Break outer loops break; } } } if (radius > 3) break; } if (radius > 3) break; } } } } } } // Create bombs in stuck areas for (var k = 0; k < stuckAreas.length; k++) { var bombPos = stuckAreas[k]; grid[bombPos.row][bombPos.col].setBall('bomb'); // Add visual effect to indicate bomb was created due to stuck situation var bombCell = grid[bombPos.row][bombPos.col]; if (bombCell.ball) { bombCell.ball.tint = 0xff6666; // Reddish tint LK.setTimeout(function (cell) { return function () { if (cell.ball) { cell.ball.tint = 0xffffff; } }; }(bombCell), 1000); } } } } // Spawn a random bomb on the grid function spawnBomb() { var emptyCells = []; for (var row = 0; row < GRID_SIZE; row++) { for (var col = 0; col < GRID_SIZE; col++) { if (grid[row][col].ball && !grid[row][col].isBomb) { emptyCells.push(grid[row][col]); } } } if (emptyCells.length > 0) { var randomCell = emptyCells[Math.floor(Math.random() * emptyCells.length)]; // 20% chance for purple bomb, 80% chance for regular bomb var bombType = Math.random() < 0.2 ? 'purple_bomb' : 'bomb'; randomCell.setBall(bombType); } } // Clear previous selection visual feedback function clearSelectionTint() { if (selectedCell && selectedCell.ball) { selectedCell.ball.tint = 0xffffff; } } // Handle cell selection and swapping game.down = function (x, y, obj) { if (isAnimating) return; // Find clicked cell for (var row = 0; row < GRID_SIZE; row++) { for (var col = 0; col < GRID_SIZE; col++) { var cell = grid[row][col]; var cellPos = game.toLocal(cell.parent.toGlobal(cell.position)); var distance = Math.sqrt(Math.pow(x - cellPos.x, 2) + Math.pow(y - cellPos.y, 2)); if (distance < CELL_SIZE / 2 && cell.ball) { if (!selectedCell) { selectedCell = cell; // Tint the selected ball to show it's selected if (selectedCell.ball) { selectedCell.ball.tint = 0xaaaaaa; } } else if (selectedCell === cell) { // Deselect current cell clearSelectionTint(); selectedCell = null; } else if (areAdjacent(selectedCell, cell)) { // Clear selection tint before swapping clearSelectionTint(); // Handle bomb explosion if (selectedCell.isBomb) { if (selectedCell.ballType === 'red_bomb') { explodeRedBomb(cell.row, cell.col); } else if (selectedCell.ballType === 'purple_bomb') { explodePurpleBomb(cell.row, cell.col); } else { explodeBomb(cell.row, cell.col); } selectedCell.setBall(null); } else if (cell.isBomb) { if (cell.ballType === 'red_bomb') { explodeRedBomb(selectedCell.row, selectedCell.col); } else if (cell.ballType === 'purple_bomb') { explodePurpleBomb(selectedCell.row, selectedCell.col); } else { explodeBomb(selectedCell.row, selectedCell.col); } cell.setBall(null); } else { // Regular swap swapBalls(selectedCell, cell); } selectedCell = null; isAnimating = true; // Check for cascading matches LK.setTimeout(function () { processMatches(); }, 100); } else { // Clear previous selection and select new cell clearSelectionTint(); selectedCell = cell; // Tint the newly selected ball if (selectedCell.ball) { selectedCell.ball.tint = 0xaaaaaa; } } break; } } } }; // Process matches and cascades function processMatches() { var matchResult = checkMatches(); var matchedCells = matchResult.matchedCells; var fiveBallMatches = matchResult.fiveBallMatches; if (matchedCells.length > 0) { removeMatches(matchedCells, fiveBallMatches); LK.setTimeout(function () { dropBalls(); fillEmptySpaces(); LK.setTimeout(function () { processMatches(); // Check for cascade matches }, 200); }, 300); } else { isAnimating = false; } } // Initialize the game initializeGrid(); // Main game loop game.update = function () { bombSpawnCounter++; // Spawn bomb every 600 ticks (10 seconds at 60fps) if (bombSpawnCounter >= 600) { spawnBomb(); bombSpawnCounter = 0; } // Check for stuck balls every 300 ticks (5 seconds) if (bombSpawnCounter % 300 === 0) { checkForStuckBalls(); } };
===================================================================
--- original.js
+++ change.js
@@ -822,12 +822,8 @@
}(bombCell), 1000);
}
}
}
- // Spawn a random bomb on the grid
- if (totalWallsCreated >= 122) {
- showWinScreen();
- }
}
// Spawn a random bomb on the grid
function spawnBomb() {
var emptyCells = [];