User prompt
Add combo mechanics to the game, get more points when you make combos
User prompt
Put the score under money
User prompt
AND PUT THE SCORE NEXT TO THE SCREEN
User prompt
REMOVE THE CANDY BLAST CHAIN TEXT ON TOP
User prompt
ADD BACKGROUND TO SHOP
User prompt
SET THE NAME OF FIREWORK LINE EXPLODER TO WHITE
User prompt
Move the shop a little higher
User prompt
ADD FIRE WORK TO THE SHOP AND MAKE A LINE EXPLODES AND THE PRICE IS 20 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'explodeAreaBomb')' in or related to this line: 'self.explodeAreaBomb = function (row, col) {' Line Number: 673
User prompt
3x3 area bomb Lets explode a 3x3 area ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the name of the strong bomb 5x5 area bomb and make its price 25
User prompt
PUT A 3X3 AREA EXPLODING BOMB IN THE SHOP PRICE IS 15
User prompt
IF WE MATCH 4 OR MORE THAN 4 SUGAR, A SUGAR BOMB WILL COME OUT ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
IF WE EXPLODE 4 OR MORE THAN 4 CANDIES, A CANDY BOMB WILL COME OUT ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
IF WE EXPLODE 4 OR MORE THAN 4 CANDIES, A CANDY BOMB WILL COME OUT ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
IF WE EXPLODE MORE THAN 5 CANDIES, A CANDY BOMB WILL COME ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
If we explode more than 5 candies, a bomb will come ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add music
User prompt
IT'S TOO EARLY NOW, LET THE KNIFE BE JUST WHEN IT'S TOUCHING THE SUGAR ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
EXPLODE SOUND COMES VERY LATE
User prompt
ADD A KNIFE TO ASSETS AND COME AND CUT THE CANDIES AND GO ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
CANDIES SHOULD BE CUT INSTEAD OF EXPLODING
User prompt
CHANGE BACKGROUND APPEARANCE INSTEAD OF "bg"
User prompt
When we start our game, our money should be 0.
User prompt
MAKE THE PRICE OF THE POWERFUL BOMB 125
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { money: 0, strongBombUnlocked: false }); /**** * Classes ****/ var Candy = Container.expand(function (colorType) { var self = Container.call(this); self.colorType = colorType; self.isSelected = false; self.isExploding = false; var candyAssets = ['candy_red', 'candy_blue', 'candy_green', 'candy_yellow', 'candy_purple', 'candy_orange', 'candy_bomb', 'candy_money']; var candyGraphics = self.attachAsset(candyAssets[colorType], { anchorX: 0.5, anchorY: 0.5 }); self.setSelected = function (selected) { self.isSelected = selected; if (selected) { candyGraphics.scaleX = 1.2; candyGraphics.scaleY = 1.2; } else { candyGraphics.scaleX = 1.0; candyGraphics.scaleY = 1.0; } }; self.explode = function () { self.isExploding = true; // Cut effect: rotate and scale down with fade tween(candyGraphics, { rotation: Math.PI * 2, scaleX: 0.1, scaleY: 0.1, alpha: 0 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); var Grid = Container.expand(function () { var self = Container.call(this); self.gridWidth = 8; self.gridHeight = 12; self.cellSize = 130; self.candies = []; self.selectedGroup = []; self.isAnimating = false; // Initialize grid array for (var i = 0; i < self.gridHeight; i++) { self.candies[i] = []; for (var j = 0; j < self.gridWidth; j++) { self.candies[i][j] = null; } } self.getGridPosition = function (x, y) { var startX = (2048 - self.gridWidth * self.cellSize) / 2; var startY = 300; var col = Math.floor((x - startX) / self.cellSize); var row = Math.floor((y - startY) / self.cellSize); return { row: row, col: col }; }; self.getWorldPosition = function (row, col) { var startX = (2048 - self.gridWidth * self.cellSize) / 2; var startY = 300; return { x: startX + col * self.cellSize + self.cellSize / 2, y: startY + row * self.cellSize + self.cellSize / 2 }; }; self.createCandy = function (row, col) { var colorType; // 5% chance for money candy if (Math.random() < 0.05) { colorType = 7; // Money candy } else { colorType = Math.floor(Math.random() * 6); } var candy = new Candy(colorType); var pos = self.getWorldPosition(row, col); candy.x = pos.x; candy.y = pos.y; self.candies[row][col] = candy; self.addChild(candy); return candy; }; self.fillGrid = function () { for (var i = 0; i < self.gridHeight; i++) { for (var j = 0; j < self.gridWidth; j++) { if (!self.candies[i][j]) { self.createCandy(i, j); } } } }; self.findConnectedGroup = function (row, col, colorType, visited) { if (row < 0 || row >= self.gridHeight || col < 0 || col >= self.gridWidth) { return []; } if (visited[row][col] || !self.candies[row][col] || self.candies[row][col].colorType !== colorType) { return []; } visited[row][col] = true; var group = [{ row: row, col: col, candy: self.candies[row][col] }]; // Check adjacent cells (up, down, left, right) var directions = [[-1, 0], [1, 0], [0, -1], [0, 1]]; for (var d = 0; d < directions.length; d++) { var newRow = row + directions[d][0]; var newCol = col + directions[d][1]; var connected = self.findConnectedGroup(newRow, newCol, colorType, visited); group = group.concat(connected); } return group; }; self.selectGroup = function (row, col) { if (self.isAnimating || !self.candies[row][col]) return; // Clear previous selection self.clearSelection(); var visited = []; for (var i = 0; i < self.gridHeight; i++) { visited[i] = []; for (var j = 0; j < self.gridWidth; j++) { visited[i][j] = false; } } var colorType = self.candies[row][col].colorType; self.selectedGroup = self.findConnectedGroup(row, col, colorType, visited); if (self.selectedGroup.length >= 3) { for (var i = 0; i < self.selectedGroup.length; i++) { self.selectedGroup[i].candy.setSelected(true); } return true; } else { self.selectedGroup = []; return false; } }; self.clearSelection = function () { for (var i = 0; i < self.selectedGroup.length; i++) { if (self.selectedGroup[i].candy && !self.selectedGroup[i].candy.isExploding) { self.selectedGroup[i].candy.setSelected(false); } } self.selectedGroup = []; }; self.explodeBomb = function (row, col) { if (!self.candies[row][col] || self.candies[row][col].colorType !== 6) return 0; self.isAnimating = true; var points = 0; var bombsToExplode = []; // Explode 3x3 area around bomb for (var i = -1; i <= 1; i++) { for (var j = -1; j <= 1; j++) { var newRow = row + i; var newCol = col + j; if (newRow >= 0 && newRow < self.gridHeight && newCol >= 0 && newCol < self.gridWidth) { if (self.candies[newRow][newCol]) { bombsToExplode.push({ row: newRow, col: newCol, candy: self.candies[newRow][newCol] }); points += 10; } } } } // Explode all candies in the bomb area for (var i = 0; i < bombsToExplode.length; i++) { var item = bombsToExplode[i]; self.candies[item.row][item.col] = null; item.candy.explode(); } LK.getSound('explode').play(); // Apply gravity and spawn new candies after explosion animation LK.setTimeout(function () { self.applyGravity(); }, 350); return points; }; self.explodeStrongBomb = function (row, col) { self.isAnimating = true; var points = 0; var bombsToExplode = []; // Explode 5x5 area around selected position for (var i = -2; i <= 2; i++) { for (var j = -2; j <= 2; j++) { var newRow = row + i; var newCol = col + j; if (newRow >= 0 && newRow < self.gridHeight && newCol >= 0 && newCol < self.gridWidth) { if (self.candies[newRow][newCol]) { bombsToExplode.push({ row: newRow, col: newCol, candy: self.candies[newRow][newCol] }); points += 15; } } } } // Explode all candies in the bomb area for (var i = 0; i < bombsToExplode.length; i++) { var item = bombsToExplode[i]; self.candies[item.row][item.col] = null; item.candy.explode(); } LK.getSound('explode').play(); // Apply gravity and spawn new candies after explosion animation LK.setTimeout(function () { self.applyGravity(); }, 350); return points; }; self.explodeSelectedGroup = function () { if (self.selectedGroup.length < 3) return 0; self.isAnimating = true; var points = self.selectedGroup.length * 10; var shouldCreateBomb = false; // Bonus points for larger groups if (self.selectedGroup.length >= 5) { points += 50; shouldCreateBomb = true; } if (self.selectedGroup.length >= 7) { points += 100; } // Clear candy references from grid first for (var i = 0; i < self.selectedGroup.length; i++) { var item = self.selectedGroup[i]; self.candies[item.row][item.col] = null; } // Play explode sound immediately LK.getSound('explode').play(); // Create and animate knife to cut candies var knife = new Knife(); self.addChild(knife); knife.cutCandies(self.selectedGroup, function () { // Remove knife after cutting knife.destroy(); // Create bomb if 5 or more candies exploded if (shouldCreateBomb && self.selectedGroup.length > 0) { var bombRow = self.selectedGroup[0].row; var bombCol = self.selectedGroup[0].col; LK.setTimeout(function () { var bomb = new Candy(6); // Bomb candy type var pos = self.getWorldPosition(bombRow, bombCol); bomb.x = pos.x; bomb.y = pos.y; self.candies[bombRow][bombCol] = bomb; self.addChild(bomb); }, 100); } // Apply gravity and spawn new candies after cutting animation LK.setTimeout(function () { self.applyGravity(); }, 350); }); self.selectedGroup = []; return points; }; self.applyGravity = function () { var moved = false; // Move candies down for (var col = 0; col < self.gridWidth; col++) { for (var row = self.gridHeight - 1; row >= 0; row--) { if (!self.candies[row][col]) { // Find candy above to move down for (var searchRow = row - 1; searchRow >= 0; searchRow--) { if (self.candies[searchRow][col]) { self.candies[row][col] = self.candies[searchRow][col]; self.candies[searchRow][col] = null; var newPos = self.getWorldPosition(row, col); tween(self.candies[row][col], { x: newPos.x, y: newPos.y }, { duration: 200, easing: tween.easeIn }); moved = true; break; } } } } } // Fill empty spaces at top for (var col = 0; col < self.gridWidth; col++) { for (var row = 0; row < self.gridHeight; row++) { if (!self.candies[row][col]) { var candy = self.createCandy(row, col); // Start candy above screen and animate down candy.y = self.getWorldPosition(row, col).y - 500; var targetPos = self.getWorldPosition(row, col); tween(candy, { y: targetPos.y }, { duration: 300, easing: tween.easeOut }); } } } if (moved) { LK.getSound('cascade').play(); } // Check for chain reactions LK.setTimeout(function () { self.checkChainReactions(); }, 400); }; self.checkChainReactions = function () { // Simply finish the animation process without auto-exploding self.isAnimating = false; self.checkGameOver(); }; self.checkGameOver = function () { var visited = []; for (var i = 0; i < self.gridHeight; i++) { visited[i] = []; for (var j = 0; j < self.gridWidth; j++) { visited[i][j] = false; } } for (var row = 0; row < self.gridHeight; row++) { for (var col = 0; col < self.gridWidth; col++) { if (!visited[row][col] && self.candies[row][col]) { var group = self.findConnectedGroup(row, col, self.candies[row][col].colorType, visited); if (group.length >= 3) { return; // Game can continue } } } } // No valid moves left LK.setTimeout(function () { LK.showGameOver(); }, 1000); }; return self; }); var Knife = Container.expand(function () { var self = Container.call(this); var knifeGraphics = self.attachAsset('knife', { anchorX: 0.5, anchorY: 0.5 }); self.cutCandies = function (targetCandies, onComplete) { if (targetCandies.length === 0) { if (onComplete) onComplete(); return; } // Position knife at start position (off screen left) self.x = -200; self.y = targetCandies[0].candy.y; self.alpha = 1; // Calculate end position (off screen right) var endX = 2248; // Animate knife cutting across screen tween(self, { x: endX }, { duration: 500, easing: tween.easeInOut, onFinish: function onFinish() { // Fade out knife tween(self, { alpha: 0 }, { duration: 200, onFinish: function onFinish() { if (onComplete) onComplete(); } }); } }); // Trigger candy cutting effect when knife reaches each candy for (var i = 0; i < targetCandies.length; i++) { var candy = targetCandies[i].candy; var candyX = candy.x; var delay = (candyX + 200) / (endX + 200) * 500; // Calculate when knife reaches this candy (function (candyTocut) { LK.setTimeout(function () { if (candyTocut && !candyTocut.isExploding) { candyTocut.explode(); } }, delay); })(candy); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2E1065 }); /**** * Game Code ****/ // Add visual background var background = game.addChild(LK.getAsset('Bg', { anchorX: 0, anchorY: 0, scaleX: 20.48, scaleY: 27.32 })); background.x = 0; background.y = 0; var grid = game.addChild(new Grid()); var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y = 50; // Initialize score LK.setScore(0); scoreTxt.setText(LK.getScore().toString()); // Fill initial grid grid.fillGrid(); // Title text var titleTxt = new Text2('Candy Blast Chain', { size: 100, fill: 0xFFD700 }); titleTxt.anchor.set(0.5, 0); titleTxt.x = 2048 / 2; titleTxt.y = 50; game.addChild(titleTxt); // Instructions text var instructionsTxt = new Text2('Tap groups of 3+ same colored candies!', { size: 60, fill: 0xFFFFFF }); instructionsTxt.anchor.set(0.5, 0); instructionsTxt.x = 2048 / 2; instructionsTxt.y = 120; game.addChild(instructionsTxt); // Set money to 0 when game starts storage.money = 0; // Money counter var moneyTxt = new Text2('Money: ' + storage.money, { size: 80, fill: 0xFFD700 }); moneyTxt.anchor.set(0, 0); moneyTxt.x = 50; moneyTxt.y = 300; game.addChild(moneyTxt); // Shop UI var shopTxt = new Text2('SHOP', { size: 80, fill: 0xFFFFFF }); shopTxt.anchor.set(0.5, 0); shopTxt.x = 2048 / 2; shopTxt.y = 2400; game.addChild(shopTxt); var strongBombTxt = new Text2('Strong Bomb (Cost: 125)', { size: 60, fill: storage.strongBombUnlocked ? 0x00FF00 : 0xFFFFFF }); strongBombTxt.anchor.set(0.5, 0); strongBombTxt.x = 2048 / 2; strongBombTxt.y = 2500; game.addChild(strongBombTxt); var usingStrongBomb = false; var strongBombTimer = 0; var strongBombCooldown = 45000; // 45 seconds in milliseconds game.down = function (x, y, obj) { if (grid.isAnimating) return; // Check if clicked on shop area if (y >= 2400) { // Check if clicked on strong bomb purchase if (y >= 2500 && y <= 2600) { if (!storage.strongBombUnlocked && storage.money >= 125) { storage.money -= 125; storage.strongBombUnlocked = true; moneyTxt.setText('Money: ' + storage.money); strongBombTxt.setText('Strong Bomb (Unlocked!)'); strongBombTxt.fill = 0x00FF00; } else if (storage.strongBombUnlocked && !usingStrongBomb) { usingStrongBomb = true; strongBombTxt.setText('Select area to explode!'); strongBombTxt.fill = 0xFF0000; } } return; } var gridPos = grid.getGridPosition(x, y); if (gridPos.row >= 0 && gridPos.row < grid.gridHeight && gridPos.col >= 0 && gridPos.col < grid.gridWidth) { // Check if using strong bomb if (usingStrongBomb && storage.strongBombUnlocked) { var points = grid.explodeStrongBomb(gridPos.row, gridPos.col); LK.setScore(LK.getScore() + points); scoreTxt.setText(LK.getScore().toString()); usingStrongBomb = false; // Reset to purchasable state storage.strongBombUnlocked = false; strongBombTxt.setText('Strong Bomb (Cost: 125)'); strongBombTxt.fill = 0xFFFFFF; return; } // Check if clicked candy is money candy if (grid.candies[gridPos.row][gridPos.col] && grid.candies[gridPos.row][gridPos.col].colorType === 7) { // Give money and remove candy storage.money += 5; moneyTxt.setText('Money: ' + storage.money); grid.candies[gridPos.row][gridPos.col].explode(); grid.candies[gridPos.row][gridPos.col] = null; LK.setTimeout(function () { grid.applyGravity(); }, 350); return; } // Check if clicked candy is a bomb if (grid.candies[gridPos.row][gridPos.col] && grid.candies[gridPos.row][gridPos.col].colorType === 6) { // Explode bomb immediately var points = grid.explodeBomb(gridPos.row, gridPos.col); LK.setScore(LK.getScore() + points); scoreTxt.setText(LK.getScore().toString()); } else if (grid.selectGroup(gridPos.row, gridPos.col)) { // Valid group selected, explode on next tap LK.setTimeout(function () { if (grid.selectedGroup.length >= 3) { var points = grid.explodeSelectedGroup(); LK.setScore(LK.getScore() + points); scoreTxt.setText(LK.getScore().toString()); } }, 100); } } }; game.update = function () { // Timer logic removed - no cooldown needed };
===================================================================
--- original.js
+++ change.js
@@ -246,15 +246,16 @@
for (var i = 0; i < self.selectedGroup.length; i++) {
var item = self.selectedGroup[i];
self.candies[item.row][item.col] = null;
}
+ // Play explode sound immediately
+ LK.getSound('explode').play();
// Create and animate knife to cut candies
var knife = new Knife();
self.addChild(knife);
knife.cutCandies(self.selectedGroup, function () {
// Remove knife after cutting
knife.destroy();
- LK.getSound('explode').play();
// Create bomb if 5 or more candies exploded
if (shouldCreateBomb && self.selectedGroup.length > 0) {
var bombRow = self.selectedGroup[0].row;
var bombCol = self.selectedGroup[0].col;
uncut watermelon. In-Game asset. 2d. High contrast. No shadows
Coin. In-Game asset. 2d. High contrast. No shadows
uncut lemon. In-Game asset. 2d. High contrast. No shadows
Uncut orange. In-Game asset. 2d. High contrast. No shadows
Uncut dragonfruit. In-Game asset. 2d. High contrast. No shadows
Strawberry. In-Game asset. 2d. High contrast. No shadows
Blueberry. In-Game asset. 2d. High contrast. No shadows
Bomb. In-Game asset. 2d. High contrast. No shadows
HORIZONTAL BLADE. In-Game asset. 2d. High contrast. No shadows