User prompt
Özel şekere dokundugumda etrafındaki 2 karelik alandaki diger şekerleri kaldıracak ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Özel şeker silinmesin
User prompt
Özel şeker sadece 1 tane olucak
User prompt
Özel şeker sadece 1 kare olucak ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Eger 4 tane aynı renk bir araya gelirse yeni bir varlık şeker oluşucak ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bir skor puanı ekle
User prompt
Eger bir topu hareket ettirdigimde en az 3 aynı renk biraraya gelmiyorsa topu eski yerine koy ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Sadece ekranda toplar kalsın
User prompt
Oyun arka planını sil
User prompt
Toplar 1 kare hareket edebilir ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Onları 3 renk aynı koydugumda patlamalı ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bir topa dokundugumda onu aşagı yukarı saga ve sola hareket ettirmeliyim ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Diger bütün topları ekledigim kırmızı top gibi fakat renllerini koruyarak degiştir
User prompt
Oyunu ekrana ortala
User prompt
Dahada büyült
User prompt
Oyun ekranını büyült
User prompt
Top Renkler birbirine çok benziyor degiştir
User prompt
Aynı renkten 3 tane yanyana gelirse patlıcak
Code edit (1 edits merged)
Please save this source code
User prompt
Sweet Match Mania
Initial prompt
Candy crusş tarzı bir oyun
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Candy = Container.expand(function (type) { var self = Container.call(this); self.candyType = type; self.gridX = -1; self.gridY = -1; self.isMatched = false; self.isMoving = false; self.isDragging = false; // Background removed - only candy graphics remain var candyGraphic = self.attachAsset('candy' + type, { anchorX: 0.5, anchorY: 0.5 }); self.setGridPosition = function (gridX, gridY) { self.gridX = gridX; self.gridY = gridY; self.x = GRID_START_X + gridX * CELL_SIZE; self.y = GRID_START_Y + gridY * CELL_SIZE; }; self.animateToPosition = function (targetX, targetY, onComplete) { self.isMoving = true; tween(self, { x: targetX, y: targetY }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { self.isMoving = false; if (onComplete) onComplete(); } }); }; self.markForDestroy = function () { self.isMatched = true; tween(self, { scaleX: 0, scaleY: 0, alpha: 0 }, { duration: 300, easing: tween.easeIn, onFinish: function onFinish() { self.destroy(); } }); }; self.down = function (x, y, obj) { if (gameState !== 'playing' || self.isMoving) return; selectedCandy = self; self.scaleX = 1.1; self.scaleY = 1.1; self.isDragging = true; self.dragStartX = x; self.dragStartY = y; self.startX = self.x; self.startY = self.y; }; self.move = function (x, y, obj) { if (self.isDragging && gameState === 'playing' && !self.isMoving) { var deltaX = x - self.dragStartX; var deltaY = y - self.dragStartY; // Determine which direction has the larger movement var absDeltaX = Math.abs(deltaX); var absDeltaY = Math.abs(deltaY); var targetX = self.startX; var targetY = self.startY; // Only move in the direction with the larger delta, and limit to one cell if (absDeltaX > absDeltaY) { // Horizontal movement if (deltaX > CELL_SIZE / 2 && self.gridX < GRID_SIZE - 1) { targetX = self.startX + CELL_SIZE; } else if (deltaX < -CELL_SIZE / 2 && self.gridX > 0) { targetX = self.startX - CELL_SIZE; } } else { // Vertical movement if (deltaY > CELL_SIZE / 2 && self.gridY < GRID_SIZE - 1) { targetY = self.startY + CELL_SIZE; } else if (deltaY < -CELL_SIZE / 2 && self.gridY > 0) { targetY = self.startY - CELL_SIZE; } } self.x = targetX; self.y = targetY; } }; self.up = function (x, y, obj) { if (gameState !== 'playing' || self.isMoving) return; if (self.isDragging) { self.isDragging = false; // Find target grid position based on current visual position var targetX = Math.round((self.x - GRID_START_X) / CELL_SIZE); var targetY = Math.round((self.y - GRID_START_Y) / CELL_SIZE); // Clamp to grid bounds targetX = Math.max(0, Math.min(GRID_SIZE - 1, targetX)); targetY = Math.max(0, Math.min(GRID_SIZE - 1, targetY)); // If position changed, try to swap if (targetX !== self.gridX || targetY !== self.gridY) { var targetCandy = grid[targetX][targetY]; if (targetCandy && targetCandy !== self) { // Swap candies in grid grid[self.gridX][self.gridY] = targetCandy; grid[targetX][targetY] = self; var tempGridX = self.gridX; var tempGridY = self.gridY; self.gridX = targetX; self.gridY = targetY; targetCandy.gridX = tempGridX; targetCandy.gridY = tempGridY; // Animate both candies to their new positions var targetX1 = GRID_START_X + self.gridX * CELL_SIZE; var targetY1 = GRID_START_Y + self.gridY * CELL_SIZE; var targetX2 = GRID_START_X + targetCandy.gridX * CELL_SIZE; var targetY2 = GRID_START_Y + targetCandy.gridY * CELL_SIZE; self.animateToPosition(targetX1, targetY1, function () { checkForMatches(); }); targetCandy.animateToPosition(targetX2, targetY2); } else { // Return to original position tween(self, { x: GRID_START_X + self.gridX * CELL_SIZE, y: GRID_START_Y + self.gridY * CELL_SIZE }, { duration: 300, easing: tween.easeOut }); } } else { // Return to original position tween(self, { x: GRID_START_X + self.gridX * CELL_SIZE, y: GRID_START_Y + self.gridY * CELL_SIZE }, { duration: 300, easing: tween.easeOut }); } self.scaleX = 1; self.scaleY = 1; selectedCandy = null; } else if (selectedCandy === self) { self.scaleX = 1; self.scaleY = 1; selectedCandy = null; } else if (selectedCandy && isAdjacent(selectedCandy, self)) { attemptSwap(selectedCandy, self); selectedCandy.scaleX = 1; selectedCandy.scaleY = 1; selectedCandy = null; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game(); /**** * Game Code ****/ // Bright Cyan // Bright Magenta // Bright Yellow // Bright Blue // Bright Green // Bright Red var GRID_SIZE = 12; var CELL_SIZE = 140; var GRID_START_X = (2048 - GRID_SIZE * CELL_SIZE) / 2; var GRID_START_Y = (2732 - GRID_SIZE * CELL_SIZE) / 2; var CANDY_TYPES = 6; var grid = []; var selectedCandy = null; var gameState = 'playing'; var score = 0; var moves = 30; var targetScore = 1000; // UI elements removed - only candy balls remain on screen function initializeGrid() { grid = []; for (var x = 0; x < GRID_SIZE; x++) { grid[x] = []; for (var y = 0; y < GRID_SIZE; y++) { var candyType = Math.floor(Math.random() * CANDY_TYPES) + 1; var candy = new Candy(candyType); candy.setGridPosition(x, y); grid[x][y] = candy; game.addChild(candy); } } // Remove initial matches removeInitialMatches(); } function removeInitialMatches() { var hasMatches = true; var iterations = 0; while (hasMatches && iterations < 10) { hasMatches = false; for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { if (wouldCreateMatch(x, y, grid[x][y].candyType)) { var newType = Math.floor(Math.random() * CANDY_TYPES) + 1; grid[x][y].destroy(); var candy = new Candy(newType); candy.setGridPosition(x, y); grid[x][y] = candy; game.addChild(candy); hasMatches = true; } } } iterations++; } } function wouldCreateMatch(x, y, type) { // Check horizontal matches var horizontalCount = 1; var left = x - 1; while (left >= 0 && grid[left][y] && grid[left][y].candyType === type) { horizontalCount++; left--; } var right = x + 1; while (right < GRID_SIZE && grid[right][y] && grid[right][y].candyType === type) { horizontalCount++; right++; } // Check vertical matches var verticalCount = 1; var up = y - 1; while (up >= 0 && grid[x][up] && grid[x][up].candyType === type) { verticalCount++; up--; } var down = y + 1; while (down < GRID_SIZE && grid[x][down] && grid[x][down].candyType === type) { verticalCount++; down++; } return horizontalCount >= 3 || verticalCount >= 3; } function isAdjacent(candy1, candy2) { var dx = Math.abs(candy1.gridX - candy2.gridX); var dy = Math.abs(candy1.gridY - candy2.gridY); return dx === 1 && dy === 0 || dx === 0 && dy === 1; } function attemptSwap(candy1, candy2) { if (moves <= 0) return; // Temporarily swap positions var tempX = candy1.gridX; var tempY = candy1.gridY; candy1.gridX = candy2.gridX; candy1.gridY = candy2.gridY; candy2.gridX = tempX; candy2.gridY = tempY; grid[candy1.gridX][candy1.gridY] = candy1; grid[candy2.gridX][candy2.gridY] = candy2; // Check if this creates matches var matches1 = findMatches(candy1.gridX, candy1.gridY); var matches2 = findMatches(candy2.gridX, candy2.gridY); if (matches1.length > 0 || matches2.length > 0) { // Valid swap - animate moves--; // Moves text removed var targetX1 = GRID_START_X + candy1.gridX * CELL_SIZE; var targetY1 = GRID_START_Y + candy1.gridY * CELL_SIZE; var targetX2 = GRID_START_X + candy2.gridX * CELL_SIZE; var targetY2 = GRID_START_Y + candy2.gridY * CELL_SIZE; candy1.animateToPosition(targetX1, targetY1); candy2.animateToPosition(targetX2, targetY2, function () { LK.getSound('swap').play(); processMatches(); }); } else { // Invalid swap - revert candy1.gridX = tempX; candy1.gridY = tempY; candy2.gridX = candy2.gridX; candy2.gridY = candy2.gridY; grid[candy1.gridX][candy1.gridY] = candy1; grid[candy2.gridX][candy2.gridY] = candy2; } } function findMatches(x, y) { var matches = []; var candy = grid[x][y]; if (!candy) return matches; var type = candy.candyType; // Check horizontal matches var horizontal = [candy]; var left = x - 1; while (left >= 0 && grid[left][y] && grid[left][y].candyType === type) { horizontal.unshift(grid[left][y]); left--; } var right = x + 1; while (right < GRID_SIZE && grid[right][y] && grid[right][y].candyType === type) { horizontal.push(grid[right][y]); right++; } if (horizontal.length >= 3) { matches = matches.concat(horizontal); } // Check vertical matches var vertical = [candy]; var up = y - 1; while (up >= 0 && grid[x][up] && grid[x][up].candyType === type) { vertical.unshift(grid[x][up]); up--; } var down = y + 1; while (down < GRID_SIZE && grid[x][down] && grid[x][down].candyType === type) { vertical.push(grid[x][down]); down++; } if (vertical.length >= 3) { matches = matches.concat(vertical); } return matches; } function processMatches() { var allMatches = []; var processedCandies = []; // Find all matches on the grid for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { if (grid[x][y] && !grid[x][y].isMatched) { // Check horizontal matches (3+ in a row) var horizontalMatches = []; var currentType = grid[x][y].candyType; var startX = x; // Find consecutive candies of same type horizontally while (startX < GRID_SIZE && grid[startX][y] && grid[startX][y].candyType === currentType) { horizontalMatches.push(grid[startX][y]); startX++; } // If we found 3 or more consecutive horizontal matches if (horizontalMatches.length >= 3) { for (var i = 0; i < horizontalMatches.length; i++) { if (allMatches.indexOf(horizontalMatches[i]) === -1) { allMatches.push(horizontalMatches[i]); } } } // Check vertical matches (3+ in a column) var verticalMatches = []; var startY = y; // Find consecutive candies of same type vertically while (startY < GRID_SIZE && grid[x][startY] && grid[x][startY].candyType === currentType) { verticalMatches.push(grid[x][startY]); startY++; } // If we found 3 or more consecutive vertical matches if (verticalMatches.length >= 3) { for (var i = 0; i < verticalMatches.length; i++) { if (allMatches.indexOf(verticalMatches[i]) === -1) { allMatches.push(verticalMatches[i]); } } } } } } if (allMatches.length > 0) { // Mark matches for destruction and update score for (var i = 0; i < allMatches.length; i++) { var candy = allMatches[i]; candy.markForDestroy(); grid[candy.gridX][candy.gridY] = null; score += 10; } // Score text removed LK.getSound('match').play(); // Drop candies after delay LK.setTimeout(function () { dropCandies(); }, 350); } } function dropCandies() { var hasDropped = false; // Drop existing candies for (var x = 0; x < GRID_SIZE; x++) { var writeIndex = GRID_SIZE - 1; for (var y = GRID_SIZE - 1; y >= 0; y--) { if (grid[x][y] !== null) { if (y !== writeIndex) { grid[x][writeIndex] = grid[x][y]; grid[x][y] = null; grid[x][writeIndex].gridX = x; grid[x][writeIndex].gridY = writeIndex; var targetX = GRID_START_X + x * CELL_SIZE; var targetY = GRID_START_Y + writeIndex * CELL_SIZE; grid[x][writeIndex].animateToPosition(targetX, targetY); hasDropped = true; } writeIndex--; } } // Fill empty spaces with new candies for (var y = 0; y < GRID_SIZE; y++) { if (grid[x][y] === null) { var candyType = Math.floor(Math.random() * CANDY_TYPES) + 1; var candy = new Candy(candyType); candy.gridX = x; candy.gridY = y; candy.x = GRID_START_X + x * CELL_SIZE; candy.y = GRID_START_Y - (GRID_SIZE - y) * CELL_SIZE; var targetY = GRID_START_Y + y * CELL_SIZE; candy.animateToPosition(candy.x, targetY); grid[x][y] = candy; game.addChild(candy); hasDropped = true; } } } if (hasDropped) { LK.setTimeout(function () { processMatches(); }, 250); } else { checkGameState(); } } function checkForMatches() { var allMatches = []; // Check all positions for matches for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { if (grid[x][y] && !grid[x][y].isMatched) { var candy = grid[x][y]; var matches = findMatchesAt(x, y, candy.candyType); // Add unique matches to allMatches for (var i = 0; i < matches.length; i++) { if (allMatches.indexOf(matches[i]) === -1) { allMatches.push(matches[i]); } } } } } if (allMatches.length > 0) { // Mark matches for destruction and update score for (var i = 0; i < allMatches.length; i++) { var candy = allMatches[i]; candy.markForDestroy(); grid[candy.gridX][candy.gridY] = null; score += 10; } // Score text removed LK.getSound('match').play(); // Drop candies after delay LK.setTimeout(function () { dropCandies(); }, 350); } } function findMatchesAt(x, y, candyType) { var matches = []; // Check horizontal matches (3+ in a row) var horizontalMatches = [grid[x][y]]; // Check left var left = x - 1; while (left >= 0 && grid[left][y] && grid[left][y].candyType === candyType && !grid[left][y].isMatched) { horizontalMatches.unshift(grid[left][y]); left--; } // Check right var right = x + 1; while (right < GRID_SIZE && grid[right][y] && grid[right][y].candyType === candyType && !grid[right][y].isMatched) { horizontalMatches.push(grid[right][y]); right++; } if (horizontalMatches.length >= 3) { matches = matches.concat(horizontalMatches); } // Check vertical matches (3+ in a column) var verticalMatches = [grid[x][y]]; // Check up var up = y - 1; while (up >= 0 && grid[x][up] && grid[x][up].candyType === candyType && !grid[x][up].isMatched) { verticalMatches.unshift(grid[x][up]); up--; } // Check down var down = y + 1; while (down < GRID_SIZE && grid[x][down] && grid[x][down].candyType === candyType && !grid[x][down].isMatched) { verticalMatches.push(grid[x][down]); down++; } if (verticalMatches.length >= 3) { // Remove duplicates if candy is part of both horizontal and vertical match for (var i = 0; i < verticalMatches.length; i++) { if (matches.indexOf(verticalMatches[i]) === -1) { matches.push(verticalMatches[i]); } } } return matches; } function checkGameState() { if (score >= targetScore) { gameState = 'won'; LK.showYouWin(); } else if (moves <= 0) { gameState = 'lost'; LK.showGameOver(); } } // Initialize the game initializeGrid(); game.update = function () { // Game loop updates handled by individual object updates };
===================================================================
--- original.js
+++ change.js
@@ -13,12 +13,9 @@
self.gridY = -1;
self.isMatched = false;
self.isMoving = false;
self.isDragging = false;
- var background = self.attachAsset('cellBackground', {
- anchorX: 0.5,
- anchorY: 0.5
- });
+ // Background removed - only candy graphics remain
var candyGraphic = self.attachAsset('candy' + type, {
anchorX: 0.5,
anchorY: 0.5
});
@@ -189,33 +186,9 @@
var gameState = 'playing';
var score = 0;
var moves = 30;
var targetScore = 1000;
-// Initialize score display
-var scoreText = new Text2('Score: 0', {
- size: 60,
- fill: 0xFFFFFF
-});
-scoreText.anchor.set(0.5, 0);
-LK.gui.top.addChild(scoreText);
-// Initialize moves display
-var movesText = new Text2('Moves: 30', {
- size: 50,
- fill: 0xFFFFFF
-});
-movesText.anchor.set(0, 0);
-movesText.x = 100;
-movesText.y = 100;
-LK.gui.topLeft.addChild(movesText);
-// Initialize target display
-var targetText = new Text2('Target: 1000', {
- size: 50,
- fill: 0xFFFF00
-});
-targetText.anchor.set(1, 0);
-targetText.x = -100;
-targetText.y = 100;
-LK.gui.topRight.addChild(targetText);
+// UI elements removed - only candy balls remain on screen
function initializeGrid() {
grid = [];
for (var x = 0; x < GRID_SIZE; x++) {
grid[x] = [];
@@ -299,9 +272,9 @@
var matches2 = findMatches(candy2.gridX, candy2.gridY);
if (matches1.length > 0 || matches2.length > 0) {
// Valid swap - animate
moves--;
- movesText.setText('Moves: ' + moves);
+ // Moves text removed
var targetX1 = GRID_START_X + candy1.gridX * CELL_SIZE;
var targetY1 = GRID_START_Y + candy1.gridY * CELL_SIZE;
var targetX2 = GRID_START_X + candy2.gridX * CELL_SIZE;
var targetY2 = GRID_START_Y + candy2.gridY * CELL_SIZE;
@@ -407,9 +380,9 @@
candy.markForDestroy();
grid[candy.gridX][candy.gridY] = null;
score += 10;
}
- scoreText.setText('Score: ' + score);
+ // Score text removed
LK.getSound('match').play();
// Drop candies after delay
LK.setTimeout(function () {
dropCandies();
@@ -485,9 +458,9 @@
candy.markForDestroy();
grid[candy.gridX][candy.gridY] = null;
score += 10;
}
- scoreText.setText('Score: ' + score);
+ // Score text removed
LK.getSound('match').play();
// Drop candies after delay
LK.setTimeout(function () {
dropCandies();
Kırmızı 3d top. In-Game asset. 2d. High contrast. No shadows
Yeşil 3d top. In-Game asset. 2d. High contrast. No shadows
Mavi 3d yuvarlak top. In-Game asset. 2d. High contrast. No shadows
Sarı 2d top. In-Game asset. 2d. High contrast. No shadows
3d pembe daire. In-Game asset. 2d. High contrast. No shadows
Beyaz 3d daire. In-Game asset. 2d. High contrast. No shadows
Şeker. In-Game asset. 2d. High contrast. No shadows