Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: isEnabled is not defined' in or related to this line: 'if (isEnabled) {' Line Number: 985
Code edit (5 edits merged)
Please save this source code
User prompt
in handlePlayingStateUp, find a way to exit the `puzzleManager.board.forEach` loop when operation is applied to a tile because `return`doesn't seem to work
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of null (reading 'type')' in or related to this line: 'var newValue = Math.max(0, currentTile.value + parseInt(operation.type));' Line Number: 1541
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2170 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2170 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2170 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2170 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2173 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2173 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2174 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(dragNode, {' Line Number: 2174 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (15 edits merged)
Please save this source code
Code edit (25 edits merged)
Please save this source code
Code edit (25 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: Error: Invalid color format. Expected 0xRRGGBB format, received: undefined' in or related to this line: 'tween(tileGraphics, {' Line Number: 358 โช๐ก Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1, @upit/tween.v1
Code edit (6 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -478,8 +478,9 @@
var MenuBoard = Container.expand(function () {
var self = Container.call(this);
self.menuGrid = [];
self.menuCells = [];
+ self.isLevelSelected = false;
// Define grid dimensions
var rows = 7;
var cols = 6;
var cellSize = LK.getAsset('menuCell', {}).width;
@@ -536,10 +537,15 @@
if (!isMenuReady) {
log("Menu not ready.", level); //{3F.2}
return;
}
+ if (self.isLevelSelected) {
+ log("Already selected!", level); //{3F.2}
+ return;
+ }
log("Tapped level number:", level); //{3F.2}
if (level <= puzzleManager.maxReachedLevelNumber) {
+ self.isLevelSelected = true;
LK.getSound("menuLevelSelect").play();
// Store initial width and height
var initialWidth = levelText.width;
var initialHeight = levelText.height;
@@ -580,8 +586,9 @@
}
}
}
self.updateMenuGrid = function () {
+ self.isLevelSelected = false;
// Foreach levelText in menuGrid, update the level color depending on puzzleManager.maxReachedLevelNumber
for (var row = 0; row < self.menuGrid.length; row++) {
for (var col = 0; col < self.menuGrid[row].length; col++) {
var levelText = self.menuGrid[row][col];
@@ -920,8 +927,9 @@
tint: 0xEAEEE8
});
self.down = function () {
self.disable();
+ menuButton.deactivate();
tween(self, {
// Animate rotation
rotation: Math.PI * 2 // Rotate 360 degrees
}, {
@@ -963,8 +971,12 @@
});
};
self.activate = function () {
log("Reset button activate...");
+ if (puzzleManager.currentLevel == 1) {
+ log("No Reset in level 1...");
+ return;
+ }
self.visible = true;
self.y = -300;
tween(self, {
y: 130
@@ -1207,11 +1219,11 @@
self.game = game;
self.activeTileCount = 0; // Initialize active tile count
self.levelBoardOffsetX = 0; // Initialize levelBoardOffsetX
self.levelBoardOffsetY = 0; // Initialize levelBoardOffsetY
- self.currentLevel = debug ? 1 : 1;
+ self.currentLevel = debug ? 24 : 1;
self.previousLevelNumber = 1;
- self.maxReachedLevelNumber = storage.maxReachedLevelNumber || 1; // Retrieve from storage or default to 1
+ self.maxReachedLevelNumber = debug ? self.currentLevel : storage.maxReachedLevelNumber || 1; // Retrieve from storage or default to 1
self.board = [];
self.operations = [];
self.isAnimating = false;
self.selectedOperation = null;
@@ -1265,12 +1277,13 @@
self.levelFailed = false;
// Load the current level
self.previousLevelNumber = self.currentLevel;
if (noContinue) {
+ console.log("End Reset, but no continue. currentState", currentState);
return;
}
LK.setTimeout(function () {
- log("End Reset, currentState ", currentState);
+ console.log("End Reset, now loadLevel currentState ", currentState);
self.loadLevel(self.currentLevel);
}, 850);
};
self.loadLevel = function (levelNumber) {
@@ -1293,8 +1306,10 @@
//LK.setTimeout(self.updateOperations, 900);
LK.setTimeout(function () {
self.animateTilesEntrance();
self.animateOperationsEntrance();
+ resetButton.activate(); // Make resetButton visible in PLAYING state
+ menuButton.activate();
}, 800);
};
self.createBoard = function () {
self.board = [];
@@ -1626,8 +1641,9 @@
if (self.activeTileCount <= 0) {
self.playVictoryAnimation();
isPlaying = false;
resetButton.disable();
+ menuButton.deactivate();
LK.setTimeout(function () {
self.previousLevelNumber = self.currentLevel;
self.currentLevel++; // Advance to the next level
gameHints.removeHint();
@@ -1757,9 +1773,19 @@
//menuBoard.x = 2048; // Start off-screen to the right
menuBoard.visible = true;
var delayAnim = startButton.visible ? 800 : 0;
LK.setTimeout(function () {
- menuBoard.animateEntrance();
+ if (puzzleManager.maxReachedLevelNumber == 1)
+ // First Launch => Auto-select level 1
+ {
+ backgroundImage.hideWall();
+ menuBoard.visible = false;
+ puzzleManager.selectLevel(1);
+ levelNumberText.setText(1, 2);
+ changeGameState(GAME_STATE.NEW_ROUND);
+ } else {
+ menuBoard.animateEntrance();
+ }
}, delayAnim);
menuButton.deactivate();
}
function handleMenuLoop() {
@@ -1783,12 +1809,9 @@
return;
}
puzzleManager.initPuzzle();
levelNumberText.show();
- //if (debug)
- {
- changeGameState(GAME_STATE.PLAYING);
- }
+ changeGameState(GAME_STATE.PLAYING);
}
function handleNewRoundLoop() {
// Handle the game loop for NEW_ROUND state
log("Handling NEW_ROUND Loop");
@@ -1804,13 +1827,13 @@
showHintsInterval = LK.setTimeout(function () {
gameHints.showHint1();
}, 2000);
}
- LK.setTimeout(function () {
- //resetButton.disable();
- resetButton.activate(); // Make resetButton visible in PLAYING state
- menuButton.activate();
- }, 3000);
+ // LK.setTimeout(function () {
+ // //resetButton.disable();
+ // resetButton.activate(); // Make resetButton visible in PLAYING state
+ // menuButton.activate();
+ // }, 3000);
}
function handlePlayingLoop() {
// Handle the game loop for PLAYING state
log("Handling PLAYING Loop");
@@ -2280,9 +2303,10 @@
//<Write imports for supported plugins here>
/***********************************************************************************************/
/****************************************** GLOBAL VARIABLES ***********************************/
/***********************************************************************************************/
-var debug = false;
+var debug = true;
+var resetProgress = false;
var isPlaying = false;
var GAME_STATE = {
INIT: 'INIT',
MENU: 'MENU',
@@ -2452,8 +2476,24 @@
},
20: {
"tiles": [["", "", "", 1, 2, 3, 1], ["", "", 1, 1, 2, 3, 1], [1, 1, 2, 2, 3, 1, 2], ["", 2, 2, 3, 3, 1, 2], [3, 3, 3, 1, 1, 2, 2], ["", 1, 1, 1, 2, 2, 2], [2, 2, 2, 2, 2, 2, 3], ["", 2, 2, 2, 2, 3, 3], [3, 3, 3, 3, 3, 2, 2], ["", 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, ""]],
"operations": ["-1", "-1", "-1", "-1", "+2"]
+ },
+ 21: {
+ "tiles": [["", "", "", "", "", "", ""], ["", "", 1, 1, 2, 2, 3], ["", 1, 1, 2, 2, 3, 3], ["", 1, 1, 2, 2, 3, 3], ["", "", 2, "", "", 3, ""], ["", "", "", 2, "", "", ""], ["", 3, "", 2, "", "", ""], ["", 3, 3, 2, 2, 1, 1], [3, 3, 2, 2, 1, 1, ""], ["", 3, 2, 2, 1, 1, ""], ["", "", "", "", "", "", ""]],
+ "operations": ["+2", "+1", "-3", "-1"]
+ },
+ 22: {
+ "tiles": [["", "", "", "", "", "", ""], ["", 4, "", 4, "", 4, ""], ["", 4, 4, 4, 4, "", ""], ["", 1, 4, 1, 4, 1, ""], ["", 1, 1, 1, 1, 2, ""], ["", 2, 1, 2, 1, 2, 1], [2, "", 2, "", 2, "", 2], ["", 3, 1, 3, 1, 3, 1], ["", 3, 3, 3, 3, 3, 3], ["", "", 3, "", 3, "", 3], ["", "", "", "", "", "", ""]],
+ "operations": ["-2", "-2", "-1", "-1", "+1", "+1"]
+ },
+ 23: {
+ "tiles": [["", "", "", "", "", "", ""], ["", "", "", 4, 4, "", ""], ["", "", 4, "", 4, "", ""], ["", "", 4, 2, 1, 4, ""], ["", 4, "", 3, "", 4, ""], ["", 4, 2, "", "", 3, 4], [4, "", 2, "", 3, "", 4], ["", 4, "", 1, 1, "", 4], ["", 4, 1, "", 1, 4, ""], ["", "", 4, 4, 4, 4, ""], ["", "", "", "", "", "", ""]],
+ "operations": ["-2", "-1", "-1", "+1", "+1", "+1"]
+ },
+ 24: {
+ "tiles": [["", "", "", "", 2, "", 3], ["", "", 2, "", 2, 3, 3], ["", 2, "", 3, 3, "", ""], ["", "", 2, 3, "", 2, ""], [3, 3, 2, "", 2, 3, 3], ["", "", 2, "", 3, 3, ""], ["", "", 2, 3, "", 2, ""], ["", 3, 3, 2, "", 2, 3], ["", "", "", 2, 3, 3, 3], ["", "", "", 3, 2, "", 2], ["", 3, 3, "", 2, "", 2]],
+ "operations": ["-2", "-1", "+1"]
}
};
/***********************************************************************************************/
/***************************************** GAME INITIALISATION *********************************/
@@ -2472,8 +2512,11 @@
middleLayer.addChild(boardContainer);
boardContainer.x = 0;
boardContainer.y = 0;
puzzleManager = new PuzzleManager(game);
+ if (debug && resetProgress) {
+ puzzleManager.maxReachedLevelNumber = 1;
+ }
startButton = new StartButton();
startButton.x = centerX; // Center horizontally
startButton.y = centerY; // Center vertically
startButton.visible = true;
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