User prompt
Please fix the bug: 'Uncaught ReferenceError: createjs is not defined' in or related to this line: 'self.water = new createjs.Shape();' Line Number: 165
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in Tile setType , attach all asset in the switch(type) to the pipeContainer
Code edit (14 edits merged)
Please save this source code
User prompt
in Tile, add a new pipeContainer property which is a cointainer
Code edit (1 edits merged)
Please save this source code
User prompt
make fountain sound fade out after 2sec
User prompt
play fontain sound only once when fountains is visible
User prompt
play fontain sound when fountains is visible
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
tween(logo, {...}) does nothing. please fix
User prompt
easing: tween.bounceOut doesn't exists so fix that line properly
User prompt
in initMenuState, init the logo out of screen, then in handleMenuLoop animate its entrace with a bounce anim and finish the anim at logo.x = 2048 / 2; logo.y = 2732 / 2 - 50;
User prompt
in handleMenuLoop use tween plugin to animate logo entrance in a bump anim βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
in initMenuState, move logo in middle layer
User prompt
Place it before the logo
User prompt
Add backgroundPlaying1 in menu state init too
User prompt
Play tileBlocked when player makes invalid move
User prompt
Play level when level solved
User prompt
Play tile slide when moving tile
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'includes')' in or related to this line: 'var baseTileAsset = type == 'start' || type == 'end' || puzzleManager && puzzleManager.levelConfigs && puzzleManager.levelConfigs[puzzleManager.currentLevel] && puzzleManager.levelConfigs[puzzleManager.currentLevel].fixedTiles.includes(x + ',' + y) ? 'baseTile' : 'baseMobileTile';' Line Number: 49
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'includes')' in or related to this line: 'var baseTileAsset = type == 'start' || type == 'end' || puzzleManager && puzzleManager.levelConfigs[puzzleManager.currentLevel].fixedTiles.includes(x + ',' + y) ? 'baseTile' : 'baseMobileTile';' Line Number: 49
===================================================================
--- original.js
+++ change.js
@@ -131,8 +131,18 @@
dir: ''
});
break;
case 'straightPipeH':
+ self.water = self.pipeContainer.attachAsset('waterH', {
+ anchorX: 0,
+ anchorY: 0.5,
+ x: 0,
+ y: 40,
+ width: 0,
+ height: 20,
+ visible: false,
+ dir: ''
+ });
self.pipeContainer.attachAsset('straightPipeHAsset', {
anchorX: 0.5,
anchorY: 0.5,
y: -40,
@@ -144,17 +154,8 @@
scaleY: -1,
y: 30,
tint: self.baseTint
});
- self.water = self.pipeContainer.attachAsset('waterH', {
- anchorX: 0,
- anchorY: 0.5,
- x: -130,
- y: -5,
- width: 0,
- visible: false,
- dir: 'lr'
- });
break;
case 'straightPipeV':
self.pipeContainer.attachAsset('straightPipeVAsset', {
anchorX: 0.5,
@@ -286,46 +287,96 @@
};
self.normalizeRotation = function (rotation) {
// If rotation is a number (radians), convert it to our direction system
if (typeof rotation === 'number') {
- // Convert radians to our direction system
- // 0 = up
- // Ο/2 = right
- // Ο = down
- // 3Ο/2 = left
- var angle = rotation % (2 * Math.PI);
- if (angle < 0) {
- angle += 2 * Math.PI;
+ switch (self.type) {
+ case 'cornerPipe':
+ // Convert radians to our direction system
+ // 0 = up
+ // Ο/2 = right
+ // Ο = down
+ // 3Ο/2 = left
+ var angle = rotation % (2 * Math.PI);
+ if (angle < 0) {
+ angle += 2 * Math.PI;
+ }
+ if (angle < Math.PI / 4 || angle > 7 * Math.PI / 4) {
+ log("Corner normalize ", angle, " => up");
+ return 'left'; //'up';
+ }
+ if (angle < 3 * Math.PI / 4) {
+ log("Corner normalize ", angle, " => right");
+ return 'right';
+ }
+ if (angle < 5 * Math.PI / 4) {
+ log("Corner normalize ", angle, " => down");
+ return 'down';
+ }
+ log("Corner normalize ", angle, " => left");
+ return 'up'; //'left';
+ break;
+ default:
+ // Convert radians to our direction system
+ // 0 = up
+ // Ο/2 = right
+ // Ο = down
+ // 3Ο/2 = left
+ var angle = rotation % (2 * Math.PI);
+ if (angle < 0) {
+ angle += 2 * Math.PI;
+ }
+ if (angle < Math.PI / 4 || angle > 7 * Math.PI / 4) {
+ return 'up';
+ }
+ if (angle < 3 * Math.PI / 4) {
+ return 'right';
+ }
+ if (angle < 5 * Math.PI / 4) {
+ return 'down';
+ }
+ return 'left';
+ break;
}
- if (angle < Math.PI / 4 || angle > 7 * Math.PI / 4) {
- return 'up';
- }
- if (angle < 3 * Math.PI / 4) {
- return 'right';
- }
- if (angle < 5 * Math.PI / 4) {
- return 'down';
- }
- return 'left';
}
return rotation || 'down';
};
self.setRotation = function (direction) {
- switch (direction) {
- case 'left':
- self.pipeContainer.rotation = -Math.PI * 1.5;
+ switch (self.type) {
+ case 'cornerPipe':
+ switch (direction) {
+ case 'left':
+ self.pipeContainer.rotation = 0;
+ break;
+ case 'right':
+ self.pipeContainer.rotation = -Math.PI * 1.5;
+ break;
+ case 'up':
+ self.pipeContainer.rotation = 0;
+ break;
+ case 'down':
+ self.pipeContainer.rotation = Math.PI;
+ break;
+ }
+ log("Corner Set rot ", direction, " => ", self.pipeContainer.rotation);
break;
- case 'right':
- self.pipeContainer.rotation = -Math.PI * 0.5;
+ default:
+ switch (direction) {
+ case 'left':
+ self.pipeContainer.rotation = -Math.PI * 1.5;
+ break;
+ case 'right':
+ self.pipeContainer.rotation = -Math.PI * 0.5;
+ break;
+ case 'up':
+ self.pipeContainer.rotation = 0;
+ break;
+ case 'down':
+ self.pipeContainer.rotation = Math.PI;
+ break;
+ }
break;
- case 'up':
- self.pipeContainer.rotation = 0;
- break;
- case 'down':
- self.pipeContainer.rotation = Math.PI;
- break;
}
- log('Tile position:', self.x, self.y, 'Tile rotation:', self.rotation);
+ log('Tile position:', self.x, self.y, 'Tile rotation:', self.pipeContainer.rotation);
};
self.getNextPositions = function (x, y, type, normalizedRotation) {
var nextPositions = [];
switch (type) {
@@ -381,16 +432,19 @@
// Corner pipe animation
var progress = (LK.ticks - self.startFlowTicks) * self.flowSpeed; // Accelerate water speed
var thirdSize = self.maxWaterSize / 3 - 10; // Split animation into three phases
var sidesSize = self.maxWaterSize / 3; //+ 40;
- if (progress < self.maxWaterSize) {
+ var normalizedRotation = self.normalizeRotation(self.pipeContainer.rotation);
+ var isRotatedRight = normalizedRotation === Math.PI / 2; // Ο/2 means rotated right
+ if (isRotatedRight) {
+ // Standard sequence for right rotation
// Phase 1: Vertical water grows
if (progress < thirdSize) {
if (self.waterV) {
self.waterV.height = progress;
}
}
- // Phase 2: Corner water appears and rotates
+ // Phase 2: Corner water appears
else if (progress < thirdSize * 2) {
if (self.waterV) {
self.waterV.height = thirdSize; // Keep vertical at full first-phase height
}
@@ -417,8 +471,45 @@
self.waterH.width = Math.min(progress - thirdSize * 2, sidesSize);
}
}
} else {
+ // Inverted sequence for left rotation
+ // Phase 1: Horizontal water grows
+ if (progress < thirdSize) {
+ if (self.waterH) {
+ self.waterH.width = progress;
+ }
+ }
+ // Phase 2: Corner water appears
+ else if (progress < thirdSize * 2) {
+ if (self.waterH) {
+ self.waterH.width = thirdSize; // Keep horizontal at full first-phase height
+ }
+ if (self.waterCorner) {
+ self.waterCorner.visible = true;
+ self.waterCorner.alpha = Math.min(Math.max(0, ((progress - thirdSize) / thirdSize - 0.5) * 2, 0), 1); // Animate alpha from 0 to 1
+ // Calculate rotation from -PI/2 to -PI
+ var rotationProgress = (progress - thirdSize) / thirdSize; // 0 to 1
+ self.waterCorner.rotation = -Math.PI / 2 - rotationProgress * Math.PI / 2;
+ }
+ }
+ // Phase 3: Vertical water grows
+ else {
+ if (self.waterH) {
+ self.waterH.width = thirdSize;
+ }
+ if (self.waterCorner) {
+ self.waterCorner.visible = true;
+ self.waterCorner.alpha = 1;
+ self.waterCorner.rotation = -Math.PI; // Keep at final rotation
+ }
+ if (self.waterV) {
+ self.waterV.visible = true;
+ self.waterV.height = Math.min(progress - thirdSize * 2, sidesSize);
+ }
+ }
+ }
+ if (progress >= self.maxWaterSize) {
self.flow = false;
}
} else if (self.type === 'end' && self.fountain) {
// Animate fountain growth
@@ -442,15 +533,21 @@
}
} else if (self.water) {
// Regular pipe animation
var heightValue = (LK.ticks - self.startFlowTicks) * self.flowSpeed;
- if (self.water.dir != '' && heightValue < self.maxWaterSize) {
- if (self.water.dir == 'tb') {
+ if (heightValue < self.maxWaterSize) {
+ self.water.visible = true;
+ if (self.water.dir === 'lr') {
+ self.water.width = heightValue;
+ self.water.x = 0;
+ self.water.scaleX = 1;
+ } else if (self.water.dir === 'rl') {
+ self.water.width = heightValue;
+ self.water.x = self.maxWaterSize;
+ self.water.scaleX = -1;
+ } else {
self.water.height = heightValue;
}
- if (self.water.dir == 'lr') {
- self.water.width = heightValue;
- }
} else {
self.flow = false;
}
}
@@ -605,9 +702,9 @@
tiles: [[null, 'straightPipeH', 'end', null], [null, 'cornerPipe', 'straightPipeH', null], [null, null, null, null], ['start', 'straightPipeV', null, null]],
rotations: {
'0,2': 'right',
// end
- '1,1': 'right' // corner
+ '1,1': 'left' // corner
},
fixedTiles: ['3,0', '3,1', '0,2'] // Start, end, and one pipe fixed
},
3: {
@@ -807,13 +904,13 @@
if (startTile.valve) {
startTile.valve.rotationSpeed = 0.1;
}
// Start flowing through pipes
- self.flowThroughPipe(startX, startY + 1, [startX + ',' + startY]);
+ self.flowThroughPipe(startX, startY + 1, [startX + ',' + startY], 'down');
}
};
- self.flowThroughPipe = function (x, y, visited) {
- log("Entering flowThroughPipe with position:", x, y, "Visited:", visited);
+ self.flowThroughPipe = function (x, y, visited, fromDir) {
+ log("Entering flowThroughPipe at position:", x, y, "Visited:", visited, "From:", fromDir);
if (x < 0 || x >= self.gridSize || y < 0 || y >= self.gridSize) {
return;
}
var key = x + ',' + y;
@@ -821,33 +918,62 @@
return;
}
visited.push(key);
var tile = self.grid[x][y];
- log("Tile found at position:", x, y, "Type:", tile ? tile.type : "none");
+ log("Will pass :", tile ? tile.type : "none", " from ", fromDir);
if (!tile || tile.type === 'empty') {
return;
}
// Start flow animation for this tile
tile.flow = true;
if (tile.water) {
tile.water.visible = true;
+ // Set water direction based on pipe type and incoming direction
+ if (tile.type === 'straightPipeH') {
+ if (fromDir === 'right') {
+ tile.water.dir = 'rl'; // right to left
+ } else {
+ tile.water.dir = 'lr'; // left to right
+ }
+ }
}
if (tile.waterV) {
tile.waterV.visible = true;
}
if (tile.waterH) {
tile.waterH.visible = true;
+ if (fromDir === 'right') {
+ tile.waterH.scaleX = -1; // Flow right to left
+ } else {
+ tile.waterH.scaleX = 1; // Flow left to right
+ }
}
if (tile.type === 'end') {
createWaterDrops(tile.x, tile.y + 100, game);
return;
}
- var normalizedRotation = tile.normalizeRotation(tile.rotation);
+ var normalizedRotation = tile.normalizeRotation(tile.pipeContainer.rotation);
var nextPositions = tile.getNextPositions(x, y, tile.type, normalizedRotation);
// Wait for flow animation to complete before moving to next tiles
LK.setTimeout(function () {
for (var i = 0; i < nextPositions.length; i++) {
- self.flowThroughPipe(nextPositions[i][0], nextPositions[i][1], visited);
+ var nextX = nextPositions[i][0];
+ var nextY = nextPositions[i][1];
+ // Determine flow direction for next tile
+ var nextDir;
+ if (nextX > x) {
+ nextDir = 'left';
+ } // Coming from left
+ else if (nextX < x) {
+ nextDir = 'right';
+ } // Coming from right
+ else if (nextY > y) {
+ nextDir = 'up';
+ } // Coming from up
+ else {
+ nextDir = 'down';
+ } // Coming from down
+ self.flowThroughPipe(nextX, nextY, visited, nextDir);
}
}, 300);
};
self.reset = function () {
@@ -926,9 +1052,9 @@
if (tile.type === 'end') {
log("Found end tile!");
return true;
}
- var normalizedRotation = tile.normalizeRotation(tile.rotation);
+ var normalizedRotation = tile.normalizeRotation(tile.pipeContainer.rotation);
log("Checking tile:", tile.type, "with normalized rotation:", normalizedRotation, "at position:", x, y);
var nextPositions = tile.getNextPositions(x, y, tile.type, normalizedRotation);
log("Next positions to check:", nextPositions);
for (var i = 0; i < nextPositions.length; i++) {
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