Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: _slicedToArray5 is not defined' in or related to this line: '_iterator.f();' Line Number: 1151
User prompt
Please fix the bug: 'Uncaught ReferenceError: _createForOfIteratorHelper is not defined' in or related to this line: 'var _iterator = _createForOfIteratorHelper(nextPositions),' Line Number: 1023
User prompt
Please fix the bug: 'Uncaught ReferenceError: _slicedToArray2 is not defined' in or related to this line: 'var _toCheck$pop = toCheck.pop(),' Line Number: 996
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of null (reading 'baseTile')' in or related to this line: 'if (tile.baseTile) {' Line Number: 1439
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: WaterDrop is not defined' in or related to this line: 'waterDrop = new WaterDrop();' Line Number: 1263
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: pathMap.get is not a function' in or related to this line: '_iterator.f();' Line Number: 1063
User prompt
Please fix the bug: 'Uncaught TypeError: pathMap.set is not a function' in or related to this line: 'pathMap.set(key, {' Line Number: 993
User prompt
Please fix the bug: 'Uncaught TypeError: Map is not a constructor' in or related to this line: 'var pathMap = new Map(); // Store the path for each visited position' Line Number: 939
User prompt
Please fix the bug: 'Uncaught TypeError: Map is not a constructor' in or related to this line: 'var pathMap = new Map(); // Store the path for each visited position' Line Number: 939
Code edit (1 edits merged)
Please save this source code
User prompt
I fixed the checkWinCondition and the sub functions it uses. Now level win is detected properly from start to end. Analyze then Adapt the startWaterFlow and sub functions accordingly so that the flow works from start to end.
User prompt
Please fix the bug: 'Uncaught ReferenceError: currentLevel is not defined' in or related to this line: 'levelText.setText('Level: ' + currentLevel + ' Solved!');' Line Number: 1135
Code edit (3 edits merged)
Please save this source code
User prompt
Add detailled log in function canAcceptFlowFromDirection(tile, incomingDirection)
Code edit (16 edits merged)
Please save this source code
User prompt
add detailed logs (using log() ) to getNextPositions function
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught ReferenceError: x is not defined' in or related to this line: 'self.x = x * tileSize + gridBoard.x - gridBoard.width / 2 + tileSize / 2 + boardOffsetX;' Line Number: 510
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'undefined')' in or related to this line: 'var currentTile = self.grid[y][x];' Line Number: 1511
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'undefined')' in or related to this line: 'var currentTile = self.grid[y][x];' Line Number: 1508
===================================================================
--- original.js
+++ change.js
@@ -3,31 +3,153 @@
****/
var tween = LK.import("@upit/tween.v1");
/****
-* Classes
+* Initialize Game
****/
-// var tween = LK.import("@upit/tween.v1");
-var Tile = Container.expand(function () {
- var self = Container.call(this);
- self.pipeContainer = new Container();
- // Properties
- self.type = 'empty';
+/****
+* Global level configurations
+****/
+var game = new LK.Game({
+ backgroundColor: 0x000000
+});
+
+/****
+* Game Code
+****/
+/****
+* Global level configurations
+****/
+function _createForOfIteratorHelper(r, e) {
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
+ if (!t) {
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray2(r)) || e && r && "number" == typeof r.length) {
+ t && (r = t);
+ var _n = 0,
+ F = function F() {};
+ return {
+ s: F,
+ n: function n() {
+ return _n >= r.length ? {
+ done: !0
+ } : {
+ done: !1,
+ value: r[_n++]
+ };
+ },
+ e: function e(r) {
+ throw r;
+ },
+ f: F
+ };
+ }
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+ }
+ var o,
+ a = !0,
+ u = !1;
+ return {
+ s: function s() {
+ t = t.call(r);
+ },
+ n: function n() {
+ var r = t.next();
+ return a = r.done, r;
+ },
+ e: function e(r) {
+ u = !0, o = r;
+ },
+ f: function f() {
+ try {
+ a || null == t["return"] || t["return"]();
+ } finally {
+ if (u) {
+ throw o;
+ }
+ }
+ }
+ };
+}
+function _slicedToArray2(r, e) {
+ return _arrayWithHoles2(r) || _iterableToArrayLimit2(r, e) || _unsupportedIterableToArray2(r, e) || _nonIterableRest2();
+}
+function _nonIterableRest2() {
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+}
+function _unsupportedIterableToArray2(r, a) {
+ if (r) {
+ if ("string" == typeof r) {
+ return _arrayLikeToArray2(r, a);
+ }
+ var t = {}.toString.call(r).slice(8, -1);
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray2(r, a) : void 0;
+ }
+}
+function _arrayLikeToArray2(r, a) {
+ (null == a || a > r.length) && (a = r.length);
+ for (var e = 0, n = Array(a); e < a; e++) {
+ n[e] = r[e];
+ }
+ return n;
+}
+function _iterableToArrayLimit2(r, l) {
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
+ if (null != t) {
+ var e,
+ n,
+ i,
+ u,
+ a = [],
+ f = !0,
+ o = !1;
+ try {
+ if (i = (t = t.call(r)).next, 0 === l) {
+ if (Object(t) !== t) {
+ return;
+ }
+ f = !1;
+ } else {
+ for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) {
+ ;
+ }
+ }
+ } catch (r) {
+ o = !0, n = r;
+ } finally {
+ try {
+ if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) {
+ return;
+ }
+ } finally {
+ if (o) {
+ throw n;
+ }
+ }
+ }
+ return a;
+ }
+}
+function _arrayWithHoles2(r) {
+ if (Array.isArray(r)) {
+ return r;
+ }
+}
+function Tile() {
+ var self = this;
+ Container.call(self);
+ self.type = null;
+ self.fixed = false;
+ self.gridRow = -1;
+ self.gridCol = -1;
+ self.flow = false;
+ self.startFlowTicks = 0;
self.baseTint = 0xaaaaaa;
self.baseTintLight = 0xaaaaaa;
self.maxWaterSize = 260;
self.flowSpeed = 12;
- self.startFlowTicks = 0;
- self.flow = false;
- self.connections = [];
- self.position = {
- x: 0,
- y: 0
- };
- self.rotation = 0;
- self.normalizedRotation = 0;
- // Methods
- self.createStartTile = function () {
+ self.pipeContainer = new Container();
+ self.addChild(self.pipeContainer);
+ self.createStartPipe = function () {
self.pipeContainer.attachAsset('startPipeAsset', {
anchorX: 0.5,
anchorY: 0.5,
x: 20,
@@ -50,9 +172,9 @@
visible: false,
dir: ''
});
};
- self.createEndTile = function () {
+ self.createEndPipe = function () {
self.pipeContainer.attachAsset('endPipeAsset', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
@@ -77,93 +199,57 @@
height: 0,
visible: false
});
};
- self.createCrossPipe = function () {
- self.pipeContainer.attachAsset('straightPipeHAsset', {
- anchorX: 0.5,
- anchorY: 0.5,
- y: -40,
- tint: self.baseTint
- });
- self.pipeContainer.attachAsset('straightPipeHAsset', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleY: -1,
- y: 30,
- tint: self.baseTint
- });
- self.pipeContainer.attachAsset('straightPipeVAsset', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: -30,
- tint: self.baseTint
- });
- self.pipeContainer.attachAsset('straightPipeVAsset', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: -1,
- x: 30,
- tint: self.baseTint
- });
- self.water = self.pipeContainer.attachAsset('waterV', {
- anchorX: 0.5,
- anchorY: 0,
- x: -0,
- y: -120,
- height: 0,
- visible: false,
- dir: ''
- });
+ self.createStraightPipe = function (isVertical) {
+ if (isVertical) {
+ self.pipeContainer.attachAsset('straightPipeVAsset', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -30,
+ tint: self.baseTint
+ });
+ self.pipeContainer.attachAsset('straightPipeVAsset', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1,
+ x: 30,
+ tint: self.baseTint
+ });
+ self.water = self.pipeContainer.attachAsset('waterV', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: -0,
+ y: -120,
+ height: 0,
+ visible: false,
+ dir: 'tb'
+ });
+ } else {
+ self.pipeContainer.attachAsset('straightPipeHAsset', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -40,
+ tint: self.baseTint
+ });
+ self.pipeContainer.attachAsset('straightPipeHAsset', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ 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'
+ });
+ }
};
- self.createStraightPipeH = function () {
- self.pipeContainer.attachAsset('straightPipeHAsset', {
- anchorX: 0.5,
- anchorY: 0.5,
- y: -40,
- tint: self.baseTint
- });
- self.pipeContainer.attachAsset('straightPipeHAsset', {
- anchorX: 0.5,
- anchorY: 0.5,
- 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'
- });
- };
- self.createStraightPipeV = function () {
- self.pipeContainer.attachAsset('straightPipeVAsset', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: -30,
- tint: self.baseTint
- });
- self.pipeContainer.attachAsset('straightPipeVAsset', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: -1,
- x: 30,
- tint: self.baseTint
- });
- self.water = self.pipeContainer.attachAsset('waterV', {
- anchorX: 0.5,
- anchorY: 0,
- x: -0,
- y: -120,
- height: 0,
- visible: false,
- dir: 'tb'
- });
- };
self.createCornerPipe = function () {
self.pipeContainer.attachAsset('cornerPipeAsset', {
anchorX: 0.5,
anchorY: 0.5,
@@ -245,182 +331,164 @@
rotation: Math.PI * 0.5,
tint: self.baseTintLight
});
};
- self.getCornerPipeConfig = function () {
- // Define the water flow configuration based on normalized rotation
- var configs = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, Math.PI / 2, {
- // right
- primaryWater: 'waterV',
- secondaryWater: 'waterH',
- primaryGrowth: {
- property: 'height',
- direction: 1,
- position: {
- x: -120,
- y: -5
- },
- rotation: -Math.PI / 2
- },
- secondaryGrowth: {
- property: 'width',
- direction: 1,
- position: {
- x: -5,
- y: -50
- },
- rotation: -Math.PI / 2
- },
- cornerPosition: {
- x: -65,
- y: -65
- }
- }), 0, {
- // up
- primaryWater: 'waterH',
- secondaryWater: 'waterV',
- primaryGrowth: {
- property: 'width',
- direction: -1,
- position: {
- x: -5,
- y: -50
- },
- rotation: -Math.PI / 2
- },
- secondaryGrowth: {
- property: 'height',
- direction: 1,
- position: {
- x: -120,
- y: -5
- },
- rotation: -Math.PI / 2
- },
- cornerPosition: {
- x: -65,
- y: -65
- }
- }), Math.PI, {
- // down
- primaryWater: 'waterH',
- secondaryWater: 'waterV',
- primaryGrowth: {
- property: 'width',
- direction: 1,
- position: {
- x: -5,
- y: -50
- },
- rotation: -Math.PI / 2
- },
- secondaryGrowth: {
- property: 'height',
- direction: -1,
- position: {
- x: -120,
- y: -5
- },
- rotation: -Math.PI / 2
- },
- cornerPosition: {
- x: -65,
- y: -65
- }
- }), Math.PI * 1.5, {
- // left
- primaryWater: 'waterV',
- secondaryWater: 'waterH',
- primaryGrowth: {
- property: 'height',
- direction: -1,
- position: {
- x: -120,
- y: -5
- },
- rotation: -Math.PI / 2
- },
- secondaryGrowth: {
- property: 'width',
- direction: -1,
- position: {
- x: -5,
- y: -50
- },
- rotation: -Math.PI / 2
- },
- cornerPosition: {
- x: -65,
- y: -65
- }
+ self.createCrossPipe = function () {
+ self.pipeContainer.attachAsset('straightPipeHAsset', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -40,
+ tint: self.baseTint
});
- return configs[self.normalizeRotation(self.pipeContainer.rotation)] || configs[0];
+ self.pipeContainer.attachAsset('straightPipeHAsset', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleY: -1,
+ y: 30,
+ tint: self.baseTint
+ });
+ self.pipeContainer.attachAsset('straightPipeVAsset', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: -30,
+ tint: self.baseTint
+ });
+ self.pipeContainer.attachAsset('straightPipeVAsset', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: -1,
+ x: 30,
+ tint: self.baseTint
+ });
+ self.water = self.pipeContainer.attachAsset('waterV', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: -0,
+ y: -120,
+ height: 0,
+ visible: false,
+ dir: ''
+ });
};
- self.updateCornerPipeFirstPhase = function (progress, thirdSize) {
- log("Progress in first third:", progress);
- var config = self.getCornerPipeConfig();
- var primary = self[config.primaryWater];
- if (primary) {
- primary.visible = true;
- primary[config.primaryGrowth.property] = progress * config.primaryGrowth.direction;
- primary.x = config.primaryGrowth.position.x;
- primary.y = config.primaryGrowth.position.y;
- primary.rotation = config.primaryGrowth.rotation;
- if (config.primaryGrowth.direction < 0) {
- primary['scale' + (config.primaryGrowth.property === 'width' ? 'X' : 'Y')] = -1;
- }
- log("Primary water set to:", primary[config.primaryGrowth.property]);
+ self.setType = function (type, row, col) {
+ self.type = type;
+ self.gridRow = row;
+ self.gridCol = col;
+ // Clear existing pipe graphics
+ while (self.pipeContainer.children.length > 0) {
+ self.pipeContainer.removeChildAt(0);
}
+ // Create pipe graphics based on type
+ switch (type) {
+ case TileFormat.TYPES.START:
+ self.createStartPipe();
+ break;
+ case TileFormat.TYPES.END:
+ self.createEndPipe();
+ break;
+ case TileFormat.TYPES.VERTICAL:
+ self.createStraightPipe(true);
+ break;
+ case TileFormat.TYPES.HORIZONTAL:
+ self.createStraightPipe(false);
+ break;
+ case TileFormat.TYPES.CORNER:
+ self.createCornerPipe();
+ break;
+ case TileFormat.TYPES.CROSS:
+ self.createCrossPipe();
+ break;
+ }
+ // Add base tile last so it appears under the pipes
+ var baseTileAsset = type == TileFormat.TYPES.START || type == TileFormat.TYPES.END || puzzleManager && puzzleManager.levelConfigs && puzzleManager.levelConfigs[puzzleManager.currentLevel] && puzzleManager.levelConfigs[puzzleManager.currentLevel].fixedTiles && puzzleManager.levelConfigs[puzzleManager.currentLevel].fixedTiles.includes(col + ',' + row) ? 'baseTile' : 'baseMobileTile';
+ self.attachAsset(baseTileAsset, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: tileSize,
+ height: tileSize,
+ tint: 0xFFFFFF
+ });
+ self.addChild(self.pipeContainer);
};
- self.updateCornerPipeSecondPhase = function (progress, thirdSize) {
- log("Progress in second third:", progress);
- var config = self.getCornerPipeConfig();
- var primary = self[config.primaryWater];
- // Keep primary at max
- if (primary) {
- primary[config.primaryGrowth.property] = thirdSize * config.primaryGrowth.direction;
- log("Primary water at max:", primary[config.primaryGrowth.property]);
+ self.getNextPositions = function (col, row, type, rotation) {
+ var positions = [];
+ switch (type) {
+ case TileFormat.TYPES.START:
+ // Start pipe flows in direction of rotation
+ var dx = Math.cos(rotation);
+ var dy = Math.sin(rotation);
+ positions.push([col + Math.round(dx), row + Math.round(dy)]);
+ break;
+ case TileFormat.TYPES.VERTICAL:
+ positions.push([col, row - 1]); // Up
+ positions.push([col, row + 1]); // Down
+ break;
+ case TileFormat.TYPES.HORIZONTAL:
+ positions.push([col - 1, row]); // Left
+ positions.push([col + 1, row]); // Right
+ break;
+ case TileFormat.TYPES.CORNER:
+ var angle = rotation % (2 * Math.PI);
+ if (angle < 0.1 || Math.abs(angle - Math.PI / 2) < 0.1) {
+ positions.push([col + 1, row]); // Right
+ positions.push([col, row - 1]); // Up
+ } else if (Math.abs(angle - Math.PI) < 0.1 || Math.abs(angle - 3 * Math.PI / 2) < 0.1) {
+ positions.push([col - 1, row]); // Left
+ positions.push([col, row + 1]); // Down
+ }
+ break;
+ case TileFormat.TYPES.CROSS:
+ positions.push([col - 1, row]); // Left
+ positions.push([col + 1, row]); // Right
+ positions.push([col, row - 1]); // Up
+ positions.push([col, row + 1]); // Down
+ break;
}
- // Update corner water
- if (self.waterCorner) {
- self.waterCorner.visible = true;
- self.waterCorner.x = config.cornerPosition.x;
- self.waterCorner.y = config.cornerPosition.y;
- self.waterCorner.alpha = Math.min(Math.max(0, ((progress - thirdSize) / thirdSize - 0.5) * 2, 0), 1);
- var rotationProgress = (progress - thirdSize) / thirdSize;
- self.waterCorner.rotation = -Math.PI / 2 - rotationProgress * Math.PI / 2;
- log("WaterCorner visible with alpha:", self.waterCorner.alpha, "and rotation:", self.waterCorner.rotation);
+ return positions;
+ };
+ self.normalizeRotation = function (rotation) {
+ while (rotation < 0) {
+ rotation += 2 * Math.PI;
}
+ return rotation % (2 * Math.PI);
};
- self.updateCornerPipeThirdPhase = function (progress, thirdSize, sidesSize) {
- log("Progress in final third:", progress);
- var config = self.getCornerPipeConfig();
- var primary = self[config.primaryWater];
- var secondary = self[config.secondaryWater];
- // Keep primary at max
- if (primary) {
- primary[config.primaryGrowth.property] = thirdSize * config.primaryGrowth.direction;
- log("Primary water at max:", primary[config.primaryGrowth.property]);
+ self.setRotation = function (rotation) {
+ if (typeof rotation === 'number') {
+ self.pipeContainer.rotation = self.normalizeRotation(rotation * Math.PI / 2);
+ } else {
+ // Handle string rotations (legacy support)
+ switch (rotation) {
+ case 'up':
+ self.pipeContainer.rotation = 0;
+ break;
+ case 'right':
+ self.pipeContainer.rotation = Math.PI / 2;
+ break;
+ case 'down':
+ self.pipeContainer.rotation = Math.PI;
+ break;
+ case 'left':
+ self.pipeContainer.rotation = 3 * Math.PI / 2;
+ break;
+ }
}
- // Set corner to final state
- if (self.waterCorner) {
- self.waterCorner.visible = true;
- self.waterCorner.x = config.cornerPosition.x;
- self.waterCorner.y = config.cornerPosition.y;
- self.waterCorner.alpha = 1;
- self.waterCorner.rotation = -Math.PI;
- log("WaterCorner fully visible with rotation:", self.waterCorner.rotation);
- }
- // Grow secondary pipe
- if (secondary) {
- secondary.visible = true;
- secondary[config.secondaryGrowth.property] = Math.min(progress - thirdSize * 2, sidesSize) * config.secondaryGrowth.direction;
- secondary.x = config.secondaryGrowth.position.x;
- secondary.y = config.secondaryGrowth.position.y;
- if (config.secondaryGrowth.direction < 0) {
- secondary['scale' + (config.secondaryGrowth.property === 'width' ? 'X' : 'Y')] = -1;
+ };
+ 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;
+ };
+ // Water flow update methods
+ self.updateStartTile = function () {
+ if (self.valve) {
+ var rotationValue = (LK.ticks - self.startFlowTicks) * 0.1;
+ self.valve.rotation = rotationValue;
+ if (rotationValue >= Math.PI * 3) {
+ self.flow = false;
}
- log("Secondary water visible with size:", secondary[config.secondaryGrowth.property]);
}
};
self.updateEndTile = function () {
if (self.fountain) {
@@ -434,13 +502,12 @@
}
} else {
self.flow = false;
if (!waterDropInterval) {
- createWaterDrops(self.x, self.y, game);
+ createWaterDrops(self.x, self.y + 100, game);
waterDropInterval = LK.setInterval(function () {
- createWaterDrops(self.x, self.y, game);
+ createWaterDrops(self.x, self.y + 100, game);
}, 500 + Math.random() * 500);
- animateSoil();
}
}
}
};
@@ -472,31 +539,44 @@
self.flow = false;
}
}
};
- self.updateEndTileAnimation = function () {
- if (self.type === 'end' && self.fountain && self.fountain.visible) {
- self.fountain.rotation += 0.1;
- var sizeVariation = 30 * Math.sin(LK.ticks * 0.1);
- self.fountain.width = 250 + sizeVariation;
- self.fountain.height = 250 + sizeVariation;
- }
- };
self.updateCornerPipe = function () {
var progress = (LK.ticks - self.startFlowTicks) * self.flowSpeed;
- var thirdSize = self.maxWaterSize / 3 - 10;
- var sidesSize = self.maxWaterSize / 3;
+ var thirdSize = self.maxWaterSize / 3;
if (progress < thirdSize) {
self.updateCornerPipeFirstPhase(progress, thirdSize);
} else if (progress < thirdSize * 2) {
self.updateCornerPipeSecondPhase(progress, thirdSize);
} else {
- self.updateCornerPipeThirdPhase(progress, thirdSize, sidesSize);
+ self.updateCornerPipeThirdPhase(progress, thirdSize);
}
if (progress >= self.maxWaterSize) {
self.flow = false;
}
};
+ self.updateCornerPipeFirstPhase = function (progress, thirdSize) {
+ if (self.waterV) {
+ self.waterV.visible = true;
+ self.waterV.height = progress;
+ }
+ };
+ self.updateCornerPipeSecondPhase = function (progress, thirdSize) {
+ if (self.waterCorner) {
+ self.waterCorner.visible = true;
+ self.waterCorner.alpha = (progress - thirdSize) / thirdSize;
+ }
+ if (self.waterCornerCover) {
+ self.waterCornerCover.visible = true;
+ self.waterCornerCover.alpha = (progress - thirdSize) / thirdSize;
+ }
+ };
+ self.updateCornerPipeThirdPhase = function (progress, thirdSize) {
+ if (self.waterH) {
+ self.waterH.visible = true;
+ self.waterH.width = progress - thirdSize * 2;
+ }
+ };
self.update = function () {
if (self.flow) {
if (!self.startFlowTicks) {
self.startFlowTicks = LK.ticks;
@@ -510,333 +590,32 @@
self.waterH.visible = true;
}
}
switch (self.type) {
- case 'start':
+ case TileFormat.TYPES.START:
self.updateStartTile();
break;
- case 'cornerPipe':
- self.updateCornerPipe();
- break;
- case 'end':
+ case TileFormat.TYPES.END:
self.updateEndTile();
break;
+ case TileFormat.TYPES.CORNER:
+ self.updateCornerPipe();
+ break;
default:
self.updateRegularPipe();
break;
}
}
- self.updateEndTileAnimation();
- };
- self.setType = function (type, x, y) {
- self.type = type;
- var baseTileAsset = type == 'start' || type == 'end' || puzzleManager && puzzleManager.levelConfigs && puzzleManager.levelConfigs[puzzleManager.currentLevel] && puzzleManager.levelConfigs[puzzleManager.currentLevel].fixedTiles && puzzleManager.levelConfigs[puzzleManager.currentLevel].fixedTiles.includes(x + ',' + y) ? 'baseTile' : 'baseMobileTile';
- if (type == 'empty') {
- return;
+ // Animate end tile fountain
+ if (self.type === TileFormat.TYPES.END && self.fountain && self.fountain.visible) {
+ self.fountain.rotation += 0.1;
+ var sizeVariation = 30 * Math.sin(LK.ticks * 0.1);
+ self.fountain.width = 250 + sizeVariation;
+ self.fountain.height = 250 + sizeVariation;
}
- // Attach baseTile asset
- self.baseTile = self.attachAsset(baseTileAsset, {
- anchorX: 0.5,
- anchorY: 0.5,
- width: tileSize,
- height: tileSize,
- tint: 0xFFFFFF
- });
- self.addChild(self.pipeContainer);
- self.width = tileSize;
- self.height = tileSize;
- // Create tile based on type
- switch (type) {
- case 'start':
- self.createStartTile();
- break;
- case 'end':
- self.createEndTile();
- break;
- case 'crossPipe':
- self.createCrossPipe();
- break;
- case 'straightPipeH':
- self.createStraightPipeH();
- break;
- case 'straightPipeV':
- self.createStraightPipeV();
- break;
- case 'cornerPipe':
- self.createCornerPipe();
- break;
- }
};
- self.updatePosition = function (x, y) {
- self.position.x = x;
- self.position.y = y;
- if (self.baseTile) {
- self.baseTile.width = tileSize;
- self.baseTile.height = tileSize;
- }
- self.x = x * tileSize + gridBoard.x - gridBoard.width / 2 + tileSize / 2 + boardOffsetX;
- self.y = y * tileSize + gridBoard.y - gridBoard.height / 2 + tileSize / 2 + boardOffsetY;
- log('Tile index:', x, y, 'Tile position:', self.x, self.y, 'Tile dimensions:', self.width, self.height, ' self:', self);
- };
- self.normalizeRotation = function (rotation) {
- // If rotation is a number (radians), convert it to our direction system
- if (typeof rotation === 'number') {
- 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 'down'; //'up';
- }
- if (angle < 3 * Math.PI / 4) {
- return 'right';
- }
- if (angle < 5 * Math.PI / 4) {
- return 'up'; // 'down';
- }
- return 'left';
- break;
- }
- }
- return rotation || 'down';
- };
- self.setRotation = function (direction) {
- switch (self.type) {
- case 'cornerPipe':
- switch (direction) {
- case 'left':
- self.pipeContainer.rotation = 0;
- self.normalizedRotation = 0;
- break;
- case 'right':
- self.pipeContainer.rotation = Math.PI * 0.5;
- self.normalizedRotation = Math.PI * 0.5;
- break;
- case 'up':
- self.pipeContainer.rotation = Math.PI;
- self.normalizedRotation = Math.PI;
- break;
- case 'down':
- self.pipeContainer.rotation = Math.PI * 1.5;
- self.normalizedRotation = Math.PI * 1.5;
- break;
- }
- log("Corner Set rot ", direction, " => ", self.pipeContainer.rotation);
- break;
- 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 = Math.PI;
- break;
- case 'down':
- self.pipeContainer.rotation = 0;
- break;
- }
- break;
- }
- log('Tile position:', self.x, self.y, 'Tile rotation:', self.pipeContainer.rotation);
- };
- self.getNextPositions = function (x, y, type, normalizedRotation) {
- var nextPositions = [];
- switch (type) {
- case 'start':
- switch (normalizedRotation) {
- case 'down':
- nextPositions.push([x, y + 1]); // Down
- break;
- case 'up':
- nextPositions.push([x, y - 1]); // Up
- break;
- case 'left':
- nextPositions.push([x - 1, y]); // Left
- break;
- case 'right':
- nextPositions.push([x + 1, y]); // Right
- break;
- }
- break;
- 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 - 1, y], [x, y + 1]); // 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.updateStartTile = function () {
- var rotationValue = (LK.ticks - self.startFlowTicks) * 0.1;
- if (self.valve) {
- self.valve.rotation = rotationValue;
- }
- if (rotationValue >= Math.PI * 3) {
- self.flow = false;
- }
- };
- self.updateCornerPipeFirstPhase = function (progress, thirdSize) {
- log("Progress in first third:", progress);
- var config = self.getCornerPipeConfig();
- var primary = self[config.primaryWater];
- if (primary) {
- primary[config.primaryGrowth.property] = progress * config.primaryGrowth.direction;
- primary.x = config.primaryGrowth.position.x;
- primary.y = config.primaryGrowth.position.y;
- if (config.primaryGrowth.direction < 0) {
- primary['scale' + (config.primaryGrowth.property === 'width' ? 'X' : 'Y')] = -1;
- }
- log("Primary water set to:", primary[config.primaryGrowth.property]);
- }
- };
- self.updateCornerPipeSecondPhase = function (progress, thirdSize) {
- log("Progress in second third:", progress);
- var config = self.getCornerPipeConfig();
- var primary = self[config.primaryWater];
- // Keep primary at max
- if (primary) {
- primary[config.primaryGrowth.property] = thirdSize * config.primaryGrowth.direction;
- log("Primary water at max:", primary[config.primaryGrowth.property]);
- }
- // Update corner water
- if (self.waterCorner) {
- self.waterCorner.visible = true;
- self.waterCorner.alpha = Math.min(Math.max(0, ((progress - thirdSize) / thirdSize - 0.5) * 2, 0), 1);
- var rotationProgress = (progress - thirdSize) / thirdSize;
- self.waterCorner.rotation = -Math.PI / 2 - rotationProgress * Math.PI / 2;
- log("WaterCorner visible with alpha:", self.waterCorner.alpha, "and rotation:", self.waterCorner.rotation);
- }
- };
- self.updateCornerPipeThirdPhase = function (progress, thirdSize, sidesSize) {
- log("Progress in final third:", progress);
- var config = self.getCornerPipeConfig();
- var primary = self[config.primaryWater];
- var secondary = self[config.secondaryWater];
- // Keep primary at max
- if (primary) {
- primary[config.primaryGrowth.property] = thirdSize * config.primaryGrowth.direction;
- log("Primary water at max:", primary[config.primaryGrowth.property]);
- }
- // Set corner to final state
- if (self.waterCorner) {
- self.waterCorner.visible = true;
- self.waterCorner.alpha = 1;
- self.waterCorner.rotation = -Math.PI;
- log("WaterCorner fully visible with rotation:", self.waterCorner.rotation);
- }
- // Grow secondary pipe
- if (secondary) {
- secondary.visible = true;
- secondary[config.secondaryGrowth.property] = Math.min(progress - thirdSize * 2, sidesSize) * config.secondaryGrowth.direction;
- secondary.x = config.secondaryGrowth.position.x;
- secondary.y = config.secondaryGrowth.position.y;
- if (config.secondaryGrowth.direction < 0) {
- secondary['scale' + (config.secondaryGrowth.property === 'width' ? 'X' : 'Y')] = -1;
- }
- log("Secondary water visible with size:", secondary[config.secondaryGrowth.property]);
- }
- };
- self.setType(self.type);
- return self;
-});
-var WaterDrop = Container.expand(function () {
- var self = Container.call(this);
- var waterDropGraphics = self.attachAsset('waterDrop', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- // Set initial tint to a random color
- var rainbowColors = [0xC7ECFE, 0xDDFDFF, 0xF4FFFF, 0xC8F8FF]; // Rainbow [0xFF0000, 0xFF7F00, 0xFFFF00, 0x00FF00, 0x0000FF, 0x4B0082, 0x8B00FF];
- waterDropGraphics.tint = rainbowColors[Math.floor(Math.random() * rainbowColors.length)];
- self.vx = 0;
- self.vy = 0;
- self.life = 0;
- self.size = 7;
- self.alpha = 0.75 + Math.random() * 0.25;
- self.update = function () {
- self.x += self.vx;
- self.y += self.vy;
- self.rotation = Math.atan2(self.vy, self.vx) + Math.PI * 0.55;
- // Animate size
- var sizeProgress = (120 - self.life) / 120; // Assuming life starts at 120
- waterDropGraphics.width = self.size + sizeProgress * self.size * 2;
- waterDropGraphics.height = self.size * 2 + sizeProgress * self.size * 4;
- self.life--;
- if (self.life <= 0) {
- self.visible = false;
- }
- };
- return self;
-});
-
-/****
-* Initialize Game
-****/
-/****
-* Global level configurations
-****/
-var game = new LK.Game({
- backgroundColor: 0x000000
-});
-
-/****
-* Game Code
-****/
-/****
-* Global level configurations
-****/
+}
+Tile.prototype = Object.create(Container.prototype);
function _slicedToArray3(r, e) {
return _arrayWithHoles3(r) || _iterableToArrayLimit3(r, e) || _unsupportedIterableToArray3(r, e) || _nonIterableRest3();
}
function _nonIterableRest3() {
@@ -899,110 +678,14 @@
if (Array.isArray(r)) {
return r;
}
}
-function _slicedToArray2(r, e) {
- return _arrayWithHoles2(r) || _iterableToArrayLimit2(r, e) || _unsupportedIterableToArray2(r, e) || _nonIterableRest2();
-}
-function _nonIterableRest2() {
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
-}
-function _unsupportedIterableToArray2(r, a) {
- if (r) {
- if ("string" == typeof r) {
- return _arrayLikeToArray2(r, a);
- }
- var t = {}.toString.call(r).slice(8, -1);
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray2(r, a) : void 0;
- }
-}
-function _arrayLikeToArray2(r, a) {
- (null == a || a > r.length) && (a = r.length);
- for (var e = 0, n = Array(a); e < a; e++) {
- n[e] = r[e];
- }
- return n;
-}
-function _iterableToArrayLimit2(r, l) {
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
- if (null != t) {
- var e,
- n,
- i,
- u,
- a = [],
- f = !0,
- o = !1;
- try {
- if (i = (t = t.call(r)).next, 0 === l) {
- if (Object(t) !== t) {
- return;
- }
- f = !1;
- } else {
- for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) {
- ;
- }
- }
- } catch (r) {
- o = !0, n = r;
- } finally {
- try {
- if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) {
- return;
- }
- } finally {
- if (o) {
- throw n;
- }
- }
- }
- return a;
- }
-}
-function _arrayWithHoles2(r) {
- if (Array.isArray(r)) {
- return r;
- }
-}
var levelConfigs = {
- 11: {
- tiles: [["start", "straightPipeV", "straightPipeV", "cornerPipe"], [null, null, null, "straightPipeH"], [null, null, "straightPipeH", null], [null, null, null, "end"]],
- rotations: {
- "0,3": "right",
- "3,3": "left"
- },
- fixedTiles: ["0,0", "0,1", "0,2", "0,3", "1,3", "3,3"]
- },
- 2: {
- tiles: [[null, "straightPipeH", "end", null], [null, "cornerPipe", "straightPipeH", null], [null, null, null, null], ["start", "straightPipeV", null, null]],
- rotations: {
- "0,2": "right",
- "1,1": "left"
- },
- fixedTiles: ["3,0", "3,1", "0,2", "1,2"]
- },
- 3: {
- tiles: [["cornerPipe", null, null, "straightPipeV"], ["cornerPipe", "end", null, "straightPipeH"], [null, null, null, null], [null, null, "straightPipeV", "start"]],
- rotations: {
- "0,0": "down",
- "1,0": "up",
- "1,1": "up",
- "3,3": "up"
- },
- fixedTiles: ["1,0", "1,1", "3,2", "3,3"]
- },
- 1: {
- tiles: [["cornerPipe", null, null, "cornerPipe"], ["straightPipeH", "straightPipeV", "straightPipeV", "straightPipeH"], ["cornerPipe", "start", "end", "cornerPipe"], [null, null, null, null]],
- rotations: {
- "0,0": "right",
- "0,3": "up",
- "2,0": "down",
- "2,1": "up",
- "2,3": "left"
- },
- fixedTiles: ["1,0", "1,3", "2,1", "2,2", "2,3"]
- }
+ 1: [["F-S-0", "", "", ""], ["F-V-0", "", "", ""], ["F-V-0", "", "M-H-0", ""], ["F-C-3", "F-H-0", "", "F-E-0"]],
+ 2: [["", "M-H-0", "F-E-1", ""], ["", "F-C-1", "F-H-0", ""], ["", "", "", ""], ["F-S-0", "F-V-0", "", ""]],
+ 3: [["F-C-2", "", "", "M-V-0"], ["F-C-1", "F-E-1", "", "F-H-0"], ["", "", "", ""], ["", "", "F-V-0", "F-S-1"]],
+ 4: [["F-S-0", "F-H-0", "M-C-0", ""], ["", "", "F-V-0", ""], ["", "M-H-0", "F-C-3", ""], ["", "", "F-V-0", "F-E-0"]],
+ 5: [["", "", "F-S-0", ""], ["M-V-0", "F-C-1", "F-H-0", "M-C-0"], ["F-V-0", "", "", "F-V-0"], ["F-E-1", "F-H-0", "M-H-0", "F-C-3"]]
};
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
@@ -1111,299 +794,307 @@
this.items[item] = true;
}
};
};
-var PuzzleManager = function PuzzleManager() {
+var PuzzleManager = function PuzzleManager(game) {
var self = this;
- // Properties
- self.currentLevel = 1;
- self.maxLevels = 30;
+ self.game = game;
self.grid = [];
self.gridSize = 4;
self.selectedTile = null;
- self.waterFlowing = false;
self.isComplete = false;
- // Level configurations
- self.levelConfigs = levelConfigs;
- self.initPuzzle = function () {
- log("Initializing puzzle for level", self.currentLevel);
- // Clear existing grid
- self.grid = [];
- // Get level config
- var config = self.levelConfigs[self.currentLevel];
- if (!config) {
- log("No configuration for level", self.currentLevel);
- return;
+ self.waterFlowing = false;
+ self.reset = function () {
+ // Clear grid
+ for (var row = 0; row < self.gridSize; row++) {
+ if (!self.grid[row]) {
+ self.grid[row] = [];
+ }
+ for (var col = 0; col < self.gridSize; col++) {
+ if (self.grid[row][col]) {
+ self.grid[row][col].destroy();
+ }
+ self.grid[row][col] = null;
+ }
}
- // Initialize grid
- for (var i = 0; i < self.gridSize; i++) {
- self.grid[i] = [];
- for (var j = 0; j < self.gridSize; j++) {
- var tile = new Tile();
- if (config.tiles[i] && config.tiles[i][j]) {
- tile.setType(config.tiles[i][j], i, j);
+ // Reset state
+ self.selectedTile = null;
+ self.isComplete = false;
+ self.waterFlowing = false;
+ // Clear water drops
+ if (waterDropInterval) {
+ LK.clearInterval(waterDropInterval);
+ waterDropInterval = null;
+ }
+ // Reset water particles
+ if (game.waterParticles) {
+ for (var i = game.waterParticles.length - 1; i >= 0; i--) {
+ var particle = game.waterParticles[i];
+ if (particle && particle.parent) {
+ particle.parent.removeChild(particle);
}
- tile.updatePosition(i, j);
- self.grid[i][j] = tile;
- game.addChild(tile);
}
+ game.waterParticles = [];
}
- // Apply rotations
- if (config.rotations) {
- for (var pos in config.rotations) {
- /*var _pos$split$map = pos.split(',').map(Number),
- _pos$split$map2 = _slicedToArray(_pos$split$map, 2),
- x = _pos$split$map2[0],
- y = _pos$split$map2[1];
- self.grid[x][y].setRotation(config.rotations[pos]);*/
- var _pos$split$map = pos.split(',').map(Number),
- x = _pos$split$map[0],
- y = _pos$split$map[1];
- self.grid[x][y].setRotation(config.rotations[pos]);
+ };
+ self.initPuzzle = function (level) {
+ self.reset();
+ // Initialize grid with tiles from level configuration
+ for (var row = 0; row < self.gridSize; row++) {
+ self.grid[row] = [];
+ for (var col = 0; col < self.gridSize; col++) {
+ var tileStr = level[row][col];
+ var tile = createTile(tileStr, row, col);
+ if (tile) {
+ gridBoard.addChild(tile);
+ self.grid[row][col] = tile;
+ }
}
}
};
+ self.checkWinCondition = function () {
+ log("=== Starting Win Condition Check ===");
+ // Debug grid state
+ log("Grid state:");
+ for (var row = 0; row < self.gridSize; row++) {
+ var rowStr = [];
+ for (var col = 0; col < self.gridSize; col++) {
+ var tile = self.grid[row][col];
+ if (tile) {
+ var rotIndex = TileFormat.getRotationIndex(tile.normalizeRotation(tile.pipeContainer.rotation));
+ rowStr.push("".concat(tile.fixed ? 'F' : 'M', "-").concat(tile.type, "-").concat(rotIndex));
+ } else {
+ rowStr.push('empty');
+ }
+ }
+ log("Row ".concat(row, ":"), rowStr.join(' | '));
+ }
+ // Find start tile
+ var startTile = null;
+ var startRow = -1,
+ startCol = -1;
+ for (var row = 0; row < self.gridSize; row++) {
+ for (var col = 0; col < self.gridSize; col++) {
+ if (self.grid[row][col] && self.grid[row][col].type === TileFormat.TYPES.START) {
+ startTile = self.grid[row][col];
+ startRow = row;
+ startCol = col;
+ break;
+ }
+ }
+ if (startTile) {
+ break;
+ }
+ }
+ if (!startTile) {
+ log("No start tile found!");
+ return false;
+ }
+ log("Found start tile at row:", startRow, "col:", startCol);
+ var visited = new SimpleSet();
+ var toCheck = [[startRow, startCol, getFlowDirection(startTile)]];
+ function getFlowDirection(tile) {
+ var rotation = tile.normalizeRotation(tile.pipeContainer.rotation);
+ switch (tile.type) {
+ case TileFormat.TYPES.START:
+ return rotation;
+ case TileFormat.TYPES.CORNER:
+ return (rotation + Math.PI / 2) % (2 * Math.PI);
+ default:
+ return rotation;
+ }
+ }
+ function canAcceptFlowFromDirection(tile, incomingDirection) {
+ var normalizedIncoming = (incomingDirection + Math.PI) % (2 * Math.PI);
+ var tileRotation = tile.normalizeRotation(tile.pipeContainer.rotation);
+ switch (tile.type) {
+ case TileFormat.TYPES.START:
+ return false;
+ case TileFormat.TYPES.END:
+ var angle = (normalizedIncoming - tileRotation + 2 * Math.PI) % (2 * Math.PI);
+ return angle < 0.1;
+ case TileFormat.TYPES.VERTICAL:
+ var angle = Math.abs(normalizedIncoming - Math.PI / 2) % (2 * Math.PI);
+ return angle < 0.1 || Math.abs(angle - Math.PI) < 0.1;
+ case TileFormat.TYPES.HORIZONTAL:
+ var angle = normalizedIncoming % (2 * Math.PI);
+ return angle < 0.1 || Math.abs(angle - Math.PI) < 0.1;
+ case TileFormat.TYPES.CORNER:
+ var angle = (normalizedIncoming - tileRotation + 2 * Math.PI) % (2 * Math.PI);
+ return angle < 0.1 || Math.abs(angle - Math.PI / 2) < 0.1;
+ default:
+ return false;
+ }
+ }
+ while (toCheck.length > 0) {
+ var _toCheck$pop = toCheck.pop(),
+ _toCheck$pop2 = _slicedToArray2(_toCheck$pop, 3),
+ row = _toCheck$pop2[0],
+ col = _toCheck$pop2[1],
+ flowDirection = _toCheck$pop2[2];
+ var key = "".concat(row, ",").concat(col);
+ if (visited.has(key)) {
+ continue;
+ }
+ visited.add(key);
+ log("Checking position - row:", row, "col:", col);
+ if (row < 0 || row >= self.gridSize || col < 0 || col >= self.gridSize) {
+ log("Position out of bounds");
+ continue;
+ }
+ var currentTile = self.grid[row][col];
+ if (!currentTile) {
+ log("No tile at position");
+ continue;
+ }
+ var normalizedRotation = currentTile.normalizeRotation(currentTile.pipeContainer.rotation);
+ log("Checking tile:", currentTile.type, "rotation:", TileFormat.getRotationIndex(normalizedRotation));
+ var nextPositions = currentTile.getNextPositions(col, row, currentTile.type, normalizedRotation);
+ log("Next positions to check:", nextPositions);
+ var _iterator = _createForOfIteratorHelper(nextPositions),
+ _step;
+ try {
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
+ var nextPos = _step.value;
+ var _nextPos = nextPos,
+ _nextPos2 = _slicedToArray2(_nextPos, 2),
+ nextCol = _nextPos2[0],
+ nextRow = _nextPos2[1];
+ log("Trying next position - row:", nextRow, "col:", nextCol);
+ if (nextRow < 0 || nextRow >= self.gridSize || nextCol < 0 || nextCol >= self.gridSize) {
+ log("Next position out of bounds");
+ continue;
+ }
+ var nextTile = self.grid[nextRow][nextCol];
+ if (!nextTile) {
+ log("No tile at next position");
+ continue;
+ }
+ var incomingDirection = Math.atan2(nextRow - row, nextCol - col);
+ if (!canAcceptFlowFromDirection(nextTile, incomingDirection)) {
+ log("Tile at row:", nextRow, "col:", nextCol, "cannot accept flow from direction:", incomingDirection);
+ continue;
+ }
+ if (nextTile.type === TileFormat.TYPES.END) {
+ log("Found path to end!");
+ return true;
+ }
+ var nextFlowDirection = getFlowDirection(nextTile);
+ toCheck.push([nextRow, nextCol, nextFlowDirection]);
+ }
+ } catch (err) {
+ _iterator.e(err);
+ } finally {
+ _iterator.f();
+ }
+ }
+ log("No valid path found");
+ return false;
+ };
self.selectTile = function (x, y) {
- // Convert screen coordinates to grid coordinates
if (!isPlaying) {
return;
}
- // Adjust coordinate calculation to use grid board position and size
+ // Convert screen coordinates to grid coordinates
var boardX = gridBoard.x - gridBoard.width / 2;
var boardY = gridBoard.y - gridBoard.height / 2;
- var gridX = Math.floor((x - boardX) / tileSize);
- var gridY = Math.floor((y - boardY) / tileSize);
- log("Grid coordinates:", gridX, gridY);
+ var row = Math.floor((y - boardY) / tileSize);
+ var col = Math.floor((x - boardX) / tileSize);
+ log("Grid coordinates - row:", row, "col:", col);
// Check if coordinates are within grid
- if (gridX >= 0 && gridX < self.gridSize && gridY >= 0 && gridY < self.gridSize) {
- var tile = self.grid[gridX] && self.grid[gridX][gridY] ? self.grid[gridX][gridY] : undefined;
- var key = gridX + ',' + gridY;
- // Check if tile exists, is not empty, not start/end, and not fixed
- if (tile && tile.type !== 'empty' && tile.type !== 'start' && tile.type !== 'end' && (!self.levelConfigs[self.currentLevel].fixedTiles || !self.levelConfigs[self.currentLevel].fixedTiles.includes(key))) {
- self.selectedTile = {
- x: gridX,
- y: gridY,
+ if (row >= 0 && row < this.gridSize && col >= 0 && col < this.gridSize) {
+ var tile = this.grid[row][col];
+ // Check if tile exists, is mobile, and not start/end
+ if (tile && !tile.fixed && tile.type !== TileFormat.TYPES.START && tile.type !== TileFormat.TYPES.END) {
+ this.selectedTile = {
+ row: row,
+ col: col,
tile: tile
};
// Check possible moves
- self.checkPossibleMoves();
+ this.checkPossibleMoves();
}
}
};
self.checkPossibleMoves = function () {
- if (!self.selectedTile) {
+ if (!this.selectedTile) {
return;
}
- var x = self.selectedTile.x;
- var y = self.selectedTile.y;
+ var row = this.selectedTile.row;
+ var col = this.selectedTile.col;
var possibleMoves = [];
// Check each direction
// Right
- if (x < self.gridSize - 1 && self.grid[x + 1][y].type === 'empty') {
+ if (col < this.gridSize - 1 && !this.grid[row][col + 1]) {
possibleMoves.push('right');
}
// Left
- if (x > 0 && self.grid[x - 1][y].type === 'empty') {
+ if (col > 0 && !this.grid[row][col - 1]) {
possibleMoves.push('left');
}
// Down
- if (y < self.gridSize - 1 && self.grid[x][y + 1].type === 'empty') {
+ if (row < this.gridSize - 1 && !this.grid[row + 1][col]) {
possibleMoves.push('down');
}
// Up
- if (y > 0 && self.grid[x][y - 1].type === 'empty') {
+ if (row > 0 && !this.grid[row - 1][col]) {
possibleMoves.push('up');
}
- self.selectedTile.possibleMoves = possibleMoves;
+ this.selectedTile.possibleMoves = possibleMoves;
};
self.moveTile = function (direction) {
- if (!isPlaying || !self.selectedTile || !self.selectedTile.possibleMoves.includes(direction)) {
- LK.getSound('tileBlocked').play(); // Play tileBlocked sound
+ if (!isPlaying || !this.selectedTile || !this.selectedTile.possibleMoves.includes(direction)) {
+ LK.getSound('tileBlocked').play();
return;
}
- var oldX = self.selectedTile.x;
- var oldY = self.selectedTile.y;
- var newX = oldX;
- var newY = oldY;
+ var oldRow = this.selectedTile.row;
+ var oldCol = this.selectedTile.col;
+ var newRow = oldRow;
+ var newCol = oldCol;
// Calculate new position
switch (direction) {
case 'right':
- newX++;
+ newCol++;
break;
case 'left':
- newX--;
+ newCol--;
break;
case 'down':
- newY++;
+ newRow++;
break;
case 'up':
- newY--;
+ newRow--;
break;
}
- // Swap tiles
- var movingTile = self.grid[oldX][oldY];
- var emptyTile = self.grid[newX][newY];
// Play tile slide sound
LK.getSound('tileSlide').play();
- // Update grid
- self.grid[newX][newY] = movingTile;
- self.grid[oldX][oldY] = emptyTile;
- // Update positions
- movingTile.updatePosition(newX, newY);
- emptyTile.updatePosition(oldX, oldY);
+ // Move tile
+ var movingTile = this.grid[oldRow][oldCol];
+ this.grid[oldRow][oldCol] = null;
+ this.grid[newRow][newCol] = movingTile;
+ // Update tile position
+ movingTile.updatePosition(newRow, newCol);
// Clear selection
- self.selectedTile = null;
+ this.selectedTile = null;
// Check if puzzle is solved
- if (self.checkWinCondition()) {
- self.isComplete = true;
- self.startWaterFlow();
- LK.getSound('levelWon').play(); // Play levelWon sound
- levelText.setText('Level: ' + self.currentLevel + ' Solved!');
+ if (this.checkWinCondition()) {
+ this.isComplete = true;
+ this.startWaterFlow();
+ LK.getSound('levelWon').play();
+ levelText.setText('Level: ' + currentLevel + ' Solved!');
isPlaying = false;
}
};
self.startWaterFlow = function () {
- log("Starting water flow...");
- if (self.waterFlowing) {
- return;
- }
- self.waterFlowing = true;
- // Find start position
- var startX = -1,
- startY = -1;
- for (var i = 0; i < self.gridSize; i++) {
- for (var j = 0; j < self.gridSize; j++) {
- if (self.grid[i][j].type === 'start') {
- startX = i;
- startY = j;
- break;
- }
- }
- if (startX !== -1) {
- break;
- }
- }
- // Start the flow animation from the start tile
- if (startX !== -1) {
- var startTile = self.grid[startX][startY];
- startTile.flow = true;
- startTile.startFlowTicks = 0;
- // Start valve animation
- if (startTile.valve) {
- startTile.valve.rotationSpeed = 0.1;
- }
- // Start flowing through pipes
- var startDirection = startTile.normalizeRotation(startTile.pipeContainer.rotation);
- self.flowThroughPipe(startX, startY, [], startDirection);
- }
- };
- 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) {
- log("Invalid position.");
- return;
- }
- var key = x + ',' + y;
- if (visited.includes(key)) {
- log("Already visited...");
- return;
- }
- visited.push(key);
- var tile = self.grid[x][y];
- 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.type === 'straightPipeV') {
- if (fromDir === 'down') {
- tile.water.dir = 'bt'; // top to bottom
- } else {
- tile.water.dir = 'tb'; // bottom to top
- }
- }
- }
- 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.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++) {
- 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 () {
- self.selectedTile = null;
- if (self.isComplete) {
- self.currentLevel++;
- } else {
- self.currentLevel = self.currentLevel || 1;
- }
- self.isComplete = false;
- self.waterFlowing = false;
- // Remove previous level tiles
- self.grid.forEach(function (row) {
- row.forEach(function (tile) {
- if (tile) {
- tile.destroy();
- }
- });
- });
- self.initPuzzle();
- };
- self.checkWinCondition = function () {
- // Find start tile properly
var startTile = null;
- var startX = -1,
- startY = -1;
- for (var y = 0; y < self.gridSize; y++) {
- for (var x = 0; x < self.gridSize; x++) {
- if (self.grid[y][x] && self.grid[y][x].type === 'start') {
- startTile = self.grid[y][x];
- startX = x;
- startY = y;
+ var startRow = -1,
+ startCol = -1;
+ for (var row = 0; row < this.gridSize; row++) {
+ for (var col = 0; col < this.gridSize; col++) {
+ if (this.grid[row][col] && this.grid[row][col].type === TileFormat.TYPES.START) {
+ startTile = this.grid[row][col];
+ startRow = row;
+ startCol = col;
break;
}
}
if (startTile) {
@@ -1413,103 +1104,104 @@
if (!startTile) {
log("No start tile found!");
return false;
}
- log("Found start tile at:", startX, startY);
+ log("Found start tile at row:", startRow, "col:", startCol);
var visited = new SimpleSet();
- var toCheck = [[startX, startY, getFlowDirection(startTile)]];
+ var toCheck = [[startRow, startCol, getFlowDirection(startTile)]];
function getFlowDirection(tile) {
- // Returns the direction the water flows out of this tile
var rotation = tile.normalizeRotation(tile.pipeContainer.rotation);
switch (tile.type) {
- case 'start':
+ case TileFormat.TYPES.START:
return rotation;
- case 'cornerPipe':
- // Corner pipe changes flow direction by 90 degrees
+ case TileFormat.TYPES.CORNER:
return (rotation + Math.PI / 2) % (2 * Math.PI);
default:
return rotation;
}
}
function canAcceptFlowFromDirection(tile, incomingDirection) {
- // incomingDirection is the direction the water is coming FROM
- // Need to normalize it to match the tile's rotation
var normalizedIncoming = (incomingDirection + Math.PI) % (2 * Math.PI);
var tileRotation = tile.normalizeRotation(tile.pipeContainer.rotation);
switch (tile.type) {
- case 'start':
+ case TileFormat.TYPES.START:
return false;
- // Start tile only outputs
- case 'end':
- // End tile only accepts flow from its rotated direction
+ case TileFormat.TYPES.END:
var angle = (normalizedIncoming - tileRotation + 2 * Math.PI) % (2 * Math.PI);
return angle < 0.1;
- case 'straightPipeV':
- // Vertical pipe only accepts flow from top (Ï€/2) or bottom (3Ï€/2)
+ case TileFormat.TYPES.VERTICAL:
var angle = Math.abs(normalizedIncoming - Math.PI / 2) % (2 * Math.PI);
return angle < 0.1 || Math.abs(angle - Math.PI) < 0.1;
- case 'straightPipeH':
- // Horizontal pipe only accepts flow from left (Ï€) or right (0)
+ case TileFormat.TYPES.HORIZONTAL:
var angle = normalizedIncoming % (2 * Math.PI);
return angle < 0.1 || Math.abs(angle - Math.PI) < 0.1;
- case 'cornerPipe':
- // Corner pipe accepts flow from two adjacent directions based on rotation
+ case TileFormat.TYPES.CORNER:
var angle = (normalizedIncoming - tileRotation + 2 * Math.PI) % (2 * Math.PI);
return angle < 0.1 || Math.abs(angle - Math.PI / 2) < 0.1;
default:
return false;
}
}
while (toCheck.length > 0) {
- var _toCheck$pop = toCheck.pop(),
- _toCheck$pop2 = _slicedToArray3(_toCheck$pop, 3),
- x = _toCheck$pop2[0],
- y = _toCheck$pop2[1],
- flowDirection = _toCheck$pop2[2];
- var key = x + "," + y;
+ var _toCheck$pop3 = toCheck.pop(),
+ _toCheck$pop4 = _slicedToArray2(_toCheck$pop3, 3),
+ row = _toCheck$pop4[0],
+ col = _toCheck$pop4[1],
+ flowDirection = _toCheck$pop4[2];
+ var key = "".concat(row, ",").concat(col);
if (visited.has(key)) {
continue;
}
visited.add(key);
- log("Checking position:", x, y);
- if (x < 0 || x >= self.gridSize || y < 0 || y >= self.gridSize) {
+ log("Checking position - row:", row, "col:", col);
+ if (row < 0 || row >= this.gridSize || col < 0 || col >= this.gridSize) {
log("Position out of bounds");
continue;
}
- var currentTile = self.grid[y][x];
+ var currentTile = this.grid[row][col];
if (!currentTile) {
log("No tile at position");
continue;
}
var normalizedRotation = currentTile.normalizeRotation(currentTile.pipeContainer.rotation);
- log("Checking tile:", currentTile.type, "with normalized rotation:", normalizedRotation, "at position:", x, y);
- var nextPositions = currentTile.getNextPositions(x, y, currentTile.type, normalizedRotation);
+ log("Checking tile:", currentTile.type, "rotation:", TileFormat.getRotationIndex(normalizedRotation));
+ var nextPositions = currentTile.getNextPositions(col, row, currentTile.type, normalizedRotation);
log("Next positions to check:", nextPositions);
- for (var i = 0; i < nextPositions.length; i++) {
- var _nextPositions$i = _slicedToArray3(nextPositions[i], 2),
- nextX = _nextPositions$i[0],
- nextY = _nextPositions$i[1];
- log("Trying next position:", nextX, nextY);
- if (nextX < 0 || nextX >= self.gridSize || nextY < 0 || nextY >= self.gridSize) {
- log("Next position out of bounds");
- continue;
+ var _iterator2 = _createForOfIteratorHelper(nextPositions),
+ _step2;
+ try {
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
+ var nextPos = _step2.value;
+ var _nextPos3 = nextPos,
+ _nextPos4 = _slicedToArray2(_nextPos3, 2),
+ nextCol = _nextPos4[0],
+ nextRow = _nextPos4[1];
+ log("Trying next position - row:", nextRow, "col:", nextCol);
+ if (nextRow < 0 || nextRow >= this.gridSize || nextCol < 0 || nextCol >= this.gridSize) {
+ log("Next position out of bounds");
+ continue;
+ }
+ var nextTile = this.grid[nextRow][nextCol];
+ if (!nextTile) {
+ log("No tile at next position");
+ continue;
+ }
+ var incomingDirection = Math.atan2(nextRow - row, nextCol - col);
+ if (!canAcceptFlowFromDirection(nextTile, incomingDirection)) {
+ log("Tile at row:", nextRow, "col:", nextCol, "cannot accept flow from direction:", incomingDirection);
+ continue;
+ }
+ if (nextTile.type === TileFormat.TYPES.END) {
+ log("Found path to end!");
+ return true;
+ }
+ var nextFlowDirection = getFlowDirection(nextTile);
+ toCheck.push([nextRow, nextCol, nextFlowDirection]);
}
- var nextTile = self.grid[nextY][nextX];
- if (!nextTile) {
- log("No tile at next position");
- continue;
- }
- var incomingDirection = Math.atan2(nextY - y, nextX - x);
- if (!canAcceptFlowFromDirection(nextTile, incomingDirection)) {
- log("Tile at", nextX, nextY, "cannot accept flow from direction", incomingDirection);
- continue;
- }
- if (nextTile.type === 'end') {
- log("Found path to end!");
- return true;
- }
- var nextFlowDirection = getFlowDirection(nextTile);
- toCheck.push([nextX, nextY, nextFlowDirection]);
+ } catch (err) {
+ _iterator2.e(err);
+ } finally {
+ _iterator2.f();
}
}
log("No valid path found");
return false;
@@ -1657,9 +1349,9 @@
growGrass.x = 2048 / 2 + 20;
growGrass.y = 2732 / 2;
middleLayer.addChild(growGrass);
// Initialize game assets and variables
- puzzleManager = new PuzzleManager();
+ puzzleManager = new PuzzleManager(game);
// Initialize level text
levelText = new Text2("Level 1", {
size: 100,
fill: 0xFFFFFF
@@ -1725,9 +1417,9 @@
levelText.text = "Level 1";
// Reset puzzle manager for new round
console.log("Entering New Round State");
if (puzzleManager) {
- puzzleManager.reset();
+ puzzleManager.initPuzzle(levelConfigs[1]);
}
// Show gridBoard
gridBoard.visible = true;
// After a short delay, transition to PLAYING state
@@ -1748,9 +1440,15 @@
}
function handlePlayingLoop() {
// Update game logic
if (puzzleManager) {
- puzzleManager.update();
+ puzzleManager.grid.forEach(function (row) {
+ row.forEach(function (tile) {
+ if (tile) {
+ tile.update();
+ }
+ });
+ });
// Check if level is complete
if (puzzleManager.isComplete) {
changeGameState(GAME_STATE.SCORE);
}
@@ -1789,9 +1487,15 @@
}
function handleScoreLoop() {
// Update any score animations
if (puzzleManager) {
- puzzleManager.update();
+ puzzleManager.grid.forEach(function (row) {
+ row.forEach(function (tile) {
+ if (tile) {
+ tile.update();
+ }
+ });
+ });
}
}
function cleanScoreState() {
levelText.visible = false;
@@ -1899,5 +1603,122 @@
if (waterDrops[i].visible) {
waterDrops[i].update();
}
}
+}
+// Tile Format Utilities
+var TileFormat = {
+ // Constants
+ FIXED: 'F',
+ MOBILE: 'M',
+ TYPES: {
+ START: 'S',
+ END: 'E',
+ VERTICAL: 'V',
+ HORIZONTAL: 'H',
+ CORNER: 'C',
+ CROSS: 'X',
+ BLANK: 'B'
+ },
+ // Parse a tile string into its components
+ parse: function parse(tileStr) {
+ if (!tileStr || tileStr === "") {
+ return null;
+ }
+ var parts = tileStr.split('-');
+ if (parts.length !== 3) {
+ console.error("Invalid tile format:", tileStr);
+ return null;
+ }
+ return {
+ fixed: parts[0] === this.FIXED,
+ type: parts[1],
+ rotation: parseInt(parts[2]) * (Math.PI / 2) // Convert to radians
+ };
+ },
+ // Create a tile string from components
+ create: function create(fixed, type, rotationIndex) {
+ return "".concat(fixed ? this.FIXED : this.MOBILE, "-").concat(type, "-").concat(rotationIndex);
+ },
+ // Convert old tile type to new format
+ convertOldType: function convertOldType(oldType) {
+ switch (oldType) {
+ case 'start':
+ return this.TYPES.START;
+ case 'end':
+ return this.TYPES.END;
+ case 'straightPipeV':
+ return this.TYPES.VERTICAL;
+ case 'straightPipeH':
+ return this.TYPES.HORIZONTAL;
+ case 'cornerPipe':
+ return this.TYPES.CORNER;
+ default:
+ return this.TYPES.BLANK;
+ }
+ },
+ // Convert rotation in radians to index (0-3)
+ getRotationIndex: function getRotationIndex(radians) {
+ if (typeof radians !== 'number') {
+ return 0;
+ }
+ return Math.round(radians % (2 * Math.PI) / (Math.PI / 2)) % 4;
+ },
+ // Convert old level format to new format
+ convertOldLevel: function convertOldLevel(oldLevel) {
+ var newGrid = [];
+ for (var row = 0; row < 4; row++) {
+ newGrid[row] = [];
+ for (var col = 0; col < 4; col++) {
+ var oldTile = oldLevel.tiles[row][col];
+ if (!oldTile) {
+ newGrid[row][col] = "";
+ continue;
+ }
+ var isFixed = oldLevel.fixedTiles && oldLevel.fixedTiles.includes("".concat(row, ",").concat(col));
+ var type = this.convertOldType(oldTile);
+ var rotation = oldLevel.rotations["".concat(row, ",").concat(col)] || 'up';
+ var rotationIndex = this.getRotationIndex(rotation);
+ newGrid[row][col] = this.create(isFixed, type, rotationIndex);
+ }
+ }
+ return newGrid;
+ }
+};
+// Convert existing levels to new format
+var levelConfigs = {
+ 1: [["F-S-0", "", "", ""], ["F-V-0", "", "", ""], ["F-V-0", "", "M-H-0", ""], ["F-C-3", "F-H-0", "", "F-E-0"]],
+ 2: [["", "M-H-0", "F-E-1", ""], ["", "F-C-1", "F-H-0", ""], ["", "", "", ""], ["F-S-0", "F-V-0", "", ""]],
+ 3: [["F-C-2", "", "", "M-V-0"], ["F-C-1", "F-E-1", "", "F-H-0"], ["", "", "", ""], ["", "", "F-V-0", "F-S-1"]],
+ 4: [["F-S-0", "F-H-0", "M-C-0", ""], ["", "", "F-V-0", ""], ["", "M-H-0", "F-C-3", ""], ["", "", "F-V-0", "F-E-0"]],
+ 5: [["", "", "F-S-0", ""], ["M-V-0", "F-C-1", "F-H-0", "M-C-0"], ["F-V-0", "", "", "F-V-0"], ["F-E-1", "F-H-0", "M-H-0", "F-C-3"]]
+};
+// Update tile creation to use new format
+function createTile(tileStr, row, col) {
+ if (!tileStr || tileStr === "") {
+ return null;
+ }
+ var tileData = TileFormat.parse(tileStr);
+ if (!tileData) {
+ return null;
+ }
+ var tile = new Tile();
+ tile.type = tileData.type;
+ tile.fixed = tileData.fixed;
+ tile.gridRow = row;
+ tile.gridCol = col;
+ // Create base tile graphics
+ tile.baseTile = tile.attachAsset(tile.fixed ? 'baseTile' : 'baseMobileTile', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: tileSize,
+ height: tileSize,
+ tint: 0xFFFFFF
+ });
+ // Set type and create pipe graphics
+ tile.setType(tileData.type, row, col);
+ // Set initial rotation
+ tile.setRotation(tileData.rotation);
+ // Set position
+ tile.updatePosition(row, col);
+ return tile;
}
\ No newline at end of file
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