User prompt
iç içe giriyor şekerler onu düzelt
User prompt
olmuyor hala olmuyor
User prompt
olmamış bak o boşluğun üstündeki yeşil şeker düşmüyor
User prompt
fizik ekle oyuna arada boşluk kalmasın şekerlerin altında boşluk var ise şekerler o boşluğa düşsün ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
sürekli rahat music çalsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
arada bir şekerlere dokunamıyorumbu bir bug mu
User prompt
kahveye dokununca coffee sesi çalsın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
tekrardan ekle ama 1 tane assets şeklinde olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
coffee cup kaldır
User prompt
tıklayınca dolan o şeyi kaldır sadece sallansın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
tamam kahve içme animasyonu ekleme ama tıklayınca sallansın çok az ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
kahveyi biraz daha alta alsak
User prompt
sakin bir müzik arkaya. o şekerlerin bulunduğu karenin altına bir kahve koy ve kahveye tıkladıkça içebilelim ve kahve içme sesi ekle tıklayınca ona özelde animasyon koy ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
yazılar vs. hepsi türkçe olsun
User prompt
leveli geçtiğimizde yeaahh soundu çalsın
User prompt
her şeker kaydırdığımızda boing soundu çalsın
Code edit (1 edits merged)
Please save this source code
User prompt
Sweet Match Cascade
Initial prompt
candy crush game
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Candy = Container.expand(function (type) { var self = Container.call(this); self.candyType = type || 1; self.gridX = 0; self.gridY = 0; self.isAnimating = false; self.isMatched = false; var candyGraphics = self.attachAsset('candy' + self.candyType, { 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 + CELL_SIZE / 2; self.y = GRID_START_Y + gridY * CELL_SIZE + CELL_SIZE / 2; }; self.animateToPosition = function (targetX, targetY, callback) { self.isAnimating = true; tween(self, { x: targetX, y: targetY }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { self.isAnimating = false; if (callback) callback(); } }); }; self.animateFall = function (newGridY, callback) { var targetY = GRID_START_Y + newGridY * CELL_SIZE + CELL_SIZE / 2; self.gridY = newGridY; self.animateToPosition(self.x, targetY, callback); }; self.markForRemoval = function () { self.isMatched = true; tween(self, { alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 200, easing: tween.easeIn }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c2c54 }); /**** * Game Code ****/ var GRID_SIZE = 8; var CELL_SIZE = 200; var GRID_START_X = (2048 - GRID_SIZE * CELL_SIZE) / 2; var GRID_START_Y = 400; var gameGrid = []; var candyTypes = [1, 2, 3, 4, 5, 6]; var selectedCandy = null; var isProcessing = false; var currentLevel = storage.currentLevel || 1; var movesLeft = 20; var targetScore = currentLevel * 1000; var score = 0; var animatingCandies = 0; // Initialize grid array for (var x = 0; x < GRID_SIZE; x++) { gameGrid[x] = []; for (var y = 0; y < GRID_SIZE; y++) { gameGrid[x][y] = null; } } // UI Elements var scoreText = new Text2('Puan: 0', { size: 80, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); var targetText = new Text2('Hedef: ' + targetScore, { size: 60, fill: 0xFFFF99 }); targetText.anchor.set(0, 0); targetText.x = 50; targetText.y = 100; LK.gui.topLeft.addChild(targetText); var movesText = new Text2('Hamle: ' + movesLeft, { size: 60, fill: 0x99FFFF }); movesText.anchor.set(1, 0); movesText.x = -50; movesText.y = 100; LK.gui.topRight.addChild(movesText); var levelText = new Text2('Seviye ' + currentLevel, { size: 70, fill: 0xFFFFFF }); levelText.anchor.set(0.5, 0); levelText.y = 100; LK.gui.top.addChild(levelText); // Draw grid background for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { var cell = LK.getAsset('gridCell', { anchorX: 0.5, anchorY: 0.5 }); cell.x = GRID_START_X + x * CELL_SIZE + CELL_SIZE / 2; cell.y = GRID_START_Y + y * CELL_SIZE + CELL_SIZE / 2; cell.alpha = 0.3; game.addChild(cell); } } function getRandomCandyType() { return candyTypes[Math.floor(Math.random() * candyTypes.length)]; } function createCandy(x, y, type) { if (!type) type = getRandomCandyType(); var candy = new Candy(type); candy.setGridPosition(x, y); gameGrid[x][y] = candy; game.addChild(candy); return candy; } function initializeGrid() { for (var x = 0; x < GRID_SIZE; x++) { for (var y = 0; y < GRID_SIZE; y++) { var type; var attempts = 0; do { type = getRandomCandyType(); attempts++; } while (attempts < 10 && wouldCreateMatch(x, y, type)); createCandy(x, y, type); } } } function wouldCreateMatch(x, y, type) { var horizontalCount = 1; var verticalCount = 1; // Check horizontal for (var i = x - 1; i >= 0 && gameGrid[i][y] && gameGrid[i][y].candyType === type; i--) { horizontalCount++; } for (var i = x + 1; i < GRID_SIZE && gameGrid[i][y] && gameGrid[i][y].candyType === type; i++) { horizontalCount++; } // Check vertical for (var i = y - 1; i >= 0 && gameGrid[x][i] && gameGrid[x][i].candyType === type; i--) { verticalCount++; } for (var i = y + 1; i < GRID_SIZE && gameGrid[x][i] && gameGrid[x][i].candyType === type; i++) { verticalCount++; } return horizontalCount >= 3 || verticalCount >= 3; } function getCandyAt(worldX, worldY) { var gridX = Math.floor((worldX - GRID_START_X) / CELL_SIZE); var gridY = Math.floor((worldY - GRID_START_Y) / CELL_SIZE); if (gridX >= 0 && gridX < GRID_SIZE && gridY >= 0 && gridY < GRID_SIZE) { return gameGrid[gridX][gridY]; } return null; } function areAdjacent(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 swapCandies(candy1, candy2) { var tempX = candy1.gridX; var tempY = candy1.gridY; var tempPosX = candy1.x; var tempPosY = candy1.y; gameGrid[candy1.gridX][candy1.gridY] = candy2; gameGrid[candy2.gridX][candy2.gridY] = candy1; candy1.gridX = candy2.gridX; candy1.gridY = candy2.gridY; candy2.gridX = tempX; candy2.gridY = tempY; animatingCandies += 2; // Play boing sound when candies are swapped LK.getSound('boing').play(); candy1.animateToPosition(candy2.x, candy2.y, function () { animatingCandies--; }); candy2.animateToPosition(tempPosX, tempPosY, function () { animatingCandies--; }); } function findMatches() { var matches = []; var marked = []; for (var x = 0; x < GRID_SIZE; x++) { marked[x] = []; for (var y = 0; y < GRID_SIZE; y++) { marked[x][y] = false; } } // Check horizontal matches for (var y = 0; y < GRID_SIZE; y++) { var count = 1; var currentType = gameGrid[0][y] ? gameGrid[0][y].candyType : null; for (var x = 1; x < GRID_SIZE; x++) { var candy = gameGrid[x][y]; if (candy && candy.candyType === currentType) { count++; } else { if (count >= 3) { for (var i = x - count; i < x; i++) { if (!marked[i][y]) { matches.push(gameGrid[i][y]); marked[i][y] = true; } } } count = 1; currentType = candy ? candy.candyType : null; } } if (count >= 3) { for (var i = GRID_SIZE - count; i < GRID_SIZE; i++) { if (!marked[i][y]) { matches.push(gameGrid[i][y]); marked[i][y] = true; } } } } // Check vertical matches for (var x = 0; x < GRID_SIZE; x++) { var count = 1; var currentType = gameGrid[x][0] ? gameGrid[x][0].candyType : null; for (var y = 1; y < GRID_SIZE; y++) { var candy = gameGrid[x][y]; if (candy && candy.candyType === currentType) { count++; } else { if (count >= 3) { for (var i = y - count; i < y; i++) { if (!marked[x][i]) { matches.push(gameGrid[x][i]); marked[x][i] = true; } } } count = 1; currentType = candy ? candy.candyType : null; } } if (count >= 3) { for (var i = GRID_SIZE - count; i < GRID_SIZE; i++) { if (!marked[x][i]) { matches.push(gameGrid[x][i]); marked[x][i] = true; } } } } return matches; } function removeMatches(matches) { if (matches.length === 0) return; LK.getSound('match').play(); for (var i = 0; i < matches.length; i++) { var candy = matches[i]; candy.markForRemoval(); gameGrid[candy.gridX][candy.gridY] = null; // Update score score += 100; if (matches.length > 3) { score += (matches.length - 3) * 50; } } scoreText.setText('Puan: ' + score); // Remove candies after animation LK.setTimeout(function () { for (var i = 0; i < matches.length; i++) { matches[i].destroy(); } applyGravity(); }, 250); } function applyGravity() { var needsGravity = false; // Apply gravity physics - make candies fall to fill empty spaces for (var x = 0; x < GRID_SIZE; x++) { // Collect all candies in this column that are not null var candiesInColumn = []; for (var y = 0; y < GRID_SIZE; y++) { if (gameGrid[x][y] !== null) { candiesInColumn.push({ candy: gameGrid[x][y], originalY: y }); } gameGrid[x][y] = null; // Clear the column } // Place candies back starting from bottom var newY = GRID_SIZE - 1; for (var i = candiesInColumn.length - 1; i >= 0; i--) { var candyData = candiesInColumn[i]; var candy = candyData.candy; var originalY = candyData.originalY; gameGrid[x][newY] = candy; // Check if candy needs to fall if (newY !== originalY) { animatingCandies++; candy.animateFall(newY, function () { animatingCandies--; }); needsGravity = true; } else { // Update grid position even if not animating candy.gridY = newY; } newY--; } // Fill remaining empty spaces at top with new candies for (var y = 0; y < GRID_SIZE; y++) { if (gameGrid[x][y] === null) { var newCandy = createCandy(x, y, getRandomCandyType()); newCandy.y = GRID_START_Y - CELL_SIZE + CELL_SIZE / 2; animatingCandies++; newCandy.animateFall(y, function () { animatingCandies--; }); needsGravity = true; } } } if (needsGravity) { LK.getSound('cascade').play(); LK.setTimeout(function () { checkForNewMatches(); }, 400); } } function checkForNewMatches() { if (animatingCandies > 0) { LK.setTimeout(checkForNewMatches, 100); return; } var matches = findMatches(); if (matches.length > 0) { removeMatches(matches); } else { isProcessing = false; checkGameState(); } } function checkGameState() { if (score >= targetScore) { currentLevel++; storage.currentLevel = currentLevel; LK.getSound('yeaahh').play(); LK.showYouWin(); } else if (movesLeft <= 0) { LK.showGameOver(); } } function processMove(candy1, candy2) { if (isProcessing || !candy1 || !candy2 || candy1 === candy2) return false; if (!areAdjacent(candy1, candy2)) return false; isProcessing = true; movesLeft--; movesText.setText('Hamle: ' + movesLeft); // Temporarily swap to check for matches var tempX1 = candy1.gridX, tempY1 = candy1.gridY; var tempX2 = candy2.gridX, tempY2 = candy2.gridY; gameGrid[tempX1][tempY1] = candy2; gameGrid[tempX2][tempY2] = candy1; candy1.gridX = tempX2; candy1.gridY = tempY2; candy2.gridX = tempX1; candy2.gridY = tempY1; var matches = findMatches(); if (matches.length > 0) { // Valid move - perform the swap animation swapCandies(candy2, candy1); // Swap back positions for animation LK.setTimeout(function () { removeMatches(matches); }, 350); } else { // Invalid move - revert gameGrid[tempX1][tempY1] = candy1; gameGrid[tempX2][tempY2] = candy2; candy1.gridX = tempX1; candy1.gridY = tempY1; candy2.gridX = tempX2; candy2.gridY = tempY2; // Animate back to original positions swapCandies(candy1, candy2); LK.setTimeout(function () { isProcessing = false; }, 350); movesLeft++; // Give back the move movesText.setText('Hamle: ' + movesLeft); } return true; } game.down = function (x, y, obj) { if (isProcessing) return; var candy = getCandyAt(x, y); if (!candy) return; if (selectedCandy) { if (selectedCandy === candy) { // Deselect tween(selectedCandy, { scaleX: 1, scaleY: 1 }, { duration: 150 }); selectedCandy = null; } else { // Try to make move var success = processMove(selectedCandy, candy); if (success) { tween(selectedCandy, { scaleX: 1, scaleY: 1 }, { duration: 150 }); selectedCandy = null; } } } else { // Select candy selectedCandy = candy; tween(candy, { scaleX: 1.2, scaleY: 1.2 }, { duration: 150 }); } }; // Create coffee cup below the grid var coffee = LK.getAsset('coffee', { anchorX: 0.5, anchorY: 0.5 }); coffee.x = 2048 / 2; coffee.y = GRID_START_Y + GRID_SIZE * CELL_SIZE + 150; game.addChild(coffee); // Coffee click handler coffee.down = function (x, y, obj) { // Play coffee sound LK.getSound('coffee').play(); // Shake animation tween(coffee, { x: coffee.x + 10 }, { duration: 50, onFinish: function onFinish() { tween(coffee, { x: coffee.x - 20 }, { duration: 50, onFinish: function onFinish() { tween(coffee, { x: coffee.x + 10 }, { duration: 50 }); } }); } }); }; // Start background music LK.playMusic('rahat'); // Initialize the game initializeGrid(); game.update = function () { // Continuously check for physics updates when not processing moves if (!isProcessing && animatingCandies === 0) { // Check if any candies need to fall due to physics var needsPhysicsUpdate = false; for (var x = 0; x < GRID_SIZE && !needsPhysicsUpdate; x++) { // Check entire column from bottom to top for any candy that should fall for (var y = GRID_SIZE - 1; y >= 0; y--) { if (gameGrid[x][y] === null) { // Found empty space, check if there's a candy above it for (var checkY = y - 1; checkY >= 0; checkY--) { if (gameGrid[x][checkY] !== null) { needsPhysicsUpdate = true; break; } } if (needsPhysicsUpdate) break; } } } if (needsPhysicsUpdate) { applyGravity(); } } };
===================================================================
--- original.js
+++ change.js
@@ -303,28 +303,39 @@
function applyGravity() {
var needsGravity = false;
// Apply gravity physics - make candies fall to fill empty spaces
for (var x = 0; x < GRID_SIZE; x++) {
- // Check each column from bottom to top for empty spaces
- for (var y = GRID_SIZE - 1; y >= 0; y--) {
- if (gameGrid[x][y] === null) {
- // Found empty space, look for candy above to fall down
- for (var searchY = y - 1; searchY >= 0; searchY--) {
- if (gameGrid[x][searchY] !== null) {
- // Found candy that should fall
- var fallingCandy = gameGrid[x][searchY];
- gameGrid[x][y] = fallingCandy;
- gameGrid[x][searchY] = null;
- animatingCandies++;
- fallingCandy.animateFall(y, function () {
- animatingCandies--;
- });
- needsGravity = true;
- break; // Move to next empty space
- }
- }
+ // Collect all candies in this column that are not null
+ var candiesInColumn = [];
+ for (var y = 0; y < GRID_SIZE; y++) {
+ if (gameGrid[x][y] !== null) {
+ candiesInColumn.push({
+ candy: gameGrid[x][y],
+ originalY: y
+ });
}
+ gameGrid[x][y] = null; // Clear the column
}
+ // Place candies back starting from bottom
+ var newY = GRID_SIZE - 1;
+ for (var i = candiesInColumn.length - 1; i >= 0; i--) {
+ var candyData = candiesInColumn[i];
+ var candy = candyData.candy;
+ var originalY = candyData.originalY;
+ gameGrid[x][newY] = candy;
+ // Check if candy needs to fall
+ if (newY !== originalY) {
+ animatingCandies++;
+ candy.animateFall(newY, function () {
+ animatingCandies--;
+ });
+ needsGravity = true;
+ } else {
+ // Update grid position even if not animating
+ candy.gridY = newY;
+ }
+ newY--;
+ }
// Fill remaining empty spaces at top with new candies
for (var y = 0; y < GRID_SIZE; y++) {
if (gameGrid[x][y] === null) {
var newCandy = createCandy(x, y, getRandomCandyType());
gerçekçi bir şeker. yuvarlak bir şeker ve kırmızı renk. In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve pembe renk.. In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve koyu mavi renk. aynı candy2 deki gibi In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve sarı renk. aynı candy2 deki gibi olsun. In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve kahverengi renk. aynı candy2 deki gibi olsun. In-Game asset. 2d. High contrast. No shadows
gerçekçi bir şeker. yuvarlak bir şeker ve yeşil renk. aynı candy2 deki gibi olsun. In-Game asset. 2d. High contrast. No shadows
a coffee. In-Game asset. 2d. High contrast. No shadows
Bir satırda oyundaki tüm şekerler yan yana dizilsin. In-Game asset. 2d. High contrast. No shadows
Yuvarlak bir şeker ve üstünde ona ucu değen sağ üstte bir kalem. In-Game asset. 2d. High contrast. No shadows