Code edit (2 edits merged)
Please save this source code
User prompt
let the fontain rotate indefinetly
Code edit (5 edits merged)
Please save this source code
User prompt
and make the fontain rotate
User prompt
For the end tile, for the water animation use the fountain asset and make grow w & h
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
For start pipe, in update, instead of a water w/h anim, make the valve rotate
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'type')' in or related to this line: 'log('Flowing through pipe at:', key, 'Tile type:', tile.type);' Line Number: 510
User prompt
add log in flowThroughPipe
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: _slicedToArray is not defined' in or related to this line: 'var _pos$split$map = pos.split(',').map(Number),' Line Number: 283
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: setInterval is not a function' in or related to this line: 'var checkFlowInterval = setInterval(function () {' Line Number: 628
User prompt
in animateWaterFlow, set flow to true in start tile and wait until flow returns to false; then do same for the next tile until the end pipe tile.
User prompt
When puzzle is solved we will run an animation to simulate water flowing from start pipe to end pipe. Add a new function for flow animation; call it when puzzle is solved;
User prompt
prevent moves when !isPlaying
User prompt
add an isPlaying global defaulting to true; set it to false when level is solved
User prompt
Please fix the bug: 'Uncaught TypeError: Set is not a constructor' in or related to this line: 'var visited = new Set();' Line Number: 438
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'currentLevel')' in or related to this line: 'levelText = new Text2('Level: ' + puzzleManager.currentLevel, {' Line Number: 726
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'setText')' in or related to this line: 'levelText.setText('Level: ' + self.currentLevel + ' Solved!');' Line Number: 592
User prompt
Please fix the bug: 'Uncaught ReferenceError: levelText is not defined' in or related to this line: 'levelText.setText('Level: ' + self.currentLevel + ' Solved!');' Line Number: 592
===================================================================
--- original.js
+++ change.js
@@ -8,8 +8,9 @@
self.baseTint = 0x8FBE00;
self.baseTintLight = 0x5ED000;
self.maxWaterSize = 250;
self.flowSpeed = 4;
+ self.startFlowTicks = 0;
self.flow = false;
self.connections = [];
self.position = {
x: 0,
@@ -211,13 +212,17 @@
log('Tile position:', self.x, self.y, 'Tile rotation:', self.rotation);
};
self.update = function () {
if (self.water && self.flow) {
+ //log("Should Flow...", self.water.height, self.water.width, self.water.visible);
if (!self.water.height || !self.water.width) {
self.water.visible = true;
+ self.startFlowTicks = LK.ticks;
}
- var heightValue = LK.ticks * self.flowSpeed;
+ var heightValue = (LK.ticks - self.startFlowTicks) * self.flowSpeed;
+ log("Should Flow2...", self.water.dir, heightValue, self.maxWaterSize);
if (self.water.dir != '' && heightValue < self.maxWaterSize) {
+ log("Flowing..." + self.water.dir);
if (self.water.dir == 'tb') {
self.water.height = heightValue;
}
if (self.water.dir == 'lr') {
@@ -507,26 +512,26 @@
// Set water direction based on tile type
switch (tile.type) {
case 'start':
case 'straightPipeV':
- tile.water.dir = 'tb';
+ //tile.water.dir = 'tb';
break;
case 'straightPipeH':
- tile.water.dir = 'lr';
+ //tile.water.dir = 'lr';
break;
case 'cornerPipe':
// Set direction based on rotation
if (tile.rotation === Math.PI * 0.5) {
- tile.water.dir = 'tr'; // top to right
+ //tile.water.dir = 'tr'; // top to right
}
// Add other rotation cases here
break;
case 'crossPipe':
// Set direction based on where water came from
if (self.grid[x][y - 1] && self.grid[x][y - 1].flow) {
- tile.water.dir = 'tb';
+ //tile.water.dir = 'tb';
} else if (self.grid[x - 1][y] && self.grid[x - 1][y].flow) {
- tile.water.dir = 'lr';
+ //tile.water.dir = 'lr';
}
break;
}
log('Set water direction for tile at', x, y, 'to:', tile.water.dir);
@@ -545,48 +550,97 @@
}
}, 500); // Wait 500ms before flowing to next tile
};
self.getNextPosition = function (x, y, tile) {
+ log('Getting next position for tile:', tile.type, 'at', x, y);
switch (tile.type) {
case 'start':
+ log('Start tile - flowing down');
return [x, y + 1];
// Flow down from start
case 'straightPipeV':
- // Check if water came from top or bottom
- var nextY = self.grid[x][y - 1] && self.grid[x][y - 1].flow ? y + 1 : y - 1;
- return [x, nextY];
+ // Always flow downward if we came from above
+ if (y > 0 && self.grid[x][y - 1] && self.grid[x][y - 1].flow) {
+ log('Vertical pipe - flowing down');
+ return [x, y + 1];
+ }
+ // Flow upward if we came from below
+ if (y < self.gridSize - 1 && self.grid[x][y + 1] && self.grid[x][y + 1].flow) {
+ log('Vertical pipe - flowing up');
+ return [x, y - 1];
+ }
+ // If no previous flow, default to flowing down
+ log('Vertical pipe - default flow down');
+ return [x, y + 1];
case 'straightPipeH':
- // Check if water came from left or right
- var nextX = self.grid[x - 1][y] && self.grid[x - 1][y].flow ? x + 1 : x - 1;
- return [x, nextX];
+ // Always flow right if we came from left
+ if (x > 0 && self.grid[x - 1][y] && self.grid[x - 1][y].flow) {
+ log('Horizontal pipe - flowing right');
+ return [x + 1, y];
+ }
+ // Flow left if we came from right
+ if (x < self.gridSize - 1 && self.grid[x + 1][y] && self.grid[x + 1][y].flow) {
+ log('Horizontal pipe - flowing left');
+ return [x - 1, y];
+ }
+ // If no previous flow, default to flowing right
+ log('Horizontal pipe - default flow right');
+ return [x + 1, y];
case 'cornerPipe':
- if (tile.rotation === Math.PI * 0.5) {
- // Left rotation
- // If water came from top, go right; if from right, go up
- if (self.grid[x][y - 1] && self.grid[x][y - 1].flow) {
+ // For corner pipe at π/2 (90 degrees), when water comes from above, flow right
+ if (Math.abs(tile.rotation - Math.PI * 0.5) < 0.01) {
+ // Use approximate equality for floating point
+ if (y > 0 && self.grid[x][y - 1] && self.grid[x][y - 1].flow) {
+ log('Corner pipe π/2 - water from above, flowing right');
return [x + 1, y];
- } else if (self.grid[x + 1][y] && self.grid[x + 1][y].flow) {
+ }
+ // Default to flowing right if no previous flow (shouldn't happen in normal gameplay)
+ log('Corner pipe π/2 - default flowing right');
+ return [x + 1, y];
+ } else if (Math.abs(tile.rotation - Math.PI) < 0.01) {
+ // π (180 degrees)
+ if (y > 0 && self.grid[x][y - 1] && self.grid[x][y - 1].flow) {
+ log('Corner pipe π - water from above, flowing left');
+ return [x - 1, y];
+ }
+ } else if (Math.abs(tile.rotation - Math.PI * 1.5) < 0.01) {
+ // 3Ï€/2 (270 degrees)
+ if (y < self.gridSize - 1 && self.grid[x][y + 1] && self.grid[x][y + 1].flow) {
+ log('Corner pipe 3Ï€/2 - water from below, flowing left');
+ return [x - 1, y];
+ }
+ } else {
+ // 0 or default rotation
+ if (x > 0 && self.grid[x - 1][y] && self.grid[x - 1][y].flow) {
+ log('Corner pipe 0 - water from left, flowing up');
return [x, y - 1];
}
}
- // Add other rotations as needed
break;
case 'crossPipe':
- // Determine direction based on where water came from
- if (self.grid[x][y - 1] && self.grid[x][y - 1].flow) {
+ // For cross pipe, continue in the same direction we came from
+ if (y > 0 && self.grid[x][y - 1] && self.grid[x][y - 1].flow) {
+ log('Cross pipe - flowing down');
return [x, y + 1];
}
- if (self.grid[x][y + 1] && self.grid[x][y + 1].flow) {
+ if (y < self.gridSize - 1 && self.grid[x][y + 1] && self.grid[x][y + 1].flow) {
+ log('Cross pipe - flowing up');
return [x, y - 1];
}
- if (self.grid[x - 1][y] && self.grid[x - 1][y].flow) {
+ if (x > 0 && self.grid[x - 1][y] && self.grid[x - 1][y].flow) {
+ log('Cross pipe - flowing right');
return [x + 1, y];
}
- if (self.grid[x + 1][y] && self.grid[x + 1][y].flow) {
+ if (x < self.gridSize - 1 && self.grid[x + 1][y] && self.grid[x + 1][y].flow) {
+ log('Cross pipe - flowing left');
return [x - 1, y];
}
break;
+ case 'end':
+ log('Reached end tile');
+ return null;
}
+ log('No valid next position found');
return null;
};
return self;
};
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