Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
add a random rotation to flowers when spawning
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: finalScaleX is not defined' in or related to this line: 'if (flowerGraphics.scaleX < finalScaleX) {' Line Number: 62
User prompt
also when spawning Flower, make them grow in size from 0 to their final size
User prompt
when spawning Flower, make them fade in with an alpha anim from 0 to 1, (don't use tween for that)
Code edit (7 edits merged)
Please save this source code
User prompt
when spawning Flower, make them fade in with an alpha anim from 0 to 1
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in self.updateCornerPipeThirdPhase add logs for self.waterH x, y and dir
User prompt
add plenty of logs in updateCornerPipeFirstPhase and updateCornerPipeThirdPhase
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading '0')' in or related to this line: 'var tileStr = level[row][col];' Line Number: 1149
Code edit (1 edits merged)
Please save this source code
User prompt
in flower class, make size random from 100% to 100% + sizeRatioRange %
Code edit (1 edits merged)
Please save this source code
User prompt
in flower class make position random around x,y within positionOffset range
User prompt
in Flower class, make assetId random from 1 to maxIndex (keep prefix 'flower')
===================================================================
--- original.js
+++ change.js
@@ -629,12 +629,9 @@
}
};
self.getNextPositions = function (col, row, rotation, type, incomingDirection) {
var positions = [];
- //var normalizedIncoming = (incomingDirection + Math.PI) % (2 * Math.PI);
- //var normalizedIncoming = getFlowDirection(puzzleManager.grid[row][col], incomingDirection);
log("Getting next position for tile at", row, col, "type:", type, "rotation:", rotation, "incoming direction:", incomingDirection); //, "normalizedIncoming::", normalizedIncoming);
- //incomingDirection = normalizedIncoming;
switch (type) {
case TileFormat.TYPES.START:
// Start pipe flows in direction of rotation
var dx = -Math.sin(rotation);
@@ -689,22 +686,8 @@
if (Math.abs(incomingDirection - acceptAngle2) < 0.1) {
outgoingDirection = acceptAngle1 + Math.PI;
}
log("CORNER: turning from", incomingDirection, "to", outgoingDirection);
- //log("if so, turn 90° or -90° depending on incoming and rotation...");
- // For corner pipes, we turn 90° based on the incoming direction
- // If incoming matches pipe entry point, turn 90° clockwise
- /*
- if (Math.abs(incomingDirection - normalizedRotation) < 0.1) {
- outgoingDirection = (incomingDirection + Math.PI / 2) % (2 * Math.PI);
- log("CORNER: turning clockwise from", incomingDirection, "to", outgoingDirection);
- }
- // If incoming is 90° from pipe entry, turn 90° counterclockwise
- else if (Math.abs(incomingDirection - (normalizedRotation + Math.PI / 2) % (2 * Math.PI)) < 0.1) {
- outgoingDirection = (incomingDirection - Math.PI / 2 + 2 * Math.PI) % (2 * Math.PI);
- log("CORNER: turning counterclockwise from", incomingDirection, "to", outgoingDirection);
- }
- */
if (outgoingDirection !== undefined) {
// Convert angle to grid movement
var dx = Math.round(Math.cos(outgoingDirection));
var dy = -Math.round(Math.sin(outgoingDirection));
@@ -752,15 +735,13 @@
};
self.updatePosition = function (row, col) {
self.gridRow = row;
self.gridCol = col;
- //self.x = col * tileSize + gridBoard.x - gridBoard.width / 2;
- //self.y = row * tileSize + gridBoard.y - gridBoard.height / 2;
self.x = col * tileSize + gridBoard.x - gridBoard.width / 2 + tileSize / 2 + boardOffsetX;
self.y = row * tileSize + gridBoard.y - gridBoard.height / 2 + tileSize / 2 + boardOffsetY;
log('Tile row,col:', row, col, 'Tile position:', self.x, self.y, 'Tile dimensions:', self.width, self.height, ' self:', self);
//log('pipeContainer:', self.pipeContainer.x, self.pipeContainer.y, ' child:', self.pipeContainer.children[0].x, self.pipeContainer.children[0].y);
- // log('gridBoard :', gridBoard.x, gridBoard.y, ' size:', gridBoard.width, gridBoard.height);
+ //log('gridBoard :', gridBoard.x, gridBoard.y, ' size:', gridBoard.width, gridBoard.height);
};
// Water flow update methods
self.updateStartTile = function () {
if (self.valve) {
@@ -823,23 +804,23 @@
}
}
};
self.getFlowOrder = function (rot, dir) {
+ // Specific function take rotation (x4) + dir(x4) => order (rot + dir + => final order)
log("getFlowOrder rot=", rot, " / dir=", dir);
var normalOrder = true;
switch (rot) {
case 0:
- normalOrder = true;
+ normalOrder = dir == 'tb' ? false : true;
break;
case 1:
- log("Case 1");
normalOrder = dir == 'rl' ? false : true;
break;
case 2:
- normalOrder = false;
+ normalOrder = dir == 'rl' ? true : false;
break;
case 3:
- normalOrder = false;
+ normalOrder = dir == 'bt' ? true : false;
break;
default:
log("ERROR in getFlowOrder : Unknown rotation ", rot);
}
@@ -847,120 +828,152 @@
};
self.updateCornerPipe = function () {
var progress = (LK.ticks - self.startFlowTicks) * self.flowSpeed;
var thirdSize = self.maxWaterCornerSize / 3;
- var upRot = Math.abs(self.pipeContainer.rotation) % (2 * Math.PI) < 0.1 || Math.abs(self.pipeContainer.rotation - Math.PI / 2) % (2 * Math.PI) < 0.1;
- var normalOrder = self.getFlowOrder(self.pipeContainer.rot, self.pipeContainer.dir); //upRot || self.pipeContainer.dir == 'bt' || self.pipeContainer.dir == 'rl';
+ var normalOrder = self.getFlowOrder(self.pipeContainer.rot, self.pipeContainer.dir);
log("updateCornerPipe: Choosing order for tile:", self.pipeContainer.rotation, self.pipeContainer.dir);
- log("upRot=", upRot, " (0 or PI/2) / dir=", self.pipeContainer.dir, " normalOrder = ", normalOrder);
- // TODO : Specific function take rotation (x4) + dir(x4) => order (Log x,y + tor + dir + => final)
- // TODO : Specific function take rotation (x4) + dir(x4) => order (Log x,y + tor + dir + => final)
- // TODO : Specific function take rotation (x4) + dir(x4) => order (Log x,y + tor + dir + => final)
- // TODO : Specific function take rotation (x4) + dir(x4) => order (Log x,y + tor + dir + => final)
if (progress < thirdSize) {
// 0 or PI/2
if (normalOrder) {
- self.updateCornerPipeFirstPhase(progress, thirdSize, false);
+ self.updateCornerPipeVerticalPart(progress, thirdSize, false);
} else {
- self.updateCornerPipeThirdPhase(progress, thirdSize, true);
+ self.updateCornerPipeHorizontalPart(progress, thirdSize, true);
}
- } else if (progress < thirdSize * 2) {
- //self.updateCornerPipeSecondPhase(progress, thirdSize);
- } else {
+ } else if (progress > thirdSize * 2 && progress < thirdSize * 3) {
// 0 or PI/2
if (normalOrder) {
- self.updateCornerPipeThirdPhase(progress, thirdSize, false);
+ self.updateCornerPipeHorizontalPart(progress, thirdSize, false);
} else {
- self.updateCornerPipeFirstPhase(progress, thirdSize, true);
+ self.updateCornerPipeVerticalPart(progress, thirdSize, true);
}
}
if (progress >= self.maxWaterCornerSize) {
self.flow = false;
}
};
- // TODO : RENAME updateCornerPipeVerticalPart
- self.updateCornerPipeFirstPhase = function (progress, thirdSize, reverted) {
- // TODO : Specific function take rotation (x4) + dir(x4) => revertedV (Log x,y + rot + dir + => final)
- // TODO : Specific function take rotation (x4) + dir(x4) => reverted (Log x,y + rot + dir + => final)
- // TODO : Specific function take rotation (x4) + dir(x4) => reverted (Log x,y + rot + dir + => final)
- // TODO : Specific function take rotation (x4) + dir(x4) => reverted (Log x,y + rot + dir + => final)
- if (self.waterV) {
- log("updateCornerPipeFirstPhase: Making waterV visible. Current progress:", progress, "Third size:", thirdSize);
- self.waterV.visible = true;
- self.waterV.height = reverted ? progress - thirdSize * 2 : progress;
- log("updateCornerPipeFirstPhase: Updated waterV height to:", self.waterV.height);
- // PI
- if (Math.abs(self.pipeContainer.rotation - Math.PI) % (2 * Math.PI) < 0.1) {
- log("updateCornerPipeFirstPhase: Case PI");
- self.waterV.y = -7;
- self.waterV.x = -120;
- //self.waterV.rotation = (self.pipeContainer.rotation - Math.PI / 2) % (2 * Math.PI);
- //self.waterH.rotation = reverted ? Math.PI / 2 : -Math.PI / 2;
- self.waterH.rotation = (self.pipeContainer.dir == 'rl' ? self.pipeContainer.rotation - Math.PI / 2 : self.pipeContainer.rotation + Math.PI / 2) % (2 * Math.PI);
- self.waterV.tint = 0xFF0000;
- }
+ self.getCornerVerticalAnimWay = function (rot, dir) {
+ // Specific function take rotation (x4) + dir(x4) => way (true = exterior => interior / false = interior exterior)
+ log("get Corner Vert Anim rot=", rot, " / dir=", dir);
+ var normalWay = true;
+ switch (rot) {
+ case 0:
+ normalWay = dir == 'tb' ? false : true;
+ break;
+ case 1:
+ normalWay = dir == 'rl' ? false : true;
+ break;
+ case 2:
+ normalWay = dir == 'bt' ? false : true;
+ break;
+ case 3:
+ normalWay = dir == 'lr' ? false : true;
+ break;
+ default:
+ log("ERROR in getCornerVerticalAnimWay : Unknown rotation ", rot);
}
+ return normalWay;
};
- // TODO : RENAME updateCornerPipeCentral
- self.updateCornerPipeSecondPhase = function (progress, thirdSize) {
- if (self.waterCorner) {
- self.waterCorner.visible = true;
- self.waterCorner.alpha = (progress - thirdSize) / thirdSize;
- var rotationProgress = (progress - thirdSize) / thirdSize;
- self.waterCorner.rotation = -Math.PI / 2 - rotationProgress * Math.PI / 2;
+ self.updateCornerPipeVerticalPart = function (progress, thirdSize, reverted) {
+ // Specific function take rotation (x4) + dir(x4) => revertedV (Log x,y + rot + dir + => final)
+ if (!self.waterV) {
+ return;
}
- if (self.waterCornerCover) {
- self.waterCornerCover.visible = true;
- self.waterCornerCover.alpha = (progress - thirdSize) / thirdSize;
+ var currentProgress = reverted ? progress - thirdSize * 2 : progress;
+ var normalWay = self.getCornerVerticalAnimWay(self.pipeContainer.rot, self.pipeContainer.dir);
+ log("updateCornerPipeVerticalPart: normal way:", normalWay);
+ log("updateCornerPipeVerticalPart: Updated waterV height to:", currentProgress);
+ if (normalWay) {
+ //self.waterV.tint = 0x0000FF;
+ } else {
+ //self.waterV.tint = 0x00FF00;
+ self.waterV.y = -7;
+ self.waterV.x = -80;
+ self.waterV.rotation = Math.PI / 2;
}
+ self.waterV.visible = true;
+ self.waterV.height = currentProgress;
};
- // TODO : RENAME updateCornerPipeHorizontalPart
- self.updateCornerPipeThirdPhase = function (progress, thirdSize, reverted) {
- if (self.waterH) {
- log("updateCornerPipeThirdPhase: Making waterH visible. Current progress:", progress, "Third size:", thirdSize, " Tile Rot=", self.pipeContainer.rotation);
- self.waterH.visible = true;
- self.waterH.width = reverted ? progress : progress - thirdSize * 2;
- log("updateCornerPipeThirdPhase: Updated waterH width to:", self.waterH.width);
- log("updateCornerPipeThirdPhase: waterH position x:", self.waterH.x, "y:", self.waterH.y, "dir:", self.waterH.dir);
- // 0
- if (Math.abs(self.pipeContainer.rotation) % (2 * Math.PI) < 0.1) {
- log("updateCornerPipeThirdPhase: Case 0");
+ self.getCornerHorizontalAnimWay = function (rot, dir) {
+ // Specific function take rotation (x4) + dir(x4) => way (true = exterior => interior / false = interior exterior)
+ log("get Corner Horiz Anim rot=", rot, " / dir=", dir);
+ var normalWay = true;
+ switch (rot) {
+ case 0:
+ normalWay = dir == 'tb' ? false : true;
+ break;
+ case 1:
+ normalWay = dir == 'rl' ? false : true;
+ break;
+ case 2:
+ normalWay = dir == 'bt' ? true : false;
+ break;
+ case 3:
+ normalWay = dir == 'lr' ? false : true;
+ break;
+ default:
+ log("ERROR in getCornerHorizontalAnimWay : Unknown rotation ", rot);
+ }
+ return normalWay;
+ };
+ self.updateCornerPipeHorizontalPart = function (progress, thirdSize, reverted) {
+ if (!self.waterH) {
+ return;
+ }
+ var currentProgress = reverted ? progress - thirdSize * 2 : progress;
+ var normalWay = self.getCornerHorizontalAnimWay(self.pipeContainer.rot, self.pipeContainer.dir);
+ log("Upd Corner H: normal way:", normalWay);
+ log("Upd Corner H: Updated waterH width to:", currentProgress);
+ if (normalWay) {
+ self.waterH.tint = 0xF050A0;
+ } else {
+ self.waterH.tint = 0xFF0000;
+ //self.waterH.y = -7;
+ //self.waterH.x = -80;
+ //self.waterH.rotation = Math.PI / 2;
+ }
+ log("Upd Corner H: waterH position x:", self.waterH.x, "y:", self.waterH.y, "dir:", self.waterH.dir);
+ self.waterH.visible = true;
+ self.waterH.width = currentProgress;
+ /*
+ // 0
+ if (Math.abs(self.pipeContainer.rotation) % (2 * Math.PI) < 0.1) {
+ log("Upd Corner H: Case 0");
self.waterH.rotation = (self.pipeContainer.rotation - Math.PI / 2) % (2 * Math.PI);
self.waterH.tint = 0xF050A0;
- }
- // PI/2
- if (Math.abs(self.pipeContainer.rotation - Math.PI / 2) % (2 * Math.PI) < 0.1) {
- log("updateCornerPipeThirdPhase: Case PI/2");
+ }
+ // PI/2
+ if (Math.abs(self.pipeContainer.rotation - Math.PI / 2) % (2 * Math.PI) < 0.1) {
+ log("Upd Corner H: Case PI/2");
// 3*PI/2 => Vers le haut
// P/2 => => Vers le bas
// PI => Vers la gauche
// 0 => OK
self.waterH.rotation = (self.pipeContainer.dir == 'rl' ? self.pipeContainer.rotation + Math.PI : self.pipeContainer.rotation) % (2 * Math.PI);
- self.waterH.tint = 0x0000FF;
- }
- // PI
- if (Math.abs(self.pipeContainer.rotation - Math.PI) % (2 * Math.PI) < 0.1) {
- log("updateCornerPipeThirdPhase: Case PI; reverted=", reverted, " / self.pipeContainer.rotation=", self.pipeContainer.rotation);
+ self.waterH.tint = 0x00FF00;
+ }
+ // PI
+ if (Math.abs(self.pipeContainer.rotation - Math.PI) % (2 * Math.PI) < 0.1) {
+ log("Upd Corner H: Case PI; reverted=", reverted, " / self.pipeContainer.rotation=", self.pipeContainer.rotation);
//self.waterH.rotation = (self.pipeContainer.rotation + Math.PI / 2) % (2 * Math.PI);
self.waterH.rotation = (self.pipeContainer.dir == 'rl' ? self.pipeContainer.rotation - Math.PI / 2 : self.pipeContainer.rotation + Math.PI / 2) % (2 * Math.PI);
self.waterH.y = -80;
self.waterH.x = -5;
self.waterH.tint = 0xFF0000;
- }
- // 3*PI/2
- if (Math.abs(self.pipeContainer.rotation - 3 * Math.PI / 2) % (2 * Math.PI) < 0.1) {
- log("updateCornerPipeThirdPhase: Case 3*PI/2");
+ }
+ // 3*PI/2
+ if (Math.abs(self.pipeContainer.rotation - 3 * Math.PI / 2) % (2 * Math.PI) < 0.1) {
+ log("Upd Corner H: Case 3*PI/2");
// 3*PI/2 =>
// P/2 =>
// PI =>
// 0 =>
self.waterH.rotation = (self.pipeContainer.rotation + Math.PI) % (2 * Math.PI);
self.waterH.y = -80;
self.waterH.x = 0;
self.waterH.tint = 0x00FF00;
- }
- log("updateCornerPipeThirdPhase: waterH rotation is:", self.waterH.rotation);
}
+ log("Upd Corner H: waterH rotation is:", self.waterH.rotation);
+ */
};
self.update = function () {
if (self.flow) {
if (!self.startFlowTicks) {
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