Code edit (3 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
hamle kalmadıktan sonra oyunun bitmesi için hamle yapamaya çalışmak gerekiyor şuan. bunun yerine son hamle yapıldıktan sonra eğer düşecek şeker varsa düşmeler gerçekleşir ve oyun sona erer
User prompt
her yer değiştirme işleminden sonra tüm şekerlerin düşmesi beklensin ve muhtemel eşleşmeler kontrol edilsin böylece şekerler havada kalmışken oyun bitmez
User prompt
her yer değiştirme işleminden sonra muhtemel eşleşmeler kontrol edilsin böylece şekerler havada kalmışken oyun bitmez
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'i')' in or related to this line: 'var i = candy.i;' Line Number: 241
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: processMatches is not defined' in or related to this line: 'processMatches();' Line Number: 219
Code edit (1 edits merged)
Please save this source code
User prompt
muhtemel eşleşmeler kalmasına rağmen oyun bitebiliyor
Code edit (1 edits merged)
Please save this source code
User prompt
4'lü eşleşme sonucu oluşan özel şeker kendi rengindeki şekerlerle (örnek: 4'lü kırmızı ile oluşan şeker ile normal kırmızı şekerler) eşleşme sağlarsa eğer yatay eşleşme ise özel şekerin bulunduğu satır yok edilsin eğer, dikey eşleşme ise özel şekerin bulunduğu sütun yok edilsin
User prompt
4'lü eşleşme sonucu oluşan özel şeker kendi rengindeki şekerler ile eşleşme yaparsa eşleşmeye göre bulunduğu satır veya sütundaki tüm şekerler yok edilsin.
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '3')' in or related to this line: 'if (board[i][j] && board[i + 1][j] && board[i][j].candyType === board[i + 1][j].candyType) {' Line Number: 397
User prompt
ayrıca diyelim ki [i][j] ve [i+1][j] de aynı renk bulunsun muhtemel eşleşme için kontrol edilmesi gereken konumlar şunlar [i-2][j], [i-1][j-1], [i-1][j+1], [i+2][j-1], [i+2][j+1], [i+3][j] buna göre yapılabilir hamle kalıp kalmadığını kontrol et ve kalmadıysa oyun sonlansın.
User prompt
kalan yapılabilir hamle kontrolü tam doğru çalışmıyor
User prompt
Please fix the bug: 'marginX is not defined' in or related to this line: 'candy.x = i * candySize + candySize / 2 + marginX;' Line Number: 149
User prompt
Please fix the bug: 'candySize is not defined' in or related to this line: 'candy.x = i * candySize + candySize / 2 + marginX;' Line Number: 148
User prompt
Please fix the bug: 'isPotentialMatch is not defined' in or related to this line: 'candyType = candyTypes[Math.floor(Math.random() * candyTypes.length)];' Line Number: 31
===================================================================
--- original.js
+++ change.js
@@ -62,46 +62,8 @@
/****
* Game Code
****/
-function destroyRowOrColumn(candy) {
- var i = candy.i;
- var j = candy.j;
- var isRow = false;
- var isColumn = false;
- // Check if the special candy is part of a horizontal match
- for (var x = 0; x < boardSize; x++) {
- if (board[x][j] && board[x][j].candyType === candy.candyType.replace("_white", "")) {
- isRow = true;
- break;
- }
- }
- // Check if the special candy is part of a vertical match
- for (var y = 0; y < boardSize; y++) {
- if (board[i][y] && board[i][y].candyType === candy.candyType.replace("_white", "")) {
- isColumn = true;
- break;
- }
- }
- if (isRow) {
- // Destroy entire row
- for (var x = 0; x < boardSize; x++) {
- if (board[x][j]) {
- board[x][j].destroyCandy();
- board[x][j] = null;
- }
- }
- }
- if (isColumn) {
- // Destroy entire column
- for (var y = 0; y < boardSize; y++) {
- if (board[i][y]) {
- board[i][y].destroyCandy();
- board[i][y] = null;
- }
- }
- }
-}
var score = 0;
var scoreMultiplier = 1;
var scoreTxt = new Text2('Score: 0', {
size: 100,
@@ -200,22 +162,8 @@
}
LK.setTimeout(function () {
processMatches();
}, 300);
- refillBoard(); // Ensure all candies fall into place
- LK.setTimeout(function () {
- // Wait for candies to settle
- if (checkAllMatches()) {
- // Check for any new matches
- processMatches(); // Process any new matches found
- } else {
- isProcessing = false; // Allow new actions if no matches
- if (!checkPossibleMoves()) {
- // Check for possible moves
- LK.showGameOver(); // End the game if no possible moves are found
- }
- }
- }, 600);
}
}, 600);
}
function checkAndDestroyMatches(candy) {
@@ -224,19 +172,16 @@
var candiesToDestroy = [];
var i = candy.i;
var j = candy.j;
var matchedCandies = [candy];
- // Özel şeker olup olmadığını kontrol et (örneğin candy1_white)
- var originalType = candy.candyType.replace("_white", "");
- var isSpecialCandy = candy.candyType.includes("_white");
// Yatay kontrol
var left = i - 1;
- while (left >= 0 && board[left][j] && board[left][j].candyType.replace("_white", "") === originalType) {
+ while (left >= 0 && board[left][j] && board[left][j].candyType === candy.candyType) {
matchedCandies.push(board[left][j]);
left--;
}
var right = i + 1;
- while (right < boardSize && board[right][j] && board[right][j].candyType.replace("_white", "") === originalType) {
+ while (right < boardSize && board[right][j] && board[right][j].candyType === candy.candyType) {
matchedCandies.push(board[right][j]);
right++;
}
if (matchedCandies.length >= 3) {
@@ -250,14 +195,14 @@
}
// Dikey kontrol
matchedCandies = [candy];
var up = j - 1;
- while (up >= 0 && board[i][up] && board[i][up].candyType.replace("_white", "") === originalType) {
+ while (up >= 0 && board[i][up] && board[i][up].candyType === candy.candyType) {
matchedCandies.push(board[i][up]);
up--;
}
var down = j + 1;
- while (down < boardSize && board[i][down] && board[i][down].candyType.replace("_white", "") === originalType) {
+ while (down < boardSize && board[i][down] && board[i][down].candyType === candy.candyType) {
matchedCandies.push(board[i][down]);
down++;
}
if (matchedCandies.length >= 3) {
@@ -268,33 +213,23 @@
candiesToDestroy = candiesToDestroy.concat(matchedCandies.filter(function (c) {
return c !== candy;
}));
}
- // Eğer özel bir şeker (white) kendi rengindeki şekerlerle eşleşirse tüm satır veya sütun silinsin
- if (isSpecialCandy && hasMatch) {
- if (left >= 0 || right < boardSize) {
- // Yatay eşleşme varsa satırı temizle
- for (var x = 0; x < boardSize; x++) {
- if (board[x][j]) {
- board[x][j].destroyCandy();
- board[x][j] = null;
- }
- }
- } else if (up >= 0 || down < boardSize) {
- // Dikey eşleşme varsa sütunu temizle
- for (var y = 0; y < boardSize; y++) {
- if (board[i][y]) {
- board[i][y].destroyCandy();
- board[i][y] = null;
- }
- }
- }
- }
- // Normal eşleşen şekerleri yok et
+ // Eşleşen şekerleri yok et
candiesToDestroy.forEach(function (c) {
board[c.i][c.j] = null;
c.destroyCandy();
});
+ if (hasMatch) {
+ if (isFourMatch) {
+ updateScore(100); // 4-match score
+ } else {
+ updateScore(50); // 3-match score
+ }
+ scoreMultiplier++;
+ } else {
+ scoreMultiplier = 1; // Reset multiplier if no match
+ }
return {
hasMatch: hasMatch,
isFourMatch: isFourMatch
};
@@ -308,14 +243,8 @@
}, 300);
} else {
isProcessing = false;
scoreMultiplier = 1; // Reset multiplier after processing
- // 💥 Hamle olup olmadığını hemen kontrol et
- LK.setTimeout(function () {
- if (!checkPossibleMoves()) {
- LK.showGameOver(); // Hamle kalmadıysa oyunu bitir
- }
- }, 300);
}
}, 600);
}
function checkAllMatches() {
@@ -394,12 +323,14 @@
board[i][j] = null;
}
}
for (var j = emptySpaces - 1; j >= 0; j--) {
- if (j < boardSize - emptySpaces) {
- // Only move existing candies down, do not spawn new ones
- board[i][j] = null;
- }
+ var newCandy = new Candy(i, j);
+ newCandy.x = i * candySize + candySize / 2 + marginX;
+ newCandy.y = -candySize * (emptySpaces - j) + candySize / 2 + marginY;
+ board[i][j] = newCandy;
+ game.addChild(newCandy);
+ newCandy.moveTo(i, j);
}
}
}
game.down = function (x, y) {
@@ -432,29 +363,6 @@
LK.gui.bottomRight.addChild(resetButton);
resetButton.down = function () {
LK.showGameOver(); // This will reset the game state
};
-game.update = function () {
- if (!checkPossibleMoves()) {
- LK.showGameOver(); // End the game if no possible moves are found
- }
-};
-;
-function checkPossibleMoves() {
- for (var i = 0; i < boardSize; i++) {
- for (var j = 0; j < boardSize - 1; j++) {
- if (board[i][j] && board[i][j + 1] && board[i][j].candyType === board[i][j + 1].candyType) {
- // Check potential matches around the pair
- if (i > 0 && j > 0 && board[i - 1][j - 1] && board[i - 1][j - 1].candyType === board[i][j].candyType || j > 1 && board[i][j - 2] && board[i][j - 2].candyType === board[i][j].candyType || i < boardSize - 1 && j > 0 && board[i + 1][j - 1] && board[i + 1][j - 1].candyType === board[i][j].candyType || i > 0 && j < boardSize - 2 && board[i - 1][j + 2] && board[i - 1][j + 2].candyType === board[i][j].candyType || j < boardSize - 3 && board[i][j + 2] && board[i][j + 2].candyType === board[i][j].candyType || i < boardSize - 1 && j < boardSize - 2 && board[i + 1][j + 2] && board[i + 1][j + 2].candyType === board[i][j].candyType) {
- return true; // Found a possible move
- }
- }
- if (i < boardSize - 1 && board[i][j] && board[i + 1][j] && board[i][j].candyType === board[i + 1][j].candyType) {
- // Check potential matches around the pair
- if (i > 1 && board[i - 2][j] && board[i - 2][j].candyType === board[i][j].candyType || i > 0 && j > 0 && board[i - 1][j - 1] && board[i - 1][j - 1].candyType === board[i][j].candyType || i > 0 && j < boardSize - 1 && board[i - 1][j + 1] && board[i - 1][j + 1].candyType === board[i][j].candyType || i < boardSize - 2 && j > 0 && board[i + 2][j - 1] && board[i + 2][j - 1].candyType === board[i][j].candyType || i < boardSize - 2 && j < boardSize - 1 && board[i + 2][j + 1] && board[i + 2][j + 1].candyType === board[i][j].candyType || i < boardSize - 3 && board[i + 3][j] && board[i + 3][j].candyType === board[i][j].candyType) {
- return true; // Found a possible move
- }
- }
- }
- }
- return false; // No possible moves found
-}
\ No newline at end of file
+game.update = function () {};
+;
\ No newline at end of file