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; var background = self.attachAsset('cellBackground', { anchorX: 0.5, anchorY: 0.5 }); 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.up = function (x, y, obj) { if (gameState !== 'playing' || self.isMoving) return; 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({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ var GRID_SIZE = 8; var CELL_SIZE = 90; var GRID_START_X = (2048 - GRID_SIZE * CELL_SIZE) / 2; var GRID_START_Y = 400; var CANDY_TYPES = 6; var grid = []; var selectedCandy = null; 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); // Add grid background var gridBg = game.attachAsset('gridBackground', { anchorX: 0.5, anchorY: 0.5, x: GRID_START_X + GRID_SIZE * CELL_SIZE / 2, y: GRID_START_Y + GRID_SIZE * CELL_SIZE / 2 }); 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--; movesText.setText('Moves: ' + moves); 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; } scoreText.setText('Score: ' + score); 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 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
@@ -273,18 +273,46 @@
return matches;
}
function processMatches() {
var allMatches = [];
- // Find all matches
+ 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) {
- var matches = findMatches(x, y);
- for (var i = 0; i < matches.length; i++) {
- if (allMatches.indexOf(matches[i]) === -1) {
- allMatches.push(matches[i]);
+ // 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) {
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