User prompt
bombayı 1000.2000.3000 ve 4000 skoruna ulaşınca getir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
bomba ekrandaki bütün topları patlatsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
bombayı her 1000 skorda getir
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'destroy')' in or related to this line: 'ball.destroy();' Line Number: 381
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'destroy')' in or related to this line: 'target.destroy();' Line Number: 159
User prompt
bazen rast gele yerlere bir bomba koy ve bomba pataldığında 3x3 alanı patlat ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
hareketleri 50 yap
User prompt
arka planın rengini değiştir
User prompt
hedefi 5000 yap
User prompt
toplar patladığında parçacıklar çıksın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
toplara patlama efkti ver ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Ball Crush Saga
Initial prompt
candy crush yap şeker yerinede top olsun
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Ball = Container.expand(function (color, gridX, gridY) {
var self = Container.call(this);
self.ballColor = color;
self.gridX = gridX;
self.gridY = gridY;
self.isAnimating = false;
var ballTypes = ['ballBlue', 'ballRed', 'ballGreen', 'ballYellow', 'ballPurple', 'ballOrange'];
var ballGraphics = self.attachAsset(ballTypes[color], {
anchorX: 0.5,
anchorY: 0.5
});
self.setGridPosition = function (newGridX, newGridY) {
self.gridX = newGridX;
self.gridY = newGridY;
var worldPos = gridToWorld(newGridX, newGridY);
self.x = worldPos.x;
self.y = worldPos.y;
};
self.animateToPosition = function (newGridX, newGridY, onComplete) {
self.isAnimating = true;
self.gridX = newGridX;
self.gridY = newGridY;
var worldPos = gridToWorld(newGridX, newGridY);
tween(self, {
x: worldPos.x,
y: worldPos.y
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
self.isAnimating = false;
if (onComplete) onComplete();
}
});
};
return self;
});
var GridCell = Container.expand(function (gridX, gridY) {
var self = Container.call(this);
self.gridX = gridX;
self.gridY = gridY;
var cellGraphics = self.attachAsset('gridCell', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.3
});
var worldPos = gridToWorld(gridX, gridY);
self.x = worldPos.x;
self.y = worldPos.y;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
var GRID_SIZE = 8;
var CELL_SIZE = 90;
var GRID_OFFSET_X = (2048 - GRID_SIZE * CELL_SIZE) / 2;
var GRID_OFFSET_Y = 400;
var gameGrid = [];
var gridCells = [];
var selectedBall = null;
var isProcessingMatches = false;
var targetScore = 1000;
var movesLeft = 20;
function gridToWorld(gridX, gridY) {
return {
x: GRID_OFFSET_X + gridX * CELL_SIZE + CELL_SIZE / 2,
y: GRID_OFFSET_Y + gridY * CELL_SIZE + CELL_SIZE / 2
};
}
function worldToGrid(worldX, worldY) {
var gridX = Math.floor((worldX - GRID_OFFSET_X) / CELL_SIZE);
var gridY = Math.floor((worldY - GRID_OFFSET_Y) / CELL_SIZE);
return {
x: Math.max(0, Math.min(GRID_SIZE - 1, gridX)),
y: Math.max(0, Math.min(GRID_SIZE - 1, gridY))
};
}
function getRandomBallColor() {
return Math.floor(Math.random() * 6);
}
function initializeGrid() {
gameGrid = [];
for (var y = 0; y < GRID_SIZE; y++) {
gameGrid[y] = [];
for (var x = 0; x < GRID_SIZE; x++) {
gameGrid[y][x] = null;
}
}
// Create grid cells for visual feedback
for (var y = 0; y < GRID_SIZE; y++) {
for (var x = 0; x < GRID_SIZE; x++) {
var cell = new GridCell(x, y);
gridCells.push(cell);
game.addChild(cell);
}
}
// Fill grid with balls
fillGrid();
}
function fillGrid() {
for (var y = 0; y < GRID_SIZE; y++) {
for (var x = 0; x < GRID_SIZE; x++) {
if (gameGrid[y][x] === null) {
var color = getRandomBallColor();
var ball = new Ball(color, x, y);
ball.setGridPosition(x, y);
gameGrid[y][x] = ball;
game.addChild(ball);
}
}
}
}
function areAdjacent(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 swapBalls(ball1, ball2) {
if (!ball1 || !ball2) return;
var tempX = ball1.gridX;
var tempY = ball1.gridY;
gameGrid[ball1.gridY][ball1.gridX] = ball2;
gameGrid[ball2.gridY][ball2.gridX] = ball1;
ball1.animateToPosition(ball2.gridX, ball2.gridY);
ball2.animateToPosition(tempX, tempY);
LK.getSound('swap').play();
}
function findMatches() {
var matches = [];
// Check horizontal matches
for (var y = 0; y < GRID_SIZE; y++) {
var count = 1;
var currentColor = gameGrid[y][0] ? gameGrid[y][0].ballColor : -1;
for (var x = 1; x < GRID_SIZE; x++) {
var ball = gameGrid[y][x];
if (ball && ball.ballColor === currentColor) {
count++;
} else {
if (count >= 3) {
for (var i = x - count; i < x; i++) {
matches.push({
x: i,
y: y
});
}
}
currentColor = ball ? ball.ballColor : -1;
count = 1;
}
}
if (count >= 3) {
for (var i = GRID_SIZE - count; i < GRID_SIZE; i++) {
matches.push({
x: i,
y: y
});
}
}
}
// Check vertical matches
for (var x = 0; x < GRID_SIZE; x++) {
var count = 1;
var currentColor = gameGrid[0][x] ? gameGrid[0][x].ballColor : -1;
for (var y = 1; y < GRID_SIZE; y++) {
var ball = gameGrid[y][x];
if (ball && ball.ballColor === currentColor) {
count++;
} else {
if (count >= 3) {
for (var i = y - count; i < y; i++) {
matches.push({
x: x,
y: i
});
}
}
currentColor = ball ? ball.ballColor : -1;
count = 1;
}
}
if (count >= 3) {
for (var i = GRID_SIZE - count; i < GRID_SIZE; i++) {
matches.push({
x: x,
y: i
});
}
}
}
return matches;
}
function removeMatches(matches) {
if (matches.length === 0) return;
LK.getSound('match').play();
LK.setScore(LK.getScore() + matches.length * 10);
scoreText.setText(LK.getScore());
for (var i = 0; i < matches.length; i++) {
var match = matches[i];
var ball = gameGrid[match.y][match.x];
if (ball) {
// Create particle explosion effect
createParticleExplosion(ball.x, ball.y, ball.ballColor);
// Create explosion effect
tween(ball, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0,
rotation: Math.PI * 2
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
ball.destroy();
}
});
gameGrid[match.y][match.x] = null;
}
}
}
function dropBalls() {
var ballsDropped = false;
for (var x = 0; x < GRID_SIZE; x++) {
var writeIndex = GRID_SIZE - 1;
for (var y = GRID_SIZE - 1; y >= 0; y--) {
if (gameGrid[y][x] !== null) {
if (y !== writeIndex) {
gameGrid[writeIndex][x] = gameGrid[y][x];
gameGrid[y][x] = null;
gameGrid[writeIndex][x].animateToPosition(x, writeIndex);
ballsDropped = true;
}
writeIndex--;
}
}
// Fill empty spaces at top
for (var y = writeIndex; y >= 0; y--) {
var color = getRandomBallColor();
var ball = new Ball(color, x, y);
ball.setGridPosition(x, -1); // Start above grid
ball.animateToPosition(x, y);
gameGrid[y][x] = ball;
game.addChild(ball);
ballsDropped = true;
}
}
return ballsDropped;
}
function processMatches() {
if (isProcessingMatches) return;
isProcessingMatches = true;
var matches = findMatches();
if (matches.length > 0) {
removeMatches(matches);
LK.setTimeout(function () {
if (dropBalls()) {
LK.setTimeout(function () {
isProcessingMatches = false;
processMatches(); // Check for new matches
}, 400);
} else {
isProcessingMatches = false;
checkGameState();
}
}, 300);
} else {
isProcessingMatches = false;
checkGameState();
}
}
function createParticleExplosion(x, y, ballColor) {
var ballTypes = ['ballBlue', 'ballRed', 'ballGreen', 'ballYellow', 'ballPurple', 'ballOrange'];
var particleCount = 8;
for (var i = 0; i < particleCount; i++) {
var particle = LK.getAsset(ballTypes[ballColor], {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.3,
scaleY: 0.3
});
particle.x = x;
particle.y = y;
game.addChild(particle);
var angle = Math.PI * 2 * i / particleCount;
var speed = 80 + Math.random() * 40;
var targetX = x + Math.cos(angle) * speed;
var targetY = y + Math.sin(angle) * speed;
tween(particle, {
x: targetX,
y: targetY,
scaleX: 0,
scaleY: 0,
alpha: 0,
rotation: Math.PI * 4
}, {
duration: 400 + Math.random() * 200,
easing: tween.easeOut,
onFinish: function onFinish() {
particle.destroy();
}
});
}
}
function checkGameState() {
if (LK.getScore() >= targetScore) {
LK.showYouWin();
return;
}
if (movesLeft <= 0) {
LK.showGameOver();
return;
}
}
// UI Elements
var scoreText = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var movesText = new Text2('Moves: 20', {
size: 50,
fill: 0xFFFFFF
});
movesText.anchor.set(1, 0);
LK.gui.topRight.addChild(movesText);
var targetText = new Text2('Target: 1000', {
size: 50,
fill: 0xFFFFFF
});
targetText.anchor.set(0, 0);
LK.gui.topLeft.addChild(targetText);
// Initialize game
initializeGrid();
game.down = function (x, y, obj) {
if (isProcessingMatches) return;
var gridPos = worldToGrid(x, y);
var ball = gameGrid[gridPos.y][gridPos.x];
if (ball && !ball.isAnimating) {
if (selectedBall === null) {
selectedBall = ball;
tween(ball, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200
});
} else if (selectedBall === ball) {
// Deselect
tween(selectedBall, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
selectedBall = null;
} else if (areAdjacent(selectedBall.gridX, selectedBall.gridY, ball.gridX, ball.gridY)) {
// Attempt swap
var tempGrid = [];
for (var i = 0; i < GRID_SIZE; i++) {
tempGrid[i] = gameGrid[i].slice();
}
// Temporarily swap in grid to check for matches
tempGrid[selectedBall.gridY][selectedBall.gridX] = ball;
tempGrid[ball.gridY][ball.gridX] = selectedBall;
var tempBall1 = {
ballColor: ball.ballColor,
gridX: selectedBall.gridX,
gridY: selectedBall.gridY
};
var tempBall2 = {
ballColor: selectedBall.ballColor,
gridX: ball.gridX,
gridY: ball.gridY
};
tempGrid[selectedBall.gridY][selectedBall.gridX] = tempBall1;
tempGrid[ball.gridY][ball.gridX] = tempBall2;
// Check if this swap creates any matches
var wouldCreateMatch = false;
var testMatches = [];
// Check horizontal matches around swapped positions
for (var testY = 0; testY < GRID_SIZE; testY++) {
var count = 1;
var currentColor = tempGrid[testY][0] ? tempGrid[testY][0].ballColor : -1;
for (var testX = 1; testX < GRID_SIZE; testX++) {
var testBall = tempGrid[testY][testX];
if (testBall && testBall.ballColor === currentColor) {
count++;
} else {
if (count >= 3) {
wouldCreateMatch = true;
break;
}
currentColor = testBall ? testBall.ballColor : -1;
count = 1;
}
}
if (wouldCreateMatch || count >= 3) {
wouldCreateMatch = true;
break;
}
}
if (!wouldCreateMatch) {
// Check vertical matches
for (var testX = 0; testX < GRID_SIZE; testX++) {
var count = 1;
var currentColor = tempGrid[0][testX] ? tempGrid[0][testX].ballColor : -1;
for (var testY = 1; testY < GRID_SIZE; testY++) {
var testBall = tempGrid[testY][testX];
if (testBall && testBall.ballColor === currentColor) {
count++;
} else {
if (count >= 3) {
wouldCreateMatch = true;
break;
}
currentColor = testBall ? testBall.ballColor : -1;
count = 1;
}
}
if (wouldCreateMatch || count >= 3) {
wouldCreateMatch = true;
break;
}
}
}
if (wouldCreateMatch) {
swapBalls(selectedBall, ball);
movesLeft--;
movesText.setText('Moves: ' + movesLeft);
LK.setTimeout(function () {
processMatches();
}, 400);
}
tween(selectedBall, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
selectedBall = null;
} else {
// Select new ball
tween(selectedBall, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
selectedBall = ball;
tween(ball, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200
});
}
}
};
game.update = function () {
// Update UI
scoreText.setText('Score: ' + LK.getScore());
// Check for initial matches and remove them
if (LK.ticks === 60) {
// After 1 second
processMatches();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -214,8 +214,10 @@
for (var i = 0; i < matches.length; i++) {
var match = matches[i];
var ball = gameGrid[match.y][match.x];
if (ball) {
+ // Create particle explosion effect
+ createParticleExplosion(ball.x, ball.y, ball.ballColor);
// Create explosion effect
tween(ball, {
scaleX: 1.5,
scaleY: 1.5,
@@ -281,8 +283,41 @@
isProcessingMatches = false;
checkGameState();
}
}
+function createParticleExplosion(x, y, ballColor) {
+ var ballTypes = ['ballBlue', 'ballRed', 'ballGreen', 'ballYellow', 'ballPurple', 'ballOrange'];
+ var particleCount = 8;
+ for (var i = 0; i < particleCount; i++) {
+ var particle = LK.getAsset(ballTypes[ballColor], {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.3,
+ scaleY: 0.3
+ });
+ particle.x = x;
+ particle.y = y;
+ game.addChild(particle);
+ var angle = Math.PI * 2 * i / particleCount;
+ var speed = 80 + Math.random() * 40;
+ var targetX = x + Math.cos(angle) * speed;
+ var targetY = y + Math.sin(angle) * speed;
+ tween(particle, {
+ x: targetX,
+ y: targetY,
+ scaleX: 0,
+ scaleY: 0,
+ alpha: 0,
+ rotation: Math.PI * 4
+ }, {
+ duration: 400 + Math.random() * 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ particle.destroy();
+ }
+ });
+ }
+}
function checkGameState() {
if (LK.getScore() >= targetScore) {
LK.showYouWin();
return;
dil çıkaran top . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
mutlu yeşil top . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
şaşırmış turuncu top . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
gözlüklü mor top . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
kızgın kırmızı top . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
ağlayan mavi top . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
bomba . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat