User prompt
Please fix the bug: 'board is not defined' in or related to this line: 'board[i] = [];' Line Number: 139
User prompt
Please fix the bug: 'boardSize is not defined' in or related to this line: 'for (var i = 0; i < boardSize; i++) {' Line Number: 137
Code edit (1 edits merged)
Please save this source code
User prompt
diyelim ki [i][j] ve [i][j+1] de aynı renk bulunsun muhtemel eşleşme için kontrol edilmesi gereken konumlar şunlar [i-1][j-1], [i][j-2], [i+1][j-1], [i-1][j+2], [i][j+2], [i+1][j+2] buna göre yapılabilir hamle kalıp kalmadığını kontrol et ve kalmadıysa oyun sonlansın.
User prompt
diyelim ki [i][j] ve [i][j+1] de aynı renk bulunsun muhtemel eşleşme için kontrol edilmesi gereken konumlar şunlar [i-1][j-1], [i+1][j-1], [i-1][j+2]i [i+1][j+2] buna göre yapılabilir hamle kalıp kalmadığını kontrol et ve kalmadıysa oyun sonlansın.
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of null (reading 'candyType')' in or related to this line: 'candy1.candyType = candy2.candyType;' Line Number: 103
User prompt
eğer yer değişikliği ile eşleme yapılabilir bir hamle kalmadıysa oyunu bitir
User prompt
oyunda sadece en başta spawn olan renkler olsun orta kısımlardan yok edilenlerin yeri üst kısımdakilerde dolsun fakat yeni renkler spawn edilmesin.
User prompt
yok edilen renklerin üstüne yukarıdan renkler bloak halinde gelmeye devam etsin. fakat en üstte oluşan boşluklara yeni renkler eklenmesin. boşluk olarak kalsın
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught RangeError: Maximum call stack size exceeded' in or related to this line: 'candy1.x = candy2.x;' Line Number: 160
User prompt
Please fix the bug: 'self.checkMatches is not a function' in or related to this line: 'return self.checkMatches().length > 0;' Line Number: 48
User prompt
Please fix the bug: 'self.checkMatches is not a function' in or related to this line: 'return self.checkMatches().length > 0;' Line Number: 48
Code edit (1 edits merged)
Please save this source code
User prompt
hala aynı
User prompt
oyunda hiçbir şey gözükmüyor
User prompt
candy crush benzeri oyun yap
User prompt
hataları düzelt
User prompt
Please fix the bug: 'self.reshuffleBoard is not a function' in or related to this line: 'self.reshuffleBoard();' Line Number: 37
User prompt
Please fix the bug: 'self.hasMatches is not a function' in or related to this line: 'while (self.hasMatches()) {' Line Number: 36
User prompt
Please fix the bug: 'PowerUp is not defined' in or related to this line: 'item = new PowerUp();' Line Number: 44
User prompt
Please fix the bug: 'Candy is not defined' in or related to this line: 'item = new Candy();' Line Number: 46
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: gameBoard.board[x][y].pop is not a function' in or related to this line: 'gameBoard.board[x][y].pop();' Line Number: 280
Code edit (1 edits merged)
Please save this source code
/**** * Classes ****/ var Board = Container.expand(function () { var self = Container.call(this); self.board = []; self.boardWidth = 9; self.boardHeight = 9; self.candySize = (game.width - (self.boardWidth - 1) * 2) / self.boardWidth; self.difficulty = 'easy'; self.selectedCandy = null; self.moves = 0; self.time = 0; self.initializeBoard = function (difficulty) { self.difficulty = difficulty; self.moves = difficulty === 'medium' ? 30 : 0; self.time = difficulty === 'hard' ? 60 : 0; for (var i = 0; i < self.boardWidth; i++) { self.board[i] = []; for (var j = 0; j < self.boardHeight; j++) { self.createCandyAt(i, j); } } while (self.hasMatches()) { self.reshuffleBoard(); } }; self.createCandyAt = function (i, j) { var item = new Candy(); item.x = i * (self.candySize + 2) + self.candySize / 2; item.y = j * (self.candySize + 2) + self.candySize / 2; item.boardX = i; item.boardY = j; self.board[i][j] = item; self.addChild(item); return item; }; self.checkMatches = function () { var matches = []; // Check for horizontal matches for (var j = 0; j < self.boardHeight; j++) { var match = { x: 0, y: j, length: 1, direction: 'horizontal' }; for (var i = 1; i < self.boardWidth; i++) { if (self.board[i][j] && self.board[i - 1][j] && self.board[i][j].type === self.board[i - 1][j].type) { match.length++; } else { if (match.length >= 3) { matches.push(match); } match = { x: i, y: j, length: 1, direction: 'horizontal' }; } } if (match.length >= 3) { matches.push(match); } } // Check for vertical matches for (var i = 0; i < self.boardWidth; i++) { var match = { x: i, y: 0, length: 1, direction: 'vertical' }; for (var j = 1; j < self.boardHeight; j++) { if (self.board[i][j] && self.board[i][j - 1] && self.board[i][j].type === self.board[i][j - 1].type) { match.length++; } else { if (match.length >= 3) { matches.push(match); } match = { x: i, y: j, length: 1, direction: 'vertical' }; } } if (match.length >= 3) { matches.push(match); } } return matches; }; self.hasMatches = function () { return self.checkMatches().length > 0; }; self.swapCandies = function (candy1, candy2) { if (candy1.locked || candy2.locked || candy1.immovable || candy2.immovable) { return false; } var dx = Math.abs(candy1.boardX - candy2.boardX); var dy = Math.abs(candy1.boardY - candy2.boardY); if (dx + dy !== 1) { return false; } var tempX = candy1.x, tempY = candy1.y, tempBX = candy1.boardX, tempBY = candy1.boardY; candy1.x = candy2.x; candy1.y = candy2.y; candy1.boardX = candy2.boardX; candy1.boardY = candy2.boardY; candy2.x = tempX; candy2.y = tempY; candy2.boardX = tempBX; candy2.boardY = tempBY; self.board[candy1.boardX][candy1.boardY] = candy1; self.board[candy2.boardX][candy2.boardY] = candy2; if (!self.hasMatches()) { return false; } return true; }; return self; }); var Candy = Container.expand(function () { var self = Container.call(this); var candyTypes = ['candy1', 'candy2', 'candy3', 'candy4', 'candy5']; self.type = candyTypes[Math.floor(Math.random() * candyTypes.length)]; self.attachAsset(self.type, { anchorX: 0.5, anchorY: 0.5, width: gameBoard.candySize * 0.8, height: gameBoard.candySize * 0.8 }); self.locked = false; self.immovable = false; self.pop = function () { self.destroy(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var gameBoard = new Board(); game.addChild(gameBoard); gameBoard.initializeBoard('easy'); game.update = function () { var matches = gameBoard.checkMatches(); if (matches.length > 0) { matches.forEach(function (match) { for (var i = 0; i < match.length; i++) { var x = match.direction === 'horizontal' ? match.x + i : match.x; var y = match.direction === 'vertical' ? match.y + i : match.y; if (x >= 0 && x < gameBoard.boardWidth && y >= 0 && y < gameBoard.boardHeight && gameBoard.board[x][y]) { gameBoard.board[x][y].pop(); gameBoard.board[x][y] = null; } } }); setTimeout(function () { for (var i = 0; i < gameBoard.boardWidth; i++) { for (var j = 0; j < gameBoard.boardHeight; j++) { if (!gameBoard.board[i][j]) { gameBoard.createCandyAt(i, j); } } } }, 300); } };
===================================================================
--- original.js
+++ change.js
@@ -41,16 +41,16 @@
for (var j = 0; j < self.boardHeight; j++) {
var match = {
x: 0,
y: j,
- length: 0,
+ length: 1,
direction: 'horizontal'
};
- for (var i = 0; i < self.boardWidth; i++) {
- if (i > 0 && self.board[i][j] && self.board[i][j].type === self.board[i - 1][j].type) {
+ for (var i = 1; i < self.boardWidth; i++) {
+ if (self.board[i][j] && self.board[i - 1][j] && self.board[i][j].type === self.board[i - 1][j].type) {
match.length++;
} else {
- if (match.length > 2) {
+ if (match.length >= 3) {
matches.push(match);
}
match = {
x: i,
@@ -59,25 +59,25 @@
direction: 'horizontal'
};
}
}
- if (match.length > 2) {
+ if (match.length >= 3) {
matches.push(match);
}
}
// Check for vertical matches
for (var i = 0; i < self.boardWidth; i++) {
var match = {
x: i,
y: 0,
- length: 0,
+ length: 1,
direction: 'vertical'
};
- for (var j = 0; j < self.boardHeight; j++) {
- if (j > 0 && self.board[i][j] && self.board[i][j].type === self.board[i][j - 1].type) {
+ for (var j = 1; j < self.boardHeight; j++) {
+ if (self.board[i][j] && self.board[i][j - 1] && self.board[i][j].type === self.board[i][j - 1].type) {
match.length++;
} else {
- if (match.length > 2) {
+ if (match.length >= 3) {
matches.push(match);
}
match = {
x: i,
@@ -86,9 +86,9 @@
direction: 'vertical'
};
}
}
- if (match.length > 2) {
+ if (match.length >= 3) {
matches.push(match);
}
}
return matches;