User prompt
gizli özellik ekliyorum kayan bir yıldıza tıklanırsa ekrandaki herşey gider 4 top blirir sırasıyla 1. top 1. top 1. top 3 topa tıklanırsa oyun geri gelir ve butun toplar sadece disko topu kırmızıroket bombadan ibaret olur ve patladıkça score 20x artar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
duvarlar hareket ettirilemez oyuncu tarafından ama aşşağıya doğru oyun gereği hareket eder
User prompt
tekrar dene
User prompt
Please fix the bug: 'Uncaught TypeError: candy.makeSpecial is not a function' in or related to this line: 'candy.makeSpecial('discoBall');' Line Number: 1110
User prompt
duvarın yanında şeker patlarsa duvar çatlar ve bu 2. kez olursa yok olur ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
yok olna topların kareleri %5 olasılıkla duvara dönuşur 2 kere yakınında şeker patlatmadan kırılmaz ve duvar hareket etmez ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
bir topun üstüne 3 kere tıklanırsa 1000 altın eksilir ve tıklanan top disko topu olur ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
satın almayı kaldır
User prompt
konturol türü ya sürükliyerek yada ik sürüklencek olana tıklatp sonra yer değiştirilecek olana tıklanacak ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
kombo olduğunda ekranda kombo yazar x simgesiyle kaç kombo olusa sayı artar kombo bitince yazıda kaybolur ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Fps düzeltmesi
User prompt
50 altın karşılığında bir disko topu alınabilir seçilen top yerine gelir ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Test modu iptal
User prompt
Kaydırarak topları hareket ettir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
tekrar dolmadı ve patlayan tüm şekerler kombo ve score puanı verir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
olmadı ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
tüm toplar yok oluca üstten rasgele yeni toplar düşücek ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
disko topu ile disko topu kombolanırsa tüm kareler patlar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
her rengin 5 kombosu farklıdır ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
test modu başlatıorum tüm renklerin beşli kombolanmış hali olsun
User prompt
test modu iptal
User prompt
disko topu özelliğini ekle ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
6 lı kombo sonucu ortaya çıkan disko topunun yok ettiği topların yeri dolmuyor
User prompt
yok olan tüm şekerlerin yeri yukardan düşrn toplarla tekrar dolar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
tekrar 6lı kombolama deneesi bu
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Candy = Container.expand(function (type, row, col) {
var self = Container.call(this);
self.type = type;
self.row = row;
self.col = col;
self.isSpecial = false;
self.specialType = null;
self.matchCount = 0;
var assetMap = {
'blue': 'blueCandy',
'red': 'redCandy',
'green': 'greenCandy',
'orange': 'orangeCandy',
'purple': 'purpleCandy'
};
var specialAssetMap = {
'blueBomb': 'blueBomb',
'redRocket': 'redRocket',
'greenPentagon': 'greenPentagon',
'orangeLollipop': 'orangeLollipop',
'purpleBerry': 'purpleBerry',
'discoBall': 'discoBall'
};
self.graphics = self.attachAsset(assetMap[type], {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
self.makeSpecial = function (specialType) {
self.isSpecial = true;
self.specialType = specialType;
self.removeChild(self.graphics);
self.graphics = self.attachAsset(specialAssetMap[specialType], {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
};
self.explode = function () {
tween(self, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
if (self.parent) {
self.parent.removeChild(self);
}
}
});
};
return self;
});
var ShootingStar = Container.expand(function () {
var self = Container.call(this);
var star = LK.getAsset('gridLine', {
width: 8,
height: 8,
color: 0xFFFFFF,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(star);
// Set random starting position at top of screen
self.x = Math.random() * 2048;
self.y = -50;
// Set falling speed
self.speed = Math.random() * 5 + 3;
// Add trail effect
self.alpha = 0.9;
self.update = function () {
self.y += self.speed;
// Remove when off screen
if (self.y > 2732 + 50) {
if (self.parent) {
self.parent.removeChild(self);
}
}
};
return self;
});
var StarField = Container.expand(function () {
var self = Container.call(this);
var stars = [];
var numStars = 100;
self.twinkle = function (star) {
var targetAlpha = Math.random() * 0.8 + 0.2;
var duration = Math.random() * 2000 + 1000;
tween(star, {
alpha: targetAlpha
}, {
duration: duration,
easing: tween.easeInOut,
onFinish: function onFinish() {
self.twinkle(star);
}
});
};
// Create individual stars
for (var i = 0; i < numStars; i++) {
var star = LK.getAsset('gridLine', {
width: Math.random() * 6 + 2,
height: Math.random() * 6 + 2,
color: 0xFFFFFF,
shape: 'ellipse',
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 2732,
alpha: Math.random() * 0.8 + 0.2
});
self.addChild(star);
stars.push(star);
// Start twinkling animation for each star
self.twinkle(star);
}
// Track shooting stars
var shootingStars = [];
// Create shooting star occasionally
self.createShootingStar = function () {
var shootingStar = new ShootingStar();
self.addChild(shootingStar);
shootingStars.push(shootingStar);
};
self.update = function () {
// Clean up shooting stars that are off screen
for (var i = shootingStars.length - 1; i >= 0; i--) {
if (shootingStars[i].y > 2732 + 50) {
shootingStars.splice(i, 1);
}
}
// Randomly create shooting stars
if (Math.random() < 0.003) {
// 0.3% chance per frame
self.createShootingStar();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2E1065
});
/****
* Game Code
****/
var GRID_SIZE = 8;
var CELL_SIZE = 200;
var GRID_START_X = 224;
var GRID_START_Y = 566;
var COLORS = ['blue', 'red', 'green', 'orange', 'purple'];
var grid = [];
var selectedCandy = null;
var score = 0;
var level = 1;
var gold = 0;
var isProcessing = false;
var comboMultiplier = 1;
// Create animated starfield background
var starField = new StarField();
game.addChild(starField);
// Create grid background
var gridBg = game.attachAsset('gridBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
// Create grid lines
for (var i = 0; i <= GRID_SIZE; i++) {
// Vertical lines
var verticalLine = LK.getAsset('gridLine', {
width: 4,
height: GRID_SIZE * CELL_SIZE,
color: 0x000000,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: GRID_START_X + i * CELL_SIZE,
y: GRID_START_Y + GRID_SIZE * CELL_SIZE / 2
});
game.addChild(verticalLine);
// Horizontal lines
var horizontalLine = LK.getAsset('gridLine', {
width: GRID_SIZE * CELL_SIZE,
height: 4,
color: 0x000000,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: GRID_START_X + GRID_SIZE * CELL_SIZE / 2,
y: GRID_START_Y + i * CELL_SIZE
});
game.addChild(horizontalLine);
}
// Create UI elements
var scoreText = new Text2('Score: 0', {
size: 80,
fill: '#FFFFFF'
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
scoreText.y = 100;
var levelText = new Text2('Level: 1', {
size: 60,
fill: '#FFFFFF'
});
levelText.anchor.set(0, 0);
LK.gui.topLeft.addChild(levelText);
levelText.x = 120;
levelText.y = 100;
var goldText = new Text2('Gold: 0', {
size: 60,
fill: '#FFD700'
});
goldText.anchor.set(1, 0);
LK.gui.topRight.addChild(goldText);
goldText.x = -20;
goldText.y = 100;
// Create level progress bar
var progressBarBg = LK.getAsset('progressBarBg', {
anchorX: 0.5,
anchorY: 0.5
});
LK.gui.top.addChild(progressBarBg);
progressBarBg.y = 200;
var progressBarFill = LK.getAsset('progressBarFill', {
anchorX: 0,
anchorY: 0.5
});
progressBarBg.addChild(progressBarFill);
progressBarFill.x = -300; // Start from left edge of background
progressBarFill.scaleX = 0; // Start empty
// Initialize grid
function initializeGrid() {
grid = [];
for (var row = 0; row < GRID_SIZE; row++) {
grid[row] = [];
for (var col = 0; col < GRID_SIZE; col++) {
var color;
// Test mode: Create 5-combo special candies for all colors
if (row === 0) {
// First row: 5 blue candies for blue bomb
color = 'blue';
} else if (row === 1) {
// Second row: 5 red candies for red rocket
color = 'red';
} else if (row === 2) {
// Third row: 5 green candies for green pentagon
color = 'green';
} else if (row === 3) {
// Fourth row: 5 orange candies for orange lollipop
color = 'orange';
} else if (row === 4) {
// Fifth row: 5 purple candies for purple berry
color = 'purple';
} else {
// Remaining rows: random colors
color = COLORS[Math.floor(Math.random() * COLORS.length)];
}
var candy = new Candy(color, row, col);
candy.x = GRID_START_X + col * CELL_SIZE + CELL_SIZE / 2;
candy.y = GRID_START_Y + row * CELL_SIZE + CELL_SIZE / 2;
grid[row][col] = candy;
game.addChild(candy);
}
}
}
function removeInitialMatches() {
var hasMatches = true;
while (hasMatches) {
hasMatches = false;
for (var row = 0; row < GRID_SIZE; row++) {
for (var col = 0; col < GRID_SIZE; col++) {
if (checkMatch(row, col).length >= 3) {
hasMatches = true;
var randomColor = COLORS[Math.floor(Math.random() * COLORS.length)];
grid[row][col].type = randomColor;
grid[row][col].removeChild(grid[row][col].graphics);
var assetMap = {
'blue': 'blueCandy',
'red': 'redCandy',
'green': 'greenCandy',
'orange': 'orangeCandy',
'purple': 'purpleCandy'
};
grid[row][col].graphics = grid[row][col].attachAsset(assetMap[randomColor], {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8
});
}
}
}
}
}
function getCandyAt(x, y) {
var col = Math.floor((x - GRID_START_X) / CELL_SIZE);
var row = Math.floor((y - GRID_START_Y) / CELL_SIZE);
if (row >= 0 && row < GRID_SIZE && col >= 0 && col < GRID_SIZE) {
return grid[row][col];
}
return null;
}
function swapCandies(candy1, candy2) {
if (!candy1 || !candy2 || candy1 === candy2) return false;
var row1 = candy1.row,
col1 = candy1.col;
var row2 = candy2.row,
col2 = candy2.col;
// Check if adjacent
var dx = Math.abs(col1 - col2);
var dy = Math.abs(row1 - row2);
if (dx + dy !== 1) return false;
// Swap in grid
grid[row1][col1] = candy2;
grid[row2][col2] = candy1;
// Update candy properties
candy1.row = row2;
candy1.col = col2;
candy2.row = row1;
candy2.col = col1;
// Animate swap
tween(candy1, {
x: GRID_START_X + col2 * CELL_SIZE + CELL_SIZE / 2,
y: GRID_START_Y + row2 * CELL_SIZE + CELL_SIZE / 2
}, {
duration: 200
});
tween(candy2, {
x: GRID_START_X + col1 * CELL_SIZE + CELL_SIZE / 2,
y: GRID_START_Y + row1 * CELL_SIZE + CELL_SIZE / 2
}, {
duration: 200
});
return true;
}
function checkMatch(row, col) {
if (!grid[row] || !grid[row][col]) return [];
var candy = grid[row][col];
var matches = [candy];
var type = candy.type;
// Check horizontal
for (var c = col - 1; c >= 0 && grid[row][c] && grid[row][c].type === type; c--) {
matches.unshift(grid[row][c]);
}
for (var c = col + 1; c < GRID_SIZE && grid[row][c] && grid[row][c].type === type; c++) {
matches.push(grid[row][c]);
}
if (matches.length >= 3) return matches;
// Check vertical
matches = [candy];
for (var r = row - 1; r >= 0 && grid[r][col] && grid[r][col].type === type; r--) {
matches.unshift(grid[r][col]);
}
for (var r = row + 1; r < GRID_SIZE && grid[r][col] && grid[r][col].type === type; r++) {
matches.push(grid[r][col]);
}
return matches.length >= 3 ? matches : [];
}
function findAllMatches() {
var allMatches = [];
var processed = [];
for (var row = 0; row < GRID_SIZE; row++) {
processed[row] = [];
for (var col = 0; col < GRID_SIZE; col++) {
processed[row][col] = false;
}
}
for (var row = 0; row < GRID_SIZE; row++) {
for (var col = 0; col < GRID_SIZE; col++) {
if (!processed[row][col]) {
var matches = checkMatch(row, col);
if (matches.length >= 3) {
allMatches.push(matches);
for (var i = 0; i < matches.length; i++) {
processed[matches[i].row][matches[i].col] = true;
}
}
}
}
}
return allMatches;
}
function processMatches() {
var allMatches = findAllMatches();
if (allMatches.length === 0) {
comboMultiplier = 1;
isProcessing = false;
return;
}
// Process matches and create special candies
var totalScore = 0;
var totalGold = 0;
for (var m = 0; m < allMatches.length; m++) {
var matches = allMatches[m];
var matchScore = matches.length * 10 * comboMultiplier;
var matchGold = matches.length * 5;
if (comboMultiplier > 1) {
matchGold += 50; // Combo bonus
}
totalScore += matchScore;
totalGold += matchGold;
// Check for special candy creation
if (matches.length >= 6) {
// Create disco ball with visual effect
var centerCandy = matches[Math.floor(matches.length / 2)];
centerCandy.makeSpecial('discoBall');
// Add creation sparkle effect
tween(centerCandy.graphics, {
scaleX: 1.0,
scaleY: 1.0,
rotation: Math.PI
}, {
duration: 300,
easing: tween.bounceOut
});
// Add continuous rotation to disco ball
var _rotateDiscoBall = function rotateDiscoBall() {
if (centerCandy.isSpecial && centerCandy.specialType === 'discoBall' && centerCandy.parent) {
tween(centerCandy.graphics, {
rotation: centerCandy.graphics.rotation + Math.PI * 2
}, {
duration: 2000,
easing: tween.linear,
onFinish: _rotateDiscoBall
});
}
};
_rotateDiscoBall();
matches.splice(Math.floor(matches.length / 2), 1);
} else if (matches.length === 5) {
// Create special based on color with unique effects
var centerCandy = matches[2];
var color = centerCandy.type;
var specialType;
if (color === 'blue') {
specialType = 'blueBomb';
} else if (color === 'red') {
specialType = 'redRocket';
} else if (color === 'green') {
specialType = 'greenPentagon';
} else if (color === 'orange') {
specialType = 'orangeLollipop';
} else if (color === 'purple') {
specialType = 'purpleBerry';
}
centerCandy.makeSpecial(specialType);
matches.splice(2, 1);
}
// Explode remaining matches
for (var i = 0; i < matches.length; i++) {
var candy = matches[i];
grid[candy.row][candy.col] = null;
candy.explode();
}
}
score += totalScore;
gold += totalGold;
comboMultiplier += 5;
// Update level
var newLevel = Math.floor(score / 200) + 1;
if (newLevel > level) {
level = newLevel;
// Level up animation - flash progress bar
tween(progressBarFill, {
tint: 0xFFFF00
}, {
duration: 200,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(progressBarFill, {
tint: 0x00FF00
}, {
duration: 200,
easing: tween.easeInOut
});
}
});
if (level % 5 === 0) {
gold += 4000;
}
}
updateUI();
LK.getSound('match').play();
// Drop candies and continue processing
LK.setTimeout(function () {
dropCandies();
LK.setTimeout(function () {
processMatches();
}, 300);
}, 400);
}
function dropCandies() {
for (var col = 0; col < GRID_SIZE; col++) {
var writeRow = GRID_SIZE - 1;
// Move existing candies down
for (var row = GRID_SIZE - 1; row >= 0; row--) {
if (grid[row][col] !== null) {
if (row !== writeRow) {
grid[writeRow][col] = grid[row][col];
grid[row][col] = null;
grid[writeRow][col].row = writeRow;
grid[writeRow][col].col = col;
tween(grid[writeRow][col], {
y: GRID_START_Y + writeRow * CELL_SIZE + CELL_SIZE / 2
}, {
duration: 200,
easing: tween.easeOut
});
}
writeRow--;
}
}
// Create new candies for empty spaces - they fall from above
var emptySpaces = writeRow + 1; // Number of empty spaces from top
for (var row = writeRow; row >= 0; row--) {
var randomColor = COLORS[Math.floor(Math.random() * COLORS.length)];
var candy = new Candy(randomColor, row, col);
candy.x = GRID_START_X + col * CELL_SIZE + CELL_SIZE / 2;
// Start candies above the visible grid area
var startRow = row - emptySpaces;
candy.y = GRID_START_Y + startRow * CELL_SIZE + CELL_SIZE / 2;
grid[row][col] = candy;
game.addChild(candy);
// Animate falling with bounce effect
tween(candy, {
y: GRID_START_Y + row * CELL_SIZE + CELL_SIZE / 2
}, {
duration: 300 + (emptySpaces - (writeRow - row)) * 50,
easing: tween.bounceOut
});
}
}
}
function updateUI() {
scoreText.setText('Score: ' + score);
levelText.setText('Level: ' + level);
goldText.setText('Gold: ' + gold);
// Update progress bar
var currentLevelScore = (level - 1) * 200;
var nextLevelScore = level * 200;
var progress = (score - currentLevelScore) / (nextLevelScore - currentLevelScore);
progress = Math.max(0, Math.min(1, progress)); // Clamp between 0 and 1
// Animate progress bar fill
tween(progressBarFill, {
scaleX: progress
}, {
duration: 300,
easing: tween.easeOut
});
}
function activateSpecialCandy(candy) {
if (!candy.isSpecial) return;
var row = candy.row;
var col = candy.col;
switch (candy.specialType) {
case 'blueBomb':
// Destroy 3x3 area
for (var r = Math.max(0, row - 1); r <= Math.min(GRID_SIZE - 1, row + 1); r++) {
for (var c = Math.max(0, col - 1); c <= Math.min(GRID_SIZE - 1, col + 1); c++) {
if (grid[r][c] && grid[r][c] !== candy) {
grid[r][c].explode();
grid[r][c] = null;
}
}
}
break;
case 'redRocket':
// Clear entire row and column
for (var c = 0; c < GRID_SIZE; c++) {
if (grid[row][c] && grid[row][c] !== candy) {
grid[row][c].explode();
grid[row][c] = null;
}
}
for (var r = 0; r < GRID_SIZE; r++) {
if (grid[r][col] && grid[r][col] !== candy) {
grid[r][col].explode();
grid[r][col] = null;
}
}
break;
case 'greenPentagon':
// Destroy candies in a plus pattern (5 directions)
var directions = [[-2, 0], [-1, 0], [0, 0], [1, 0], [2, 0],
// Horizontal line
[0, -2], [0, -1], [0, 1], [0, 2] // Vertical line (excluding center)
];
for (var d = 0; d < directions.length; d++) {
var newRow = row + directions[d][0];
var newCol = col + directions[d][1];
if (newRow >= 0 && newRow < GRID_SIZE && newCol >= 0 && newCol < GRID_SIZE) {
if (grid[newRow][newCol] && grid[newRow][newCol] !== candy) {
grid[newRow][newCol].explode();
grid[newRow][newCol] = null;
}
}
}
break;
case 'orangeLollipop':
// Destroy all candies of the same color as adjacent candies
var adjacentColors = [];
var adjacentPositions = [[-1, 0], [1, 0], [0, -1], [0, 1]];
for (var a = 0; a < adjacentPositions.length; a++) {
var adjRow = row + adjacentPositions[a][0];
var adjCol = col + adjacentPositions[a][1];
if (adjRow >= 0 && adjRow < GRID_SIZE && adjCol >= 0 && adjCol < GRID_SIZE) {
if (grid[adjRow][adjCol] && adjacentColors.indexOf(grid[adjRow][adjCol].type) === -1) {
adjacentColors.push(grid[adjRow][adjCol].type);
}
}
}
// Destroy all candies of adjacent colors with staggered timing
var destroyIndex = 0;
for (var r = 0; r < GRID_SIZE; r++) {
for (var c = 0; c < GRID_SIZE; c++) {
if (grid[r][c] && grid[r][c] !== candy && adjacentColors.indexOf(grid[r][c].type) !== -1) {
(function (targetCandy, delay) {
LK.setTimeout(function () {
if (targetCandy.parent) {
tween(targetCandy.graphics, {
tint: 0xFFA500
}, {
duration: 100,
onFinish: function onFinish() {
targetCandy.explode();
grid[targetCandy.row][targetCandy.col] = null;
}
});
}
}, delay);
})(grid[r][c], destroyIndex * 30);
destroyIndex++;
}
}
}
break;
case 'purpleBerry':
// Create a wave effect that spreads outward in rings
var maxDistance = 3;
for (var distance = 1; distance <= maxDistance; distance++) {
(function (dist) {
LK.setTimeout(function () {
for (var r = Math.max(0, row - dist); r <= Math.min(GRID_SIZE - 1, row + dist); r++) {
for (var c = Math.max(0, col - dist); c <= Math.min(GRID_SIZE - 1, col + dist); c++) {
// Only destroy candies on the ring edge
var actualDist = Math.max(Math.abs(r - row), Math.abs(c - col));
if (actualDist === dist && grid[r][c] && grid[r][c] !== candy) {
tween(grid[r][c].graphics, {
tint: 0x9013fe,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 150,
onFinish: function onFinish() {
if (grid[r] && grid[r][c]) {
grid[r][c].explode();
grid[r][c] = null;
}
}
});
}
}
}
}, (dist - 1) * 200);
})(distance);
}
break;
case 'discoBall':
// Create sparkle effect on disco ball before activation
tween(candy.graphics, {
scaleX: 1.2,
scaleY: 1.2,
rotation: Math.PI * 2
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Destroy 13 random candies
var randomCandies = [];
for (var r = 0; r < GRID_SIZE; r++) {
for (var c = 0; c < GRID_SIZE; c++) {
if (grid[r][c] && grid[r][c] !== candy) {
randomCandies.push(grid[r][c]);
}
}
}
// Destroy candies with staggered timing for visual effect
var destroyCount = Math.min(13, randomCandies.length);
for (var i = 0; i < destroyCount; i++) {
(function (index) {
LK.setTimeout(function () {
if (randomCandies.length > 0) {
var randomIndex = Math.floor(Math.random() * randomCandies.length);
var randomCandy = randomCandies[randomIndex];
// Flash the candy white before exploding
tween(randomCandy.graphics, {
tint: 0xFFFFFF
}, {
duration: 100,
onFinish: function onFinish() {
randomCandy.explode();
grid[randomCandy.row][randomCandy.col] = null;
}
});
randomCandies.splice(randomIndex, 1);
}
}, index * 50);
})(i);
}
}
});
break;
}
candy.explode();
grid[row][col] = null;
LK.getSound('powerup').play();
// Drop candies to fill empty spaces after special candy activation
LK.setTimeout(function () {
dropCandies();
LK.setTimeout(function () {
processMatches();
}, 300);
}, 400);
}
game.down = function (x, y, obj) {
if (isProcessing) return;
var candy = getCandyAt(x, y);
if (!candy) return;
if (selectedCandy === null) {
selectedCandy = candy;
// Add white glowing border effect
candy.graphics.tint = 0xFFFFFF; // Keep original color
tween(candy.graphics, {
tint: 0xFFFF00
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (selectedCandy === candy) {
tween(candy.graphics, {
tint: 0xFFFFFF
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (selectedCandy === candy) {
// Restart the glow animation
tween(candy.graphics, {
tint: 0xFFFF00
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: arguments.callee
});
}
}
});
}
}
});
// Create pulsing white glow effect
tween(candy, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
} else if (selectedCandy === candy) {
// Deselect - stop glowing animation and scale back
tween.stop(candy.graphics, {
tint: true
}); // Stop the glowing animation
candy.graphics.tint = 0xFFFFFF; // Remove tint
tween(candy, {
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 100
});
selectedCandy = null;
} else {
// Check if candies are adjacent
var dx = Math.abs(selectedCandy.col - candy.col);
var dy = Math.abs(selectedCandy.row - candy.row);
if (dx + dy === 1) {
// Remove selection effects from first candy
tween.stop(selectedCandy.graphics, {
tint: true
}); // Stop the glowing animation
selectedCandy.graphics.tint = 0xFFFFFF; // Remove tint
tween(selectedCandy, {
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 100
});
// Try to swap
var tempSelectedCandy = selectedCandy;
selectedCandy = null;
isProcessing = true;
if (swapCandies(tempSelectedCandy, candy)) {
LK.setTimeout(function () {
// Check if swap creates matches
var matches1 = checkMatch(tempSelectedCandy.row, tempSelectedCandy.col);
var matches2 = checkMatch(candy.row, candy.col);
if (matches1.length >= 3 || matches2.length >= 3 || tempSelectedCandy.isSpecial || candy.isSpecial) {
// Valid move
if (tempSelectedCandy.isSpecial) {
activateSpecialCandy(tempSelectedCandy);
}
if (candy.isSpecial) {
activateSpecialCandy(candy);
}
LK.setTimeout(function () {
processMatches();
}, 200);
} else {
// Invalid move, swap back with animation
swapCandies(tempSelectedCandy, candy);
isProcessing = false;
}
}, 250);
}
} else {
// Not adjacent - remove selection from first candy and select new one
tween.stop(selectedCandy.graphics, {
tint: true
}); // Stop the glowing animation
selectedCandy.graphics.tint = 0xFFFFFF; // Remove tint
tween(selectedCandy, {
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 100
});
// Select the new candy
selectedCandy = candy;
// Add white glowing border effect
candy.graphics.tint = 0xFFFFFF; // Keep original color
tween(candy.graphics, {
tint: 0xFFFF00
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (selectedCandy === candy) {
tween(candy.graphics, {
tint: 0xFFFFFF
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: function onFinish() {
if (selectedCandy === candy) {
// Restart the glow animation
tween(candy.graphics, {
tint: 0xFFFF00
}, {
duration: 500,
easing: tween.easeInOut,
onFinish: arguments.callee
});
}
}
});
}
}
});
tween(candy, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
}
}
};
// Initialize the game
initializeGrid();
updateUI();
LK.playMusic('bgmusic'); ===================================================================
--- original.js
+++ change.js
@@ -447,12 +447,23 @@
};
_rotateDiscoBall();
matches.splice(Math.floor(matches.length / 2), 1);
} else if (matches.length === 5) {
- // Create special based on color
+ // Create special based on color with unique effects
var centerCandy = matches[2];
var color = centerCandy.type;
- var specialType = color + (color === 'blue' ? 'Bomb' : color === 'red' ? 'Rocket' : color === 'green' ? 'Pentagon' : color === 'orange' ? 'Lollipop' : 'Berry');
+ var specialType;
+ if (color === 'blue') {
+ specialType = 'blueBomb';
+ } else if (color === 'red') {
+ specialType = 'redRocket';
+ } else if (color === 'green') {
+ specialType = 'greenPentagon';
+ } else if (color === 'orange') {
+ specialType = 'orangeLollipop';
+ } else if (color === 'purple') {
+ specialType = 'purpleBerry';
+ }
centerCandy.makeSpecial(specialType);
matches.splice(2, 1);
}
// Explode remaining matches
@@ -587,8 +598,94 @@
grid[r][col] = null;
}
}
break;
+ case 'greenPentagon':
+ // Destroy candies in a plus pattern (5 directions)
+ var directions = [[-2, 0], [-1, 0], [0, 0], [1, 0], [2, 0],
+ // Horizontal line
+ [0, -2], [0, -1], [0, 1], [0, 2] // Vertical line (excluding center)
+ ];
+ for (var d = 0; d < directions.length; d++) {
+ var newRow = row + directions[d][0];
+ var newCol = col + directions[d][1];
+ if (newRow >= 0 && newRow < GRID_SIZE && newCol >= 0 && newCol < GRID_SIZE) {
+ if (grid[newRow][newCol] && grid[newRow][newCol] !== candy) {
+ grid[newRow][newCol].explode();
+ grid[newRow][newCol] = null;
+ }
+ }
+ }
+ break;
+ case 'orangeLollipop':
+ // Destroy all candies of the same color as adjacent candies
+ var adjacentColors = [];
+ var adjacentPositions = [[-1, 0], [1, 0], [0, -1], [0, 1]];
+ for (var a = 0; a < adjacentPositions.length; a++) {
+ var adjRow = row + adjacentPositions[a][0];
+ var adjCol = col + adjacentPositions[a][1];
+ if (adjRow >= 0 && adjRow < GRID_SIZE && adjCol >= 0 && adjCol < GRID_SIZE) {
+ if (grid[adjRow][adjCol] && adjacentColors.indexOf(grid[adjRow][adjCol].type) === -1) {
+ adjacentColors.push(grid[adjRow][adjCol].type);
+ }
+ }
+ }
+ // Destroy all candies of adjacent colors with staggered timing
+ var destroyIndex = 0;
+ for (var r = 0; r < GRID_SIZE; r++) {
+ for (var c = 0; c < GRID_SIZE; c++) {
+ if (grid[r][c] && grid[r][c] !== candy && adjacentColors.indexOf(grid[r][c].type) !== -1) {
+ (function (targetCandy, delay) {
+ LK.setTimeout(function () {
+ if (targetCandy.parent) {
+ tween(targetCandy.graphics, {
+ tint: 0xFFA500
+ }, {
+ duration: 100,
+ onFinish: function onFinish() {
+ targetCandy.explode();
+ grid[targetCandy.row][targetCandy.col] = null;
+ }
+ });
+ }
+ }, delay);
+ })(grid[r][c], destroyIndex * 30);
+ destroyIndex++;
+ }
+ }
+ }
+ break;
+ case 'purpleBerry':
+ // Create a wave effect that spreads outward in rings
+ var maxDistance = 3;
+ for (var distance = 1; distance <= maxDistance; distance++) {
+ (function (dist) {
+ LK.setTimeout(function () {
+ for (var r = Math.max(0, row - dist); r <= Math.min(GRID_SIZE - 1, row + dist); r++) {
+ for (var c = Math.max(0, col - dist); c <= Math.min(GRID_SIZE - 1, col + dist); c++) {
+ // Only destroy candies on the ring edge
+ var actualDist = Math.max(Math.abs(r - row), Math.abs(c - col));
+ if (actualDist === dist && grid[r][c] && grid[r][c] !== candy) {
+ tween(grid[r][c].graphics, {
+ tint: 0x9013fe,
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 150,
+ onFinish: function onFinish() {
+ if (grid[r] && grid[r][c]) {
+ grid[r][c].explode();
+ grid[r][c] = null;
+ }
+ }
+ });
+ }
+ }
+ }
+ }, (dist - 1) * 200);
+ })(distance);
+ }
+ break;
case 'discoBall':
// Create sparkle effect on disco ball before activation
tween(candy.graphics, {
scaleX: 1.2,