Code edit (18 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: confinalResultTextgratsText is not defined' in or related to this line: 'confinalResultTextgratsText.visible = true;' Line Number: 269
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: 0.5 is not a function' in or related to this line: 'var confetti = LK.getAsset('star', {' Line Number: 225
Code edit (13 edits merged)
Please save this source code
User prompt
rework finalAnimation: - don't use flower assets for confettis - make initial y = Math.random()*2732 -2732 - make targetY = 3000 - spawn progressively 100 flowers in the area x=0,y=200 / x=2048,y=2732-200
Code edit (1 edits merged)
Please save this source code
User prompt
in initPuzzle, if (!level) call finalAnimation() and return
User prompt
create a new function 'finalAnimation()' that creates a confettis like animation with star and flowers assets
Code edit (10 edits merged)
Please save this source code
User prompt
add a new 'enable' function in ResetButton that sets alpha to 1, and interactive to true;
User prompt
add a new 'disable' function in ResetButton that sets alpha to 0.5, and interactive to false;
Code edit (5 edits merged)
Please save this source code
User prompt
add a resetButton class
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
IN ``` for (var i = 0; i < puzzleManager.gridSize; i++) { for (var j = 0; j < puzzleManager.gridSize; j++) { var x = i * tileSize + gridBoard.x - gridBoard.width / 2 + tileSize / 2 + boardOffsetX; var y = j * tileSize + gridBoard.y - gridBoard.height / 2 + tileSize / 2 + boardOffsetY; var flower = new Flower(puzzleManager.currentLevel, x, y); flowers.push(flower); game.addChild(flower); } } ```` add another inner loop that goes from 0 to puzzleManager.currentLevel so that there are more flowers when we advance in levels
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: popSpeed1 is not defined' in or related to this line: 'flowerGraphics.scaleX += popSpeed1; // Adjust the increment for desired speed' Line Number: 85
Code edit (4 edits merged)
Please save this source code
User prompt
in Flower constructor play flowerPop sound with a random delay of 0 to 300ms
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in RatingStars, add 3 baseMobileTile. For better design place 1st at x = -400 and the 3rd at x=400
===================================================================
--- original.js
+++ change.js
@@ -62,9 +62,9 @@
} else {
if (!self.popPlayed) {
self.popPlayed = true;
LK.setTimeout(function () {
- LK.getSound('flowerPop').play();
+ flowerPopSound.play();
}, 0.5 * (rand1 + rand2) * 500);
}
}
};
@@ -169,8 +169,9 @@
var spawnedCount = 0;
finalAnimationInterval = LK.setInterval(function () {
if (spawnedCount >= confettiCount) {
LK.clearInterval(finalAnimationInterval);
+ isFinalAnimationFinished = true;
return;
}
var rand1 = Math.random();
var rand2 = Math.random();
@@ -198,24 +199,35 @@
}
});
spawnedCount++;
var x = rand1 * 2048;
- var y = 300 + rand2 * (2732 - 700);
+ var y = 350 + rand2 * (2732 - 750);
var flower = new Flower(puzzleManager.currentLevel, x, y);
flowers.push(flower);
game.addChild(flower);
}, 20);
- congratsText.x = congratsTextOffset;
- congratsText.y = -1300;
- congratsText.setText("Congratulations!\nGame Complete!");
- congratsText.visible = true;
- tween(congratsText, {
- x: congratsTextOffset,
- y: 1366
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
+ LK.setTimeout(function () {
+ game.removeChild(congratsText);
+ var finalResultText = new Text2("All Solved!\nCongratulations!", {
+ size: 250,
+ anchorX: 0.5,
+ fill: 0xFFFFFF,
+ weight: 1000,
+ dropShadow: true,
+ align: 'center'
+ });
+ finalResultText.x = 100;
+ finalResultText.y = -1300;
+ finalResultText.alpha = 0.9;
+ finalResultText.visible = true;
+ game.addChildAt(finalResultText, game.children.length - 1);
+ tween(finalResultText, {
+ y: 1000
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut
+ });
+ }, 1800);
}
function calculateStarsScore() {
log("Calculating stars score..."); // Log the start of the calculation
log("Current round moves:", currentRoundMoves); // Log current round moves
@@ -1742,9 +1754,9 @@
if (this.checkWinCondition()) {
this.isComplete = true;
resetButton.disable();
isPlaying = false;
- isGameFinished = puzzleManager.currentLevel == levelConfigs.length || debug && puzzleManager.currentLevel == 1;
+ isGameFinished = puzzleManager.currentLevel == nbLevels; // || debug && puzzleManager.currentLevel == 1;
LK.setTimeout(function () {
puzzleManager.startWaterFlow();
LK.getSound('levelWon').play();
}, 300);
@@ -1819,9 +1831,9 @@
};
/****
* Game Variables
****/
-var debug = true;
+var debug = false;
function log() {
if (debug) {
console.log.apply(console, arguments);
}
@@ -1868,15 +1880,17 @@
var isLogoAnimInFinished = false;
var isLogoAnimOutFinished = false;
var isRoundExitAnimFinished = false;
var isGameFinished = false;
+var isFinalAnimationFinished = false;
var finalAnimationInterval;
var currentRoundMoves = 0;
var congratsMessages = {
1: "Well Done!",
2: "Great Job!",
3: "Marvelous!"
};
+var flowerPopSound = LK.getSound('flowerPop');
// Initialize the game
initializeGame();
/****
* Helper Functions
@@ -2007,9 +2021,13 @@
growGrass.alpha += alphaIncrement; // Adjust the increment for desired speed
} else {
LK.clearInterval(grassAnimation);
LK.setTimeout(function () {
- changeGameState(GAME_STATE.NEW_ROUND);
+ if (isGameFinished) {
+ changeGameState(GAME_STATE.SCORE);
+ } else {
+ changeGameState(GAME_STATE.NEW_ROUND);
+ }
}, 2000);
}
}, 80); // Adjust the interval for desired speed
}
@@ -2218,9 +2236,9 @@
gridBoardSoil.visible = true;
gridBoard.visible = true;
levelText.visible = true;
levelText.setText(puzzleManager.currentLevel);
- console.log("Levels is now ", puzzleManager.currentLevel);
+ log("Levels is now ", puzzleManager.currentLevel);
animateRoundEntrance();
// After a short delay, transition to PLAYING state
LK.setTimeout(function () {
changeGameState(GAME_STATE.PLAYING);
@@ -2248,9 +2266,9 @@
});
});
// Check if level is complete
if (puzzleManager.isComplete) {
- changeGameState(GAME_STATE.SCORE);
+ changeGameState(GAME_STATE.NEW_ROUND);
}
}
}
function animateRoundExit(callBack) {
@@ -2480,9 +2498,12 @@
puzzleManager.selectTile(x, y);
}
break;
case GAME_STATE.SCORE:
- changeGameState(GAME_STATE.MENU);
+ //changeGameState(GAME_STATE.MENU);
+ if (isFinalAnimationFinished) {
+ LK.showGameOver();
+ }
break;
}
};
game.move = function (x, y, obj) {
@@ -2646,8 +2667,9 @@
/* All Corners :
0: [["F-E-0", "F-C-2", "F-C-3", ""], ["F-C-1", "F-C-0", "F-C-1", "F-C-3"], ["F-C-2", "F-C-3", "F-C-2", "F-C-0"], ["F-S-2", "F-C-1", "", "M-C-0"]],
0: [["F-S-0", "F-C-2", "F-C-3", ""], ["F-C-1", "F-C-0", "F-C-1", "F-C-3"], ["F-C-2", "F-C-3", "F-C-2", "F-C-0"], ["F-E-2", "F-C-1", "", "M-C-0"]],
*/
+var nbLevels = 10;
var levelMinimalMoves = {
0: 1,
1: 1,
2: 6,
@@ -2664,9 +2686,9 @@
0: [["F-S-0", "", "", ""], ["F-V-0", "", "", ""], ["F-V-0", "", "M-H-0", ""], ["F-C-1", "F-H-0", "", "F-E-1"]],
// Level 1 - 1
1: [["F-S-0", "", "", ""], ["F-V-0", "", "", ""], ["F-V-0", "", "M-H-0", ""], ["F-C-1", "F-H-0", "", "F-E-1"]],
// Level 2 - 6
- 22: [["", "M-V-0", "F-E-0", ""], ["", "M-C-0", "F-V-0", ""], ["", "", "", ""], ["F-S-3", "F-H-0", "", ""]],
+ 2: [["", "M-V-0", "F-E-0", ""], ["", "M-C-0", "F-V-0", ""], ["", "", "", ""], ["F-S-3", "F-H-0", "", ""]],
// Level 3 - 8
3: [["", "", "", ""], ["F-S-3", "F-C-3", "F-C-2", "F-E-1"], ["", "M-V-0", "F-V-0", ""], ["", "M-C-0", "M-C-1", ""]],
// Level 4 - 10
4: [["M-V-0", "F-C-2", "F-C-3", ""], ["M-C-1", "M-V-0", "F-V-0", "F-E-0"], ["F-S-0", "", "", "F-C-0"], ["F-C-1", "", "", "M-C-0"]],
straigth zenith view square light wooden pallet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
straigth zenith view square wooden pallet with big screws in each corner Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
simple yellow rating star. Modern video game style
tileSlide
Sound effect
levelWon
Sound effect
tileBlocked
Sound effect
fountain
Sound effect
waterInPipe
Sound effect
bgMusic
Music
logoBounce
Sound effect
levelStart
Sound effect
bgMusic2
Music
flowerPop
Sound effect
roundResult
Sound effect
gameWon
Sound effect
resetSound
Sound effect
birds
Sound effect
birds2
Sound effect
birds3
Sound effect