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: 'Cannot read properties of undefined (reading 'children')' in or related to this line: 'var tile = self.boardContainer.children[i];' Line Number: 607
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: 'levelBoardOffsetX is not defined' in or related to this line: 'break;' Line Number: 973
User prompt
Please fix the bug: 'levelBoardOffsetX is not defined' in or related to this line: 'log("createBoard levelBoardOffsetX: ", levelBoardOffsetX, " vs ", calcOffsetX);' Line Number: 601
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'tileSize')' in or related to this line: 'var calcOffsetX = (game.width - maxCols * boardContainer[0].tileSize) / 2;' Line Number: 589
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
in updateOperations , replace op.x = operationX; by an animation
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'show')' in or related to this line: 'op.show();' Line Number: 663
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'show')' in or related to this line: 'op.show();' Line Number: 663
Code edit (1 edits merged)
Please save this source code
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: operation is not defined' in or related to this line: 'operation.setBasePosition(operationX, op.baseY);' Line Number: 668
Code edit (11 edits merged)
Please save this source code
User prompt
queue consecutive applyOperation call until previous ones are done
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- 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 ? 5 : 1;
+ self.currentLevel = debug ? 8 : 1;
self.previousLevelNumber = 1;
self.board = [];
self.operations = [];
self.isAnimating = false;
@@ -535,31 +535,48 @@
};
self.createBoard = function () {
self.board = [];
var maxRows = self.levelData.tiles.length;
+ var maxColsRowIndex = 0;
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++) {
- maxCols = Math.max(maxCols, self.levelData.tiles[row].length);
+ var firstColWithValue = -1; // Initialize to -1 to indicate no value found yet
+ var lastColWithValue = -1; // Initialize to -1 to indicate no value found yet
for (var col = 0; col < self.levelData.tiles[row].length; col++) {
- var value = self.levelData.tiles[row][col];
+ var value = self.levelData.tiles[row][col]; //{4r.1}
if (value !== "") {
- var tile = new HexTile(value, col, row, self.levelData);
- self.board.push(tile);
- boardContainer.addChild(tile);
- self.activeTileCount++; // Increment active tile count
- }
+ //{4r.2}
+ if (firstColWithValue === -1) {
+ // Check if this is the first value in the row
+ firstColWithValue = col;
+ }
+ lastColWithValue = col; // Update lastColWithValue to the current column
+ var tile = new HexTile(value, col, row, self.levelData); //{4r.3}
+ self.board.push(tile); //{4r.4}
+ boardContainer.addChild(tile); //{4r.5}
+ self.activeTileCount++; // Increment active tile count //{4r.6}
+ } //{4r.7}
}
+ var tempMaxCols = lastColWithValue - firstColWithValue + 1; // Calculate the number of columns with values
+ log("tempMaxCols=", tempMaxCols, maxCols); //{4q.1}
+ if (tempMaxCols > maxCols) {
+ //{4q.2}
+ maxCols = tempMaxCols; //{4q.3}
+ maxColsRowIndex = row; //{4q.4}
+ } //{4q.5}
}
log("createBoard max dimensions: ", maxRows, maxCols);
+ // Max grid for 200 tiles = 11x8
// 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
+ // Rows 8 Cols 6 => 50;25
// Row 11 Cols 7 => 83
- // Row 9 Cols 7 => 55
- self.levelBoardOffsetX = 20 * maxCols;
+ // Row 9 Cols 7 => 55;25
+ self.levelBoardOffsetX = 75 * maxCols;
self.levelBoardOffsetY = 30 * maxRows;
for (var i = 0; i < self.board.length; i++) {
var tile = self.board[i];
tile.x += self.levelBoardOffsetX;
@@ -1260,14 +1277,26 @@
"tiles": [["", "", 1, "", ""], ["", "", 1, 1, ""], ["", 2, 2, 2, ""], ["", 2, 2, 2, 2], [3, 3, 3, 3, 3], ["", 2, 2, 2, 2], ["", 2, 2, 2, ""], ["", "", 1, 1, ""], ["", "", 1, "", ""]],
"operations": ['-1', '-1', '-1']
},
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, "", ""]],
+ "tiles": [["", "", "", "", "", ""], ["", "", "", 1, "", ""], ["", 1, 1, 1, 1, ""], ["", 2, "", "", "", 2], [3, 3, 3, 3, 3, 3], ["", 2, "", "", "", 2], ["", 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"]
+ },
+ 6: {
+ "tiles": [["", "", "", "", ""], ["", 1, 1, 1, 1], [1, 1, 1, 1, 1], ["", 1, 1, 1, 1], ["", "", "", "", ""]],
+ "operations": ["+1", "+1", "-1", "-1", "-1"]
+ },
+ 7: {
+ "tiles": [["", "", "", 1, 1, "", "", ""], ["", "", "", 1, 1, 1, "", ""], ["", "", 1, 1, 1, 1, "", ""], ["", "", 1, 1, 1, 1, 1, ""], ["", 1, 1, 1, 1, 1, 1, ""], ["", 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], ["", 1, 1, 1, 1, 1, 1, 1], ["", 1, 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"]
+ },
+ 8: {
+ "tiles": [["", "", 1, 1, 1, "", "", ""], ["", "", 1, 1, 1, 1, "", ""], ["", 1, 1, 1, 1, 1, "", ""], ["", 1, 1, 1, 1, 1, 1, ""], [1, 1, 1, 1, 1, 1, 1, ""], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 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