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
Code edit (1 edits merged)
Please save this source code
User prompt
add logs in calculateStarsScore
User prompt
enhance calculateStarsScore() function. if currentRoundMoves <= levelMinimalMoves[puzzleManager.currentLevel] return 3 if currentRoundMoves < levelMinimalMoves[puzzleManager.currentLevel]*0.66 return 2 else return 1
User prompt
instead of `currentRoundMoves - levelMinimalMoves[puzzleManager.currentLevel];` create a new function: calculateStarsScore() that returns `3-currentRoundMoves - levelMinimalMoves[puzzleManager.currentLevel];`
Code edit (2 edits merged)
Please save this source code
User prompt
in animateRoundExit, spawn a RatingStar with parameter of (currentRoundMoves - levelMinimalMoves[puzzleManager.currentLevel]) at x = 2048+2048/2 then animate it to 2048/2
Code edit (1 edits merged)
Please save this source code
User prompt
after levelConfigs; at the end of the code; add a new global levelMinimalMoves that is an object with properties from 0 to 10; all properties will have the value 1
User prompt
add a new global, currentRoundMoves that count the number of moves player do duing the round. if will be set to 0 in initNewRoundState
User prompt
create a new class RatingStars. its constructor can take a integer parameter stars from 1 to 3. It will have a starsContainer. It will have 3 slots for star asset
Code edit (14 edits merged)
Please save this source code
User prompt
Please fix the bug: 'tween is not defined' in or related to this line: 'simpleTween(logo, {' Line Number: 2009 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'Unable to load plugin: @upit/tween.v1' in or related to this line: 'var tween = LK.import("@upit/tween.v1");' Line Number: 45
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'tile.x += 2 * 2048;' Line Number: 2206
===================================================================
--- original.js
+++ change.js
@@ -45,24 +45,25 @@
var RatingStars = Container.expand(function (stars) {
var self = Container.call(this);
self.starsContainer = new Container();
self.addChild(self.starsContainer);
+ var offset = 450;
// Ensure stars is between 1 and 3
stars = Math.max(1, Math.min(stars, 3));
for (var j = 0; j < 3; j++) {
- var baseTile = self.starsContainer.attachAsset('baseMobileTile', {
+ var baseTile = self.starsContainer.attachAsset('baseTile', {
anchorX: 0.5,
anchorY: 0.5,
- x: j * 400 - 400,
+ x: j * offset - offset,
// Position 1st at x = -400, 2nd at x = 0, 3rd at x = 400
y: 0
});
}
for (var i = 0; i < 3; i++) {
var starAsset = self.starsContainer.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
- x: i * 400 - 400,
+ x: i * offset - offset,
// Adjust spacing as needed
visible: i < stars // Only show the number of stars specified
});
}
@@ -1710,9 +1711,9 @@
};
/****
* Game Variables
****/
-var debug = true;
+var debug = false;
function log() {
if (debug) {
console.log.apply(console, arguments);
}
@@ -1747,8 +1748,10 @@
var dragThreshold = 100; // Lower threshold for easier movement detection
var tapOffset = 50; // Offset for searching nearby tiles when no tile is found
var levelText;
var levelTextXOffset = -50;
+var congratsText;
+var congratsTextOffset = 300;
var waterDrops = [];
var flowers = [];
var waterDropInterval;
var logo;
@@ -1756,8 +1759,13 @@
var isLogoAnimInFinished = false;
var isLogoAnimOutFinished = false;
var isRoundExitAnimFinished = false;
var currentRoundMoves = 0;
+var congratsMessages = {
+ 1: "Well Done!",
+ 2: "Great Job!",
+ 3: "Marvelous!"
+};
// Initialize the game
initializeGame();
/****
* Helper Functions
@@ -1885,16 +1893,12 @@
growGrass.alpha += alphaIncrement; // Adjust the increment for desired speed
} else {
LK.clearInterval(grassAnimation);
LK.setTimeout(function () {
- //cleanPlayingState();
- //initNewRoundState();
changeGameState(GAME_STATE.NEW_ROUND);
}, 2000);
}
}, 80); // Adjust the interval for desired speed
- // }
- //}, 30); // Adjust the interval for desired speed
}
/****
* Game State Management
****/
@@ -1965,8 +1969,21 @@
levelText.blendMode = 3;
levelText.visible = false;
// Add the level text to the game
game.addChild(levelText);
+ congratsText = new Text2(congratsMessages[3], {
+ size: 300,
+ fill: 0x00D7FF,
+ weight: 1000,
+ dropShadow: true
+ });
+ congratsText.x = congratsTextOffset + 2048;
+ congratsText.y = 750;
+ congratsText.anchorX = 0.5;
+ congratsText.blendMode = 1;
+ congratsText.visible = false;
+ // Add the level text to the game
+ game.addChild(congratsText);
// Transition to menu state
changeGameState(GAME_STATE.MENU);
}
function initMenuState() {
@@ -2079,55 +2096,8 @@
gridBoard.visible = true;
levelText.visible = true;
levelText.setText(puzzleManager.currentLevel);
console.log("Levels is now ", puzzleManager.currentLevel);
- /*
- // Animate background images to slide to the left
- tween(backgroundImage1, {
- x: -2048 / 2
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
- tween(backgroundImage2, {
- x: 2048 / 2
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
- tween(gridBoard, {
- x: 2048 / 2
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
- tween(gridBoardSoil, {
- x: 2048 / 2
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
- // Initialize grid with tiles from level configuration
- for (var row = 0; row < puzzleManager.gridSize; row++) {
- for (var col = 0; col < puzzleManager.gridSize; col++) {
- var tile = puzzleManager.grid[row][col];
- if (tile) {
- tween(tile, {
- x: tile.x - 2048 // Animate entrance
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
- }
- }
- }
- tween(levelText, {
- x: 2048 / 2
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
- */
animateRoundEntrance();
// After a short delay, transition to PLAYING state
LK.setTimeout(function () {
changeGameState(GAME_STATE.PLAYING);
@@ -2244,16 +2214,40 @@
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
- tween(ratingStars, {
- x: -2048 / 2
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
+ LK.setTimeout(function () {
+ tween(ratingStars, {
+ x: -2048 / 2
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut
+ });
+ }, 300);
}
});
+ congratsText.setText(congratsMessages[stars]);
+ congratsText.visible = true;
+ congratsText.x = congratsTextOffset + 2048;
+ tween(congratsText, {
+ x: congratsTextOffset
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ LK.setTimeout(function () {
+ tween(congratsText, {
+ x: -2048 / 2
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ congratsText.visible = false;
+ }
+ });
+ }, 300);
+ }
+ });
}
function cleanPlayingState() {
log("cleanPlayingState...");
isPlaying = false;
@@ -2336,9 +2330,9 @@
break;
}
if (!isRoundExitAnimFinished) {
log("Wait exit anim before new round...");
- LK.setTimeout(initNewRoundState, 1000);
+ LK.setTimeout(initNewRoundState, 2000);
break;
}
initNewRoundState();
break;
@@ -2535,9 +2529,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 levelMinimalMoves = {
0: 1,
1: 1,
2: 6,
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