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;
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
===================================================================
--- original.js
+++ change.js
@@ -145,8 +145,39 @@
/****
* Game Code
****/
+function finalAnimation() {
+ var confettiCount = 50;
+ var confettiAssets = ['star', 'flower1', 'flower2', 'flower3', 'flower4', 'flower5', 'flower6', 'flower7', 'flower8', 'flower9', 'flower10'];
+ var confettis = [];
+ for (var i = 0; i < confettiCount; i++) {
+ 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,
+ 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 duration = 2000 + Math.random() * 1000;
+ tween(confetti, {
+ y: targetY,
+ rotation: confetti.rotation + Math.PI * 2
+ }, {
+ duration: duration,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ game.removeChild(confetti);
+ }
+ });
+ }
+}
function calculateStarsScore() {
log("Calculating stars score..."); // Log the start of the calculation
log("Current round moves:", currentRoundMoves); // Log current round moves
log("Level minimal moves for current level:", levelMinimalMoves[puzzleManager.currentLevel]); // Log minimal moves for current level
@@ -1747,9 +1778,9 @@
};
/****
* Game Variables
****/
-var debug = false;
+var debug = true;
function log() {
if (debug) {
console.log.apply(console, arguments);
}
@@ -1840,10 +1871,10 @@
case TileFormat.TYPES.START:
log("No => Tile type is START. Cannot accept flow.");
return false;
case TileFormat.TYPES.END:
- angleDiff = (normalizedIncoming - tileRotation - Math.PI / 2) % (2 * Math.PI);
- log("Yes => Tile type is END.");
+ angleDiff = Math.abs(normalizedIncoming - 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);
log("Yes => Tile type is VERTICAL");
@@ -2590,15 +2621,15 @@
9: 8,
10: 18
};
var levelConfigs = {
- 0: [["M-C-2", "M-H-0", "F-H-0", "F-E-1"], ["M-C-0", "", "", ""], ["M-H-0", "M-C-1", "M-C-3", ""], ["F-S-3", "F-H-0", "M-V-0", ""]],
+ 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", "", ""]],
// Level 3 - 8
- 3: [["", "", "", ""], ["F-S-3", "F-C-3", "F-C-2", "F-E-1"], ["", "M-C-0", "M-C-1", ""], ["M-V-0", "", "", "M-V-0"]],
+ 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"]],
// Level 5 - 15
5: [["M-H-0", "", "M-V-0", "F-E-1"], ["", "", "", "M-H-0"], ["", "", "", ""], ["F-S-2", "", "M-V-0", "M-C-2"]],
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