Code edit (1 edits merged)
Please save this source code
User prompt
Reset the storage.currentLevel just before GameOver
Code edit (10 edits merged)
Please save this source code
User prompt
Use the storage plugin to store puzzleManager.currentLevel. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Use the storage plugin to store currentLevel. reset it when game is finished ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
in code: ``` for (var i = 0; i < 3; i++) { LK.setTimeout(function () { var starAsset = self.starsContainer.attachAsset('star', { anchorX: 0.5, anchorY: 0.5, x: i * offset - offset, // Adjust spacing as needed scaleX: 0, // Start with scale 0 for grow effect scaleY: 0, // Start with scale 0 for grow effect visible: i < stars // Only show the number of stars specified }); LK.getSound("roundResult").play(); // Animate the starAsset to grow from 0 to its final size with easeIn tween(starAsset, { scaleX: 1, scaleY: 1 }, { duration: 600, easing: tween.easeIn }); }, 500); } ``` Fix the variables scope bug, don't use let as it's not available
User prompt
in code: ``` for (var i = 0; i < 3; i++) { LK.setTimeout(function () { var starAsset = self.starsContainer.attachAsset('star', { anchorX: 0.5, anchorY: 0.5, x: i * offset - offset, // Adjust spacing as needed scaleX: 0, // Start with scale 0 for grow effect scaleY: 0, // Start with scale 0 for grow effect visible: i < stars // Only show the number of stars specified }); LK.getSound("roundResult").play(); // Animate the starAsset to grow from 0 to its final size with easeIn tween(starAsset, { scaleX: 1, scaleY: 1 }, { duration: 600, easing: tween.easeIn }); }, 500); } ``` Fix the variables scope bug
Code edit (12 edits merged)
Please save this source code
User prompt
in RatingStars, when spawning a starAsset, make it grow from 0 to its final size with and easeIn
Code edit (1 edits merged)
Please save this source code
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;
===================================================================
--- original.js
+++ change.js
@@ -146,37 +146,43 @@
/****
* Game Code
****/
function finalAnimation() {
- var confettiCount = 50;
- var confettiAssets = ['star', 'flower1', 'flower2', 'flower3', 'flower4', 'flower5', 'flower6', 'flower7', 'flower8', 'flower9', 'flower10'];
+ var confettiCount = 100;
+ var confettiAssets = ['star'];
var confettis = [];
- for (var i = 0; i < confettiCount; i++) {
+ var spawnedCount = 0;
+ finalAnimationInterval = LK.setInterval(function () {
+ if (spawnedCount >= confettiCount) {
+ LK.clearInterval(finalAnimationInterval);
+ return;
+ }
var assetId = confettiAssets[Math.floor(Math.random() * confettiAssets.length)];
var confetti = LK.getAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
- y: Math.random() * 2732,
+ y: Math.random() * 2732 - 2732,
scaleX: 0.5 + Math.random() * 0.5,
scaleY: 0.5 + Math.random() * 0.5,
rotation: Math.random() * Math.PI * 2
});
confettis.push(confetti);
game.addChild(confetti);
- var targetY = 2732 + 100;
+ var targetY = 3000;
var duration = 2000 + Math.random() * 1000;
tween(confetti, {
y: targetY,
rotation: confetti.rotation + Math.PI * 2
}, {
duration: duration,
- easing: tween.easeOut,
+ easing: tween.bounceIn,
onFinish: function onFinish() {
game.removeChild(confetti);
}
});
- }
+ spawnedCount++;
+ }, 20);
}
function calculateStarsScore() {
log("Calculating stars score..."); // Log the start of the calculation
log("Current round moves:", currentRoundMoves); // Log current round moves
@@ -1347,9 +1353,9 @@
self.reset();
var level = levelConfigs[self.currentLevel];
if (!level) {
log("Next Level not found:", self.currentLevel);
- finalAnimation(); // Call finalAnimation if level is not found
+ changeGameState(GAME_STATE.SCORE);
return;
}
resetButton.visible = true;
resetButton.disable();
@@ -1703,8 +1709,9 @@
if (this.checkWinCondition()) {
this.isComplete = true;
resetButton.disable();
isPlaying = false;
+ isGameFinished = puzzleManager.currentLevel == levelConfigs.length || debug && puzzleManager.currentLevel == 1;
LK.setTimeout(function () {
puzzleManager.startWaterFlow();
LK.getSound('levelWon').play();
}, 300);
@@ -1827,8 +1834,10 @@
var puzzleManager;
var isLogoAnimInFinished = false;
var isLogoAnimOutFinished = false;
var isRoundExitAnimFinished = false;
+var isGameFinished = false;
+var finalAnimationInterval;
var currentRoundMoves = 0;
var congratsMessages = {
1: "Well Done!",
2: "Great Job!",
@@ -1872,9 +1881,9 @@
case TileFormat.TYPES.START:
log("No => Tile type is START. Cannot accept flow.");
return false;
case TileFormat.TYPES.END:
- angleDiff = Math.abs(normalizedIncoming - tileRotation - Math.PI / 2) % (2 * Math.PI);
+ angleDiff = Math.abs(normalizedIncoming - tileRotation + (Math.abs(Math.sin(tileRotation)) - Math.abs(Math.cos(tileRotation))) * Math.PI / 2) % (2 * Math.PI);
log("Yes => Tile type is END.", angleDiff, angleDiff < 0.1);
return angleDiff < 0.1;
case TileFormat.TYPES.VERTICAL:
angleDiff = Math.abs(normalizedIncoming - Math.PI / 2) % (2 * Math.PI);
@@ -2168,8 +2177,11 @@
// Reset puzzle manager for new round
if (puzzleManager) {
puzzleManager.initPuzzle();
}
+ if (isGameFinished) {
+ return;
+ }
// Show gridBoard
gridBoardSoil.visible = true;
gridBoard.visible = true;
levelText.visible = true;
@@ -2360,25 +2372,21 @@
}
function initScoreState() {
// Show score screen
log("Entering Score State");
- levelText.visible = true;
- levelText.text = "Level Complete!\nTap to continue";
+ congratsText.visible = true;
+ congratsText.x = congratsTextOffset;
+ congratsText.setText("Game Complete!\nTap to continue");
+ finalAnimation(); // Call finalAnimation if level is not found
}
function handleScoreLoop() {
// Update any score animations
- if (puzzleManager) {
- puzzleManager.grid.forEach(function (row) {
- row.forEach(function (tile) {
- if (tile) {
- tile.update();
- }
- });
- });
- }
}
function cleanScoreState() {
levelText.visible = false;
+ if (finalAnimationInterval) {
+ LK.clearInterval(finalAnimationInterval);
+ }
}
function changeGameState(newState) {
// Clean up current state
log("Changing state from", currentState, "to", newState);
@@ -2626,9 +2634,9 @@
0: [["M-V-0", "F-C-2", "F-H-0", "F-C-3"], ["", "F-E-2", "", ""], ["", "M-V-0", "F-S-0", ""], ["", "M-C-1", "M-C-0", ""]],
// 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
- 2: [["", "M-V-0", "F-E-0", ""], ["", "M-C-0", "F-V-0", ""], ["", "", "", ""], ["F-S-3", "F-H-0", "", ""]],
+ 22: [["", "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