User prompt
change log("Already visited."); to log("Already visited...");
Code edit (8 edits merged)
Please save this source code
User prompt
fix self.flowThroughPipe(startX, startY, [], 'down'); to use strat tile direction instead of hard coded 'down'
Code edit (12 edits merged)
Please save this source code
User prompt
in getNextPositions, add an entry for start tile and take into account its normalizedRotation
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
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: 34
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: 34
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: 34
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: 34
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: 34
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: 34
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: 34
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: 34
Code edit (1 edits merged)
Please save this source code
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
===================================================================
--- original.js
+++ change.js
@@ -7,8 +7,10 @@
* Classes
****/
var Tile = Container.expand(function () {
var self = Container.call(this);
+ self.pipeContainer = new Container();
+ self.addChild(self.pipeContainer);
// Properties
self.type = 'empty';
self.baseTint = 0x8FBE00;
self.baseTintLight = 0x5ED000;
@@ -291,36 +293,36 @@
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 = right
- // π/2 = down
- // π = left
- // 3π/2 = up
+ // 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 'right';
+ return 'up';
}
if (angle < 3 * Math.PI / 4) {
- return 'down';
+ return 'right';
}
if (angle < 5 * Math.PI / 4) {
- return 'left';
+ return 'down';
}
- return 'up';
+ return 'left';
}
return rotation || 'down';
};
self.setRotation = function (direction) {
switch (direction) {
case 'left':
- self.rotation = Math.PI * 0.5;
+ self.rotation = -Math.PI * 1.5;
break;
case 'right':
- self.rotation = -Math.PI * 0.5;
+ self.rotation = Math.PI * 0.5;
break;
case 'up':
self.rotation = 0;
break;
@@ -329,8 +331,36 @@
break;
}
log('Tile position:', self.x, self.y, 'Tile rotation:', self.rotation);
};
+ self.getNextPositions = function (x, y, type, normalizedRotation) {
+ var nextPositions = [];
+ switch (type) {
+ case 'straightPipeV':
+ nextPositions.push([x, y - 1], [x, y + 1]); // Up and down
+ break;
+ case 'straightPipeH':
+ nextPositions.push([x - 1, y], [x + 1, y]); // Left and right
+ break;
+ case 'cornerPipe':
+ switch (normalizedRotation) {
+ case 'up':
+ nextPositions.push([x, y - 1], [x + 1, y]); // Up and right
+ break;
+ case 'right':
+ nextPositions.push([x + 1, y], [x, y + 1]); // Right and down
+ break;
+ case 'down':
+ nextPositions.push([x - 1, y], [x, y + 1]); // Left and down
+ break;
+ case 'left':
+ nextPositions.push([x - 1, y], [x, y - 1]); // Left and up
+ break;
+ }
+ break;
+ }
+ return nextPositions;
+ };
self.update = function () {
if (self.flow) {
if (!self.startFlowTicks) {
self.startFlowTicks = LK.ticks;
@@ -576,47 +606,44 @@
},
fixedTiles: ['0,0', '0,1', '0,2', '0,3', '1,3', '3,3'] // All tiles fixed except 2,2
},
2: {
- tiles: [['start', 'straightPipeV', null, 'end'], ['cornerPipe', 'cornerPipe', 'straightPipeH', null], [null, 'straightPipeV', null, null], [null, 'cornerPipe', 'straightPipeH', null]],
+ tiles: [[null, 'straightPipeH', 'end', null], [null, 'cornerPipe', 'straightPipeH', null], [null, null, null, null], ['start', 'straightPipeV', null, null]],
rotations: {
- '0,1': 'down',
- '1,0': 'right',
- '1,1': 'left',
- '3,1': 'up'
+ '0,2': 'right',
+ // end
+ '1,1': 'down' // corner
},
- fixedTiles: ['0,0', '0,3'] // Only start and end are fixed
+ fixedTiles: ['3,0', '3,1', '0,2'] // Start, end, and one pipe fixed
},
3: {
- tiles: [['start', null, 'cornerPipe', 'end'], ['straightPipeV', 'straightPipeH', 'cornerPipe', null], [null, 'cornerPipe', 'straightPipeV', 'straightPipeH'], ['cornerPipe', 'straightPipeH', null, null]],
+ tiles: [['start', 'straightPipeV', null, null], [null, 'cornerPipe', 'straightPipeH', 'cornerPipe'], [null, null, null, 'straightPipeV'], [null, null, null, 'end']],
rotations: {
- '0,2': 'left',
- '1,2': 'down',
- '2,1': 'up',
- '3,0': 'right'
+ '1,1': 'left',
+ '1,3': 'down',
+ '2,3': 'up'
},
- fixedTiles: ['0,0', '0,3'] // Only start and end are fixed
+ fixedTiles: ['0,0', '3,3', '0,1'] // Start, end, and one pipe fixed
},
4: {
- tiles: [['start', 'straightPipeV', 'cornerPipe', null], [null, null, 'straightPipeH', 'cornerPipe'], ['straightPipeH', 'cornerPipe', 'straightPipeV', 'end'], [null, 'straightPipeV', 'cornerPipe', null]],
+ tiles: [['start', null, 'cornerPipe', null], ['straightPipeV', 'straightPipeH', 'cornerPipe', null], [null, null, 'straightPipeV', null], [null, null, 'cornerPipe', 'end']],
rotations: {
'0,2': 'left',
- '1,3': 'down',
- '2,1': 'up',
- '2,2': 'right'
+ '1,2': 'down',
+ '2,2': 'up',
+ '3,2': 'right'
},
- fixedTiles: ['0,0', '2,3'] // Only start and end are fixed
+ fixedTiles: ['0,0', '3,3'] // Only start and end are fixed
},
5: {
- tiles: [['start', null, 'cornerPipe', 'straightPipeH'], ['straightPipeV', 'cornerPipe', 'straightPipeV', 'end'], ['cornerPipe', 'straightPipeH', 'cornerPipe', null], [null, null, 'straightPipeV', 'cornerPipe']],
+ tiles: [['start', 'straightPipeV', null, null], ['cornerPipe', 'cornerPipe', 'straightPipeH', 'cornerPipe'], [null, 'straightPipeV', null, 'straightPipeV'], ['cornerPipe', 'cornerPipe', null, 'end']],
rotations: {
- '0,2': 'down',
- '1,1': 'right',
- '2,0': 'up',
- '2,2': 'left',
- '3,3': 'up'
+ '1,0': 'right',
+ '1,1': 'left',
+ '1,3': 'down',
+ '3,0': 'up'
},
- fixedTiles: ['0,0', '1,3'] // Only start and end are fixed
+ fixedTiles: ['0,0', '3,3'] // Only start and end are fixed
}
// Add more levels here
};
self.initPuzzle = function () {
@@ -814,55 +841,20 @@
}
if (tile.waterH) {
tile.waterH.visible = true;
}
- // Get next positions to flow to
- var nextPositions = [];
- switch (tile.type) {
- case 'straightPipeV':
- nextPositions.push([x, y - 1], [x, y + 1]); // Up and down
- break;
- case 'straightPipeH':
- nextPositions.push([x - 1, y], [x + 1, y]); // Left and right
- break;
- case 'cornerPipe':
- var normalizedRotation = tile.normalizeRotation(tile.rotation);
- log("Corner pipe with normalized rotation:", normalizedRotation);
- switch (normalizedRotation) {
- case 'up':
- // ┗
- log("Corner pipe up - checking up and right");
- nextPositions.push([x, y - 1], [x + 1, y]); // Up and right
- break;
- case 'right':
- // ┏
- log("Corner pipe right - checking right and down");
- nextPositions.push([x + 1, y], [x, y + 1]); // Right and down
- break;
- case 'down':
- // ┓
- log("Corner pipe down - checking up and right");
- nextPositions.push([x, y - 1], [x + 1, y]); // Up and right as per working version
- break;
- case 'left':
- // ┛
- log("Corner pipe left - checking left and up");
- nextPositions.push([x - 1, y], [x, y - 1]); // Left and up
- break;
- }
- break;
- case 'end':
- // Create water drops effect
- createWaterDrops(tile.x, tile.y + 100, game);
- break;
+ if (tile.type === 'end') {
+ createWaterDrops(tile.x, tile.y + 100, game);
+ return;
}
- log("Next positions to flow to from", x, y, ":", nextPositions);
+ var normalizedRotation = tile.normalizeRotation(tile.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);
}
- }, 300); // Wait 300ms before flowing to next tile
+ }, 300);
};
self.reset = function () {
self.selectedTile = null;
if (self.isComplete) {
@@ -919,15 +911,13 @@
log("=== Win Condition Check Complete ===");
return result;
};
self.canReachEnd = function (x, y, visited) {
- // Check bounds
log("Checking position:", x, y);
if (x < 0 || x >= self.gridSize || y < 0 || y >= self.gridSize) {
log("Position out of bounds");
return false;
}
- // Create position key
var key = x + ',' + y;
if (visited.includes(key)) {
log("Position already visited:", key);
return false;
@@ -937,70 +927,23 @@
if (!tile || tile.type === 'empty') {
log("No tile or empty tile at position:", x, y);
return false;
}
- // Get normalized rotation from tile
- var normalizedRotation = tile.normalizeRotation(tile.rotation);
- log("Checking tile:", tile.type, "with normalized rotation:", normalizedRotation, "at position:", x, y);
- // If we reached the end, success!
if (tile.type === 'end') {
log("Found end tile!");
return true;
}
- // Get next possible positions based on current tile type and rotation
- var nextPositions = [];
- switch (tile.type) {
- case 'straightPipeV':
- log("Straight vertical pipe - checking up and down");
- nextPositions.push([x, y - 1], [x, y + 1]); // Up and down
- break;
- case 'straightPipeH':
- log("Straight horizontal pipe - checking left and right");
- nextPositions.push([x - 1, y], [x + 1, y]); // Left and right
- break;
- case 'cornerPipe':
- log("Corner pipe with normalized rotation:", normalizedRotation);
- switch (normalizedRotation) {
- case 'up':
- // ┗
- log("Corner pipe up - checking up and right");
- nextPositions.push([x, y - 1], [x + 1, y]); // Up and right
- break;
- case 'right':
- // ┏
- log("Corner pipe right - checking right and down");
- nextPositions.push([x + 1, y], [x, y + 1]); // Right and down
- break;
- case 'down':
- // ┓
- log("Corner pipe down - checking up and right");
- nextPositions.push([x, y - 1], [x + 1, y]); // Up and right as per working version
- break;
- case 'left':
- // ┛
- log("Corner pipe left - checking left and up");
- nextPositions.push([x - 1, y], [x, y - 1]); // Left and up
- break;
- }
- break;
- case 'start':
- // Start tile connects downward
- log("Start tile - checking down connection");
- nextPositions.push([x, y + 1]);
- break;
- }
- log("Checking next positions:", nextPositions);
- // Try each possible next position
+ var normalizedRotation = tile.normalizeRotation(tile.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++) {
- var nextX = nextPositions[i][0];
- var nextY = nextPositions[i][1];
- log("Trying next position:", nextX, nextY);
- if (self.canReachEnd(nextX, nextY, visited)) {
- log("Found valid path through:", nextX, nextY);
+ var nextPos = nextPositions[i];
+ log("Trying next position:", nextPos);
+ if (self.canReachEnd(nextPos[0], nextPos[1], visited)) {
return true;
}
}
- log("No valid path found from:", x, y);
return false;
};
return this;
};
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