Code edit (20 edits merged)
Please save this source code
User prompt
update ``` for (var row = 0; row < self.levelData.tiles.length; row++) { var tempMaxCols = Math.max(maxCols, self.levelData.tiles[row].length); log("tempMaxCols=", tempMaxCols, maxCols); if (tempMaxCols > maxCols) { maxCols = tempMaxCols; maxColsRowIndex = row; } for (var col = 0; col < self.levelData.tiles[row].length; col++) { var value = self.levelData.tiles[row][col]; if (value !== "") { var tile = new HexTile(value, col, row, self.levelData); self.board.push(tile); boardContainer.addChild(tile); self.activeTileCount++; // Increment active tile count } } } ``` to make maxCol only count from the first tile with a value to the last with a value on each row . ie: a row with ["", "", "", "", "", "", "" ] should count as 0 ie: a row with ["", "", "", "", 3, , 3, 3] should count as 3 ie: a row with [3, "", "", "", "" , "", 3] should count as 7 ie: a row with [3, "", 1, 1, 1, "", 3] should count as 7
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught Error: [object Object]addChildAt: The index undefined supplied is out of bounds 64' in or related to this line: 'boardContainer.addChildAt(tile, tile.previousZIndex); // Restore tile's original z-index' Line Number: 1117
User prompt
Please fix the bug: 'Uncaught Error: [object Object]addChildAt: The index undefined supplied is out of bounds 9' in or related to this line: 'boardContainer.addChildAt(tile, tile.previousZIndex); // Restore tile's original z-index' Line Number: 1115
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught Error: [object Object]addChildAt: The index undefined supplied is out of bounds 43' in or related to this line: 'boardContainer.addChildAt(tile, tile.previousZIndex); // Restore tile's original z-index' Line Number: 1117
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Error: Invalid color format. Expected 0xRRGGBB format, received: undefined' in or related to this line: 'tween(tileGraphics, {' Line Number: 234
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught Error: [object Object]addChildAt: The index undefined supplied is out of bounds 43' in or related to this line: 'boardContainer.addChildAt(tile, tile.previousZIndex); // Restore tile's original z-index' Line Number: 1114
Code edit (5 edits merged)
Please save this source code
User prompt
in ``` currentAdjacentTiles.forEach(function (adjTile) { adjTile.isHighlighted = true; tween(adjTile, { scaleX: 1.33, scaleY: 1.33 }, { duration: 200, easing: tween.easeOut }); }); ``` calculate the normalized distance to tile then use it to delay the scale anim
Code edit (1 edits merged)
Please save this source code
User prompt
create a new dedicated function for the code ``` currentAdjacentTiles.forEach(function (adjTile) { adjTile.isHighlighted = false; tween(adjTile, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeOut }); }); currentAdjacentTiles = []; // Clear the list after restoring scale ``` and use it
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: currentAdjacentTiles is not defined' in or related to this line: 'if (currentAdjacentTiles && currentAdjacentTiles.length > 0 && currentAdjacentTiles[0].value != tile.value) {' Line Number: 1055
Code edit (1 edits merged)
Please save this source code
User prompt
in handlePlayingStateMove, update the test `else if (tile.isHighlighted)` to also check if the tile is not in currentAdjacentTiles
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught Error: [object Object]addChildAt: The index undefined supplied is out of bounds 9' in or related to this line: 'boardContainer.addChildAt(tile, tile.previousZIndex); // Restore tile's original z-index' Line Number: 1066
User prompt
Please fix the bug: 'Uncaught Error: [object Object]addChildAt: The index undefined supplied is out of bounds 9' in or related to this line: 'boardContainer.addChildAt(tile, tile.previousZIndex); // Restore tile's original z-index' Line Number: 1064
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -486,9 +486,9 @@
self.game = game;
self.activeTileCount = 0; // Initialize active tile count
self.levelBoardOffsetX = 0; // Initialize levelBoardOffsetX
self.levelBoardOffsetY = 0; // Initialize levelBoardOffsetY
- self.currentLevel = debug ? 4 : 1;
+ self.currentLevel = debug ? 5 : 1;
self.previousLevelNumber = 1;
self.board = [];
self.operations = [];
self.isAnimating = false;
@@ -534,13 +534,14 @@
LK.setTimeout(self.updateOperations, 900);
};
self.createBoard = function () {
self.board = [];
- var maxTilesInRow = 0; // Local variable to track the largest number of tiles in the level rows
+ var maxRows = self.levelData.tiles.length;
+ var maxCols = 0; // Local variable to track the largest number of tiles in the level rows
self.activeTileCount = 0; // Reset active tile count
// Update levelBoardOffsets depending on level
for (var row = 0; row < self.levelData.tiles.length; row++) {
- maxTilesInRow = Math.max(maxTilesInRow, self.levelData.tiles[row].length);
+ maxCols = Math.max(maxCols, self.levelData.tiles[row].length);
for (var col = 0; col < self.levelData.tiles[row].length; col++) {
var value = self.levelData.tiles[row][col];
if (value !== "") {
var tile = new HexTile(value, col, row, self.levelData);
@@ -549,13 +550,17 @@
self.activeTileCount++; // Increment active tile count
}
}
}
- log("createBoard max dimensions: ", self.levelData.tiles.length, maxTilesInRow);
- // Row 9 Cols 7 => 83
- // Row 5 Cols 7 => 55
- self.levelBoardOffsetX = self.levelData.tiles.length * 11 * maxTilesInRow; //maxTilesInRow * 83; // largest row * 100
- self.levelBoardOffsetY = self.levelData.tiles.length * 50; // nb rows * 30
+ log("createBoard max dimensions: ", maxRows, maxCols);
+ // L1 Rows 5 Cols 3 => 100;30
+ // L3 Rows 9 Cols 5 => 100;30
+ // L4 Rows 7 Cols 7 => 28;36
+ // L5 Rows 5 Cols 5 => 20;30
+ // Row 11 Cols 7 => 83
+ // Row 9 Cols 7 => 55
+ self.levelBoardOffsetX = 20 * maxCols;
+ self.levelBoardOffsetY = 30 * maxRows;
for (var i = 0; i < self.board.length; i++) {
var tile = self.board[i];
tile.x += self.levelBoardOffsetX;
tile.y += self.levelBoardOffsetY;
@@ -1257,8 +1262,12 @@
},
4: {
"tiles": [["", 1, 1, 1, 1, "", ""], ["", 1, 1, 1, 1, 1, ""], [2, "", "", "", "", 2, ""], [3, 3, 3, 3, 3, 3, 3], [2, "", "", "", "", 2, ""], ["", 1, 1, 1, 1, 1, ""], ["", 1, 1, 1, 1, "", ""]],
"operations": ["+1", "+1", "-1", "-1", "-1"]
+ },
+ 5: {
+ "tiles": [["", 1, 1, 1, ""], ["", 1, 1, 1, 1], [1, 1, 1, 1, 1], ["", 1, 1, 1, 1], ["", 1, 1, 1, ""]],
+ "operations": ["+1", "+1", "-1", "-1", "-1"]
}
};
/***********************************************************************************************/
/***************************************** GAME INITIALISATION *********************************/
tick
Sound effect
tileEntrance
Sound effect
tileRemove
Sound effect
operationSelect
Sound effect
operationCancel
Sound effect
tileChangeValue
Sound effect
resetSound
Sound effect
levelFailed
Sound effect
menuLevelSelect
Sound effect
menuCellEnter
Sound effect
applause
Sound effect
bgMusic
Music
tada
Sound effect