User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 167
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 189
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 189
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 185
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 181
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 181
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 177
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 176
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 173
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 172
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return typeof o;' Line Number: 172
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;' Line Number: 169
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;' Line Number: 165
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading '0')' in or related to this line: 'return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;' Line Number: 165
User prompt
Please fix the bug: 'ReferenceError: _typeof is not defined' in or related to this line: 'if (typeof playerPos !== "undefined" && playerPos !== null && _typeof(playerPos) === "object" && "x" in playerPos && "y" in playerPos && typeof playerPos.x === "number" && typeof playerPos.y === "number") {' Line Number: 1309
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'cell.isExit = x === exitPos.x && y === exitPos.y;' Line Number: 395
User prompt
oyuna eklediğimşiz tüm değişiklikleri kaşdır en sade haline döndür
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'if (typeof o !== "undefined" && o !== null && typeof o === "object" && typeof o.length === "number") {' Line Number: 440
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'if (typeof o !== "undefined" && o !== null && typeof o === "object" && typeof o.length === "number") {' Line Number: 440
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'if (typeof o !== "undefined" && o !== null && typeof o === "object" && typeof o.length === "number") {' Line Number: 440
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'if (typeof o !== "undefined" && o !== null && typeof o === "object" && typeof o.length === "number") {' Line Number: 440
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'if (typeof o !== "undefined" && o !== null && typeof o === "object" && typeof o.length === "number") {' Line Number: 440
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'if (typeof o !== "undefined" && o !== null && typeof o === "object" && typeof o.length === "number") {' Line Number: 440
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'if (typeof o !== "undefined" && o !== null && typeof o === "object" && typeof o.length === "number") {' Line Number: 440
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Dice visual var Dice = Container.expand(function () { var self = Container.call(this); self.value = 1; self.bg = self.attachAsset('diceBg', { width: diceSize, height: diceSize, color: 0xffffff, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.text = new Text2('1', { size: 160, fill: 0x222222 }); self.text.anchor.set(0.5, 0.5); self.addChild(self.text); self.setValue = function (v) { self.value = v; self.text.setText(v + ''); }; // Animate dice roll self.rollAnim = function (finalValue, cb) { var rollTimes = 12; var i = 0; var _roll = function roll() { if (i < rollTimes) { var val = 1 + Math.floor(Math.random() * 6); self.setValue(val); i++; LK.setTimeout(_roll, 40 + i * 10); } else { self.setValue(finalValue); if (cb) { cb(); } } }; _roll(); }; return self; }); // GridCell: Represents a single cell in the grid var GridCell = Container.expand(function () { var self = Container.call(this); // Properties self.gridX = 0; self.gridY = 0; self.value = 1; // 1-6 self.hasBomb = false; self.isExit = false; self.isRevealed = false; // Visuals self.bg = self.attachAsset('cellBg', { width: cellSize - 8, height: cellSize - 8, color: 0xeeeeee, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.valueText = new Text2('', { size: 100, fill: 0x222222 }); self.valueText.anchor.set(0.5, 0.5); self.addChild(self.valueText); // Reveal cell (show value, bomb, or exit) self.reveal = function () { self.isRevealed = true; if (self.isExit) { self.bg.color = 0x44bb44; self.valueText.setText('Exit'); self.valueText.setStyle({ fill: 0xFFFFFF }); } else if (self.hasBomb) { self.bg.color = 0xbb2222; self.valueText.setText('💣'); self.valueText.setStyle({ fill: 0xFFFFFF }); } else { self.bg.color = 0xcccccc; self.valueText.setText(self.value + ''); self.valueText.setStyle({ fill: 0x222222 }); } }; // Hide cell (for unrevealed state) self.hide = function () { self.isRevealed = false; self.bg.color = 0xeeeeee; self.valueText.setText(self.value + ''); // Always show the cell value, even when hidden }; // Highlight for possible move self.highlight = function () { self.bg.color = 0x4488ff; }; // Remove highlight self.unhighlight = function () { if (!self.isRevealed) { self.bg.color = 0xeeeeee; } else if (self.isExit) { self.bg.color = 0x44bb44; } else if (self.hasBomb) { self.bg.color = 0xbb2222; } else { self.bg.color = 0xcccccc; } }; return self; }); // Player token var PlayerToken = Container.expand(function () { var self = Container.call(this); self.token = self.attachAsset('playerToken', { width: cellSize * 0.85, height: cellSize * 0.85, color: 0x2266cc, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x800080 }); /**** * Game Code ****/ // No per-frame logic needed function _typeof2(o) { "@babel/helpers - typeof"; // Defensive: avoid reading properties of undefined/null if (o === undefined || o === null) return typeof o; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { return typeof o; } if (typeof Symbol === "function" && o && o.constructor === Symbol && o !== Symbol.prototype) { return "symbol"; } // Defensive: avoid reading properties of undefined (reading '0') return typeof o; } function _typeof(o) { // Defensive: avoid reading properties of undefined/null if (o === undefined || o === null) return _typeof2(o); if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { return _typeof2(o); } if (typeof Symbol === "function" && o && o.constructor === Symbol && o !== Symbol.prototype) { return "symbol"; } return _typeof2(o); } var gridSize = 8; var cellSize = Math.floor(2000 / gridSize); // Increased cell size for better visibility var gridOffsetX = Math.floor((2048 - cellSize * gridSize) / 2); var gridOffsetY = 250; // Move grid up a bit to fit larger elements var diceSize = 340; // Larger dice // --- State --- var grid = []; var playerPos = { x: 0, y: 0 }; var exitPos = { x: 0, y: 0 }; var playerToken = null; var dice = null; var canRoll = true; var possibleMoves = []; var gameOver = false; var moveCount = 0; var bombCount = 10; // Number of bombs // --- Timer for endgame after 15 moves --- var moveLimit = 15; var endgameCountdown = 30; // seconds var endgameTimer = null; var endgameTimerText = null; var endgameTimerInterval = null; var endgameTimerActive = false; // --- GUI --- // --- Score Bar (Para Sayaç Barı) --- var score = 0; var sayaBarWidth = 500; var sayaBarHeight = 38; var sayaBarBg = LK.getAsset('cellBg', { width: sayaBarWidth, height: sayaBarHeight, color: 0x222222, shape: 'box', anchorX: 0, anchorY: 0.5, alpha: 0.7 }); sayaBarBg.x = 124; // leave 100px for menu, 24px margin sayaBarBg.y = 90; // moved slightly lower from 60 to 90 sayaBarBg.zIndex = 10000; LK.gui.top.addChild(sayaBarBg); var sayaBarFill = LK.getAsset('cellBg', { width: 0, height: sayaBarHeight - 6, color: 0x22cc44, shape: 'box', anchorX: 0, anchorY: 0.5, alpha: 0.95 }); sayaBarFill.x = sayaBarBg.x + 3; sayaBarFill.y = sayaBarBg.y; sayaBarFill.zIndex = 10001; LK.gui.top.addChild(sayaBarFill); var sayaBarText = new Text2('0 / 100', { size: 36, fill: "#fff", font: "bold", align: "center" }); sayaBarText.anchor.set(0.5, 0.5); sayaBarText.x = sayaBarBg.x + sayaBarWidth / 2; sayaBarText.y = sayaBarBg.y; sayaBarText.zIndex = 10002; LK.gui.top.addChild(sayaBarText); function updateSayaBar(newScore) { sayaBarText.setText(newScore + ' / 100'); var targetWidth = Math.max(0, Math.min(1, newScore / 100)) * (sayaBarWidth - 6); tween(sayaBarFill, { width: targetWidth }, { duration: 400, easing: tween.cubicOut }); } // --- Heart Bar (Life Bar) --- var maxHearts = 2; var currentHearts = 1; var heartBar = []; var heartBarX = 2048 - 220; var heartBarY = 120; function drawHeartBar() { // Remove old hearts for (var i = 0; i < heartBar.length; i++) { if (heartBar[i].parent) { LK.gui.top.removeChild(heartBar[i]); } } heartBar = []; for (var i = 0; i < maxHearts; i++) { var heart = LK.getAsset('cellBg', { width: 60, height: 60, color: i < currentHearts ? 0xff3366 : 0x888888, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, alpha: 0.93 }); heart.x = heartBarX + i * 70; heart.y = heartBarY; heart.zIndex = 10010 + i; LK.gui.top.addChild(heart); heartBar.push(heart); } } drawHeartBar(); // --- Animated +10 floating text --- function showScoreAnim(x, y, text) { var plusText = new Text2(text || '+$20', { size: 44, fill: 0x22CC44, font: "bold", align: "center" }); plusText.anchor.set(0.5, 0.5); plusText.x = x; plusText.y = y; plusText.alpha = 1; plusText.zIndex = 10010; game.addChild(plusText); tween(plusText, { y: y - 90, alpha: 0 }, { duration: 700, easing: tween.cubicOut, onComplete: function onComplete() { if (plusText.parent) { plusText.parent.removeChild(plusText); } } }); } var infoText = new Text2('', { size: 70, fill: 0x333333 }); infoText.anchor.set(0.5, 0); LK.gui.top.addChild(infoText); // Timer text (hidden by default) endgameTimerText = new Text2('', { size: 80, fill: "#fff", font: "bold", align: "center" }); endgameTimerText.anchor.set(0, 0.5); // Will position next to dice after dice is created endgameTimerText.visible = false; game.addChild(endgameTimerText); // Helper to start the 20s countdown function startEndgameTimer() { if (endgameTimerActive) { return; } endgameTimerActive = true; endgameCountdown = 30; endgameTimerText.visible = true; endgameTimerText.setText('Time: 30'); // Show timer text on screen when countdown starts endgameTimerText.visible = true; endgameTimerInterval = LK.setInterval(function () { if (gameOver) { LK.clearInterval(endgameTimerInterval); endgameTimerText.visible = false; return; } endgameCountdown--; endgameTimerText.setText('Time: ' + endgameCountdown); if (endgameCountdown <= 0) { LK.clearInterval(endgameTimerInterval); endgameTimerText.visible = false; gameOver = true; LK.effects.flashScreen(0xbb2222, 900); LK.setTimeout(function () { LK.showGameOver(); }, 900); infoText.setText('Time is up! You lost.'); } }, 1000); } // Helper to stop the timer (on win/lose) function stopEndgameTimer() { if (endgameTimerInterval) { LK.clearInterval(endgameTimerInterval); endgameTimerInterval = null; } endgameTimerText.visible = false; endgameTimerActive = false; } // --- Functions --- // Generate grid with random values, bombs, and exit function generateGrid() { grid = []; // Place bombs var bombCells = []; while (bombCells.length < bombCount) { var bx = Math.floor(Math.random() * gridSize); var by = Math.floor(Math.random() * gridSize); if (bx === 0 && by === 0 || bombCells.some(function (b) { return b.x === bx && b.y === by; })) { continue; } bombCells.push({ x: bx, y: by }); } // Place exit do { exitPos.x = Math.floor(Math.random() * gridSize); exitPos.y = Math.floor(Math.random() * gridSize); } while (exitPos.x === 0 && exitPos.y === 0 || bombCells.some(function (b) { return b.x === exitPos.x && b.y === exitPos.y; })); // Build grid for (var y = 0; y < gridSize; y++) { var row = []; for (var x = 0; x < gridSize; x++) { var cell = new GridCell(); cell.gridX = x; cell.gridY = y; cell.x = gridOffsetX + x * cellSize + cellSize / 2; cell.y = gridOffsetY + y * cellSize + cellSize / 2; cell.value = 1 + Math.floor(Math.random() * 6); cell.hasBomb = bombCells.some(function (b) { return b.x === x && b.y === y; }); cell.isExit = typeof exitPos !== "undefined" && exitPos !== null && typeof exitPos.x === "number" && typeof exitPos.y === "number" ? x === exitPos.x && y === exitPos.y : false; if (cell.isExit) { cell.value = 6; // Exit cell always has value 6 cell.reveal(); // Always show exit cell } else { cell.hide(); } game.addChild(cell); row.push(cell); } grid.push(row); } } // Get neighbors of (x, y) function getNeighbors(x, y) { var neighbors = []; for (var dx = -1; dx <= 1; dx++) { for (var dy = -1; dy <= 1; dy++) { if (dx === 0 && dy === 0) { continue; } var nx = x + dx; var ny = y + dy; if (nx >= 0 && nx < gridSize && ny >= 0 && ny < gridSize) { neighbors.push(grid[ny][nx]); } } } return neighbors; } // Highlight possible moves for current dice value // --- Arrow UI for multiple moves --- var moveArrows = []; function clearMoveArrows() { for (var i = 0; i < moveArrows.length; i++) { if (moveArrows[i] && moveArrows[i].parent) { moveArrows[i].parent.removeChild(moveArrows[i]); } } moveArrows = []; } function createArrowForCell(cell, idx) { // Use a yellow box as arrow for now, can be replaced with a real arrow asset var arrow = LK.getAsset('diceTap', { width: cellSize * 0.35, height: cellSize * 0.35, color: 0xfad82b, anchorX: 0.5, anchorY: 0.5, alpha: 0.85 }); arrow.x = cell.x; arrow.y = cell.y; arrow.zIndex = 1000 + idx; arrow.down = function (x, y, obj) { if (!canRoll && !gameOver) { movePlayerTo(cell); clearMoveArrows(); } }; game.addChild(arrow); moveArrows.push(arrow); } function highlightPossibleMoves(diceValue) { possibleMoves = []; clearMoveArrows(); var neighbors = getNeighbors(playerPos.x, playerPos.y); for (var i = 0; i < neighbors.length; i++) { var cell = neighbors[i]; if (!cell.isRevealed && cell.value === diceValue) { cell.highlight(); possibleMoves.push(cell); } } // If only one possible move, auto-move if (possibleMoves.length === 1) { // Delay slightly for UX LK.setTimeout(function () { if (!canRoll && !gameOver) { movePlayerTo(possibleMoves[0]); clearMoveArrows(); } }, 350); } else if (possibleMoves.length > 1) { // Show arrows for each possible move for (var i = 0; i < possibleMoves.length; i++) { createArrowForCell(possibleMoves[i], i); } } } // Remove all highlights function clearHighlights() { for (var y = 0; y < gridSize; y++) { for (var x = 0; x < gridSize; x++) { grid[y][x].unhighlight(); // Always keep exit cell revealed if (grid[y][x].isExit) { grid[y][x].reveal(); } } } clearMoveArrows(); } // Move player to cell function movePlayerTo(cell) { playerPos.x = cell.gridX; playerPos.y = cell.gridY; moveCount++; // --- Score logic: +20 per cell moved --- if (score < 100) { score += 20; if (score > 100) { score = 100; } if (score === 100) { // Bar is full, but do not reset here, only allow card to be used again if needed cardRevealBombsBtn.alpha = 1; cardRevealBombsBtn.setText('Bombaları Göster'); infoText.setText('You earned $100! Card is available again.'); } } updateSayaBar(score); // --- Money bundle animation: animate a money bundle from the cell to the score bar --- (function animateMoneyBundle() { // Create a money bundle asset (use cellBg as a green box for now) var moneyBundle = LK.getAsset('cellBg', { width: cellSize * 0.38, height: cellSize * 0.24, color: 0x22cc44, shape: 'box', anchorX: 0.5, anchorY: 0.5, alpha: 1, zIndex: 10010 }); moneyBundle.x = cell.x; moneyBundle.y = cell.y - cellSize * 0.18; game.addChild(moneyBundle); // Animate directly to the score bar and disappear var barTargetX = sayaBarBg.x + sayaBarBg.width * 0.5; var barTargetY = sayaBarBg.y; // Convert GUI coordinates to game coordinates for smooth animation var guiToGameX = barTargetX; var guiToGameY = barTargetY + 60; // visually align with bar tween(moneyBundle, { x: guiToGameX, y: guiToGameY, scaleX: 0.7, scaleY: 0.7, alpha: 0.0 }, { duration: 600, easing: tween.cubicInOut, onComplete: function onComplete() { if (moneyBundle.parent) { moneyBundle.parent.removeChild(moneyBundle); } } }); })(); updateScoreBar(score); showScoreAnim(cell.x, cell.y - cellSize * 0.35, '+$20'); clearMoveArrows(); // --- Extra card use if score bar reaches 100 (only once) --- // (No longer needed, handled above. Remove this block.) tween(playerToken, { x: cell.x, y: cell.y }, { duration: 220, easing: tween.cubicOut }); cell.reveal(); // Start endgame timer after 20th move if (moveCount === moveLimit) { startEndgameTimer(); } if (cell.hasBomb) { if (currentHearts > 1) { // Use shield instead of dying currentHearts = 1; drawHeartBar(); infoText.setText('You hit a bomb! Shield used, 1 life left.'); // Animate heart bar for (var i = 0; i < heartBar.length; i++) { tween(heartBar[i], { scaleX: 1.3, scaleY: 1.3 }, { duration: 180, easing: tween.cubicOut, onComplete: function (h) { return function () { tween(h, { scaleX: 1, scaleY: 1 }, { duration: 120, easing: tween.cubicIn }); }; }(heartBar[i]) }); } // Reveal the bomb cell, but do not end the game cell.reveal(); LK.effects.flashScreen(0xff0000, 600); // Remove highlights and allow next move canRoll = true; clearHighlights(); grid[exitPos.y][exitPos.x].reveal(); return; } stopEndgameTimer(); // --- Shatter animation for the bomb cell --- var shatterPieces = []; var pieceCount = 12 + Math.floor(Math.random() * 4); for (var i = 0; i < pieceCount; i++) { var angle = Math.PI * 2 * (i / pieceCount) + Math.random() * 0.2; var dist = cellSize * (0.7 + Math.random() * 0.7); var px = cell.x + Math.cos(angle) * (cellSize * 0.08 + Math.random() * cellSize * 0.08); var py = cell.y + Math.sin(angle) * (cellSize * 0.08 + Math.random() * cellSize * 0.08); var piece = LK.getAsset('cellBg', { width: cellSize * (0.18 + Math.random() * 0.13), height: cellSize * (0.18 + Math.random() * 0.13), color: 0xbb2222, shape: 'box', anchorX: 0.5, anchorY: 0.5, alpha: 0.92 }); piece.x = px; piece.y = py; piece.zIndex = 10000 + i; game.addChild(piece); shatterPieces.push(piece); // Animate each piece flying outward, rotating and fading (function (p, a, d) { var tx = cell.x + Math.cos(a) * d; var ty = cell.y + Math.sin(a) * d; var rot = (Math.random() - 0.5) * Math.PI * 1.2; tween(p, { x: tx, y: ty, rotation: rot, alpha: 0 }, { duration: 650 + Math.random() * 250, easing: tween.cubicOut, onComplete: function onComplete() { if (p.parent) { p.parent.removeChild(p); } } }); })(piece, angle, dist); } // Hide the cell's background and valueText for the shatter effect cell.bg.visible = false; cell.valueText.visible = false; // --- Black smoke after shatter --- LK.setTimeout(function () { var postSmoke = LK.getAsset('cellBg', { width: cellSize * 1.5, height: cellSize * 1.5, color: 0x111111, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, alpha: 0.55 }); postSmoke.x = cell.x; postSmoke.y = cell.y; postSmoke.zIndex = 9997; game.addChild(postSmoke); tween(postSmoke, { scaleX: 2.8, scaleY: 2.8, alpha: 0 }, { duration: 1200, easing: tween.cubicOut, onComplete: function onComplete() { if (postSmoke.parent) { postSmoke.parent.removeChild(postSmoke); } } }); }, 320); // --- Existing explosion and smoke/particle effects --- var explosion = LK.getAsset('cellBg', { width: cellSize * 1.1, height: cellSize * 1.1, color: 0xffe066, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, alpha: 0.85 }); explosion.x = cell.x; explosion.y = cell.y; explosion.zIndex = 9999; game.addChild(explosion); // Black smoke effect (grows and fades) var smoke = LK.getAsset('cellBg', { width: cellSize * 1.2, height: cellSize * 1.2, color: 0x111111, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, alpha: 0.45 }); smoke.x = cell.x; smoke.y = cell.y; smoke.zIndex = 9998; game.addChild(smoke); tween(smoke, { scaleX: 2.5, scaleY: 2.5, alpha: 0 }, { duration: 900, easing: tween.cubicOut, onComplete: function onComplete() { if (smoke.parent) { smoke.parent.removeChild(smoke); } } }); // Particle burst (black debris) for (var i = 0; i < 16; i++) { var angle = Math.PI * 2 * (i / 16) + Math.random() * 0.2; var dist = cellSize * (0.7 + Math.random() * 0.7); var px = cell.x + Math.cos(angle) * 10; var py = cell.y + Math.sin(angle) * 10; var particle = LK.getAsset('cellBg', { width: 22 + Math.random() * 16, height: 22 + Math.random() * 16, color: 0x222222, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, alpha: 0.7 + Math.random() * 0.2 }); particle.x = px; particle.y = py; particle.zIndex = 9999; game.addChild(particle); (function (p, a, d) { tween(p, { x: cell.x + Math.cos(a) * d, y: cell.y + Math.sin(a) * d, alpha: 0, scaleX: 0.7 + Math.random() * 0.5, scaleY: 0.7 + Math.random() * 0.5 }, { duration: 700 + Math.random() * 300, easing: tween.cubicOut, onComplete: function onComplete() { if (p.parent) { p.parent.removeChild(p); } } }); })(particle, angle, dist); } // Animate: grow and fade out tween(explosion, { scaleX: 2.2, scaleY: 2.2, alpha: 0 }, { duration: 600, easing: tween.cubicOut, onComplete: function onComplete() { if (explosion.parent) { explosion.parent.removeChild(explosion); } } }); LK.effects.flashScreen(0xff0000, 900); gameOver = true; LK.setTimeout(function () { LK.showGameOver(); }, 900); infoText.setText('Bomba! Oyun bitti.'); return; } if (cell.isExit) { stopEndgameTimer(); LK.effects.flashScreen(0x44bb44, 900); gameOver = true; LK.setTimeout(function () { LK.showYouWin(); }, 900); infoText.setText('Congratulations! You reached the exit.'); return; } infoText.setText('Move: ' + moveCount); canRoll = true; clearHighlights(); // Always keep exit cell revealed grid[exitPos.y][exitPos.x].reveal(); } // Handle tap on a cell function onCellDown(x, y, obj) { if (!canRoll && !gameOver) { // If arrows are present, only allow move via arrow tap if (moveArrows.length > 0) { return; } // Only allow move if the tapped cell is in possibleMoves (highlighted and matches dice) for (var i = 0; i < possibleMoves.length; i++) { if (possibleMoves[i] === obj) { movePlayerTo(obj); break; } } } } // Roll the dice function rollDice() { if (!canRoll || gameOver) { return; } canRoll = false; // Play dice roll sound LK.getSound('diceRoll').play(); var diceValue = 1 + Math.floor(Math.random() * 6); dice.rollAnim(diceValue, function () { highlightPossibleMoves(diceValue); // Check if exit is adjacent and matches dice value var exitIsPossible = false; var exitCell = null; var neighbors = getNeighbors(playerPos.x, playerPos.y); for (var i = 0; i < neighbors.length; i++) { if (neighbors[i].isExit) { exitCell = neighbors[i]; if (neighbors[i].value === diceValue) { exitIsPossible = true; break; } } } // If exit is adjacent and dice is 6, win immediately (regardless of exit cell value) if (exitCell && diceValue === 6) { stopEndgameTimer(); exitCell.reveal(); LK.effects.flashScreen(0x44bb44, 900); gameOver = true; LK.setTimeout(function () { LK.showYouWin(); }, 900); infoText.setText('Rolled a 6! You reached the exit.'); return; } if (possibleMoves.length === 0 && !exitIsPossible) { // No moves and exit is not possible, allow unlimited reroll canRoll = true; infoText.setText('No moves! You can roll the dice again.'); } else { infoText.setText('Move: ' + moveCount + ' | Dice: ' + diceValue); } }); } // --- Setup --- // Create grid, player, dice generateGrid(); // Reveal start cell playerPos.x = 0; playerPos.y = 0; grid[0][0].reveal(); // Player token playerToken = new PlayerToken(); playerToken.x = grid[0][0].x; playerToken.y = grid[0][0].y; game.addChild(playerToken); // --- Double-tap logic for shield (second life) --- var lastTapTime = 0; var tapCount = 0; var shieldUsed = false; // Only allow shield to be used once per game playerToken.down = function (x, y, obj) { if (gameOver) { return; } var now = Date.now(); if (now - lastTapTime < 400) { tapCount++; } else { tapCount = 1; } lastTapTime = now; // Double-tap: activate shield (second life) if (tapCount === 2) { tapCount = 0; if (shieldUsed) { infoText.setText('Shield can only be used once per game!'); return; } if (currentHearts === 1) { currentHearts = 2; shieldUsed = true; drawHeartBar(); infoText.setText('Shield activated! You now have 2 lives.'); // Animate hearts for (var i = 0; i < heartBar.length; i++) { tween(heartBar[i], { scaleX: 1.3, scaleY: 1.3 }, { duration: 180, easing: tween.cubicOut, onComplete: function (h) { return function () { tween(h, { scaleX: 1, scaleY: 1 }, { duration: 120, easing: tween.cubicIn }); }; }(heartBar[i]) }); } } else { infoText.setText('You already have 2 lives!'); } return; } // Single tap: use bomb reveal card if (cardRevealBombsUsed) { return; } cardRevealBombsUsed = true; cardRevealBombsBtn.setText('Kullanıldı'); cardRevealBombsBtn.alpha = 0.5; // Reset score to 0 when bomb reveal card is used via playerToken score = 0; updateSayaBar(score); showAllBombsTemporarily(); }; // Dice dice = new Dice(); dice.x = 2048 / 2; dice.y = gridOffsetY + cellSize * gridSize + diceSize / 2 + 60; game.addChild(dice); // Position the countdown timer to the right of the dice endgameTimerText.x = dice.x + diceSize / 2 + 60; endgameTimerText.y = dice.y; // --- Saniye Bar (Second Bar) --- // Circular clock-style saniye bar, larger and next to the dice var saniyeBarRadius = 80; var saniyeBarThickness = 22; var saniyeBarCenterX = dice.x + diceSize / 2 + 110; var saniyeBarCenterY = dice.y + 10; // Background circle (dark) var saniyeBarBg = LK.getAsset('cellBg', { width: saniyeBarRadius * 2 + saniyeBarThickness, height: saniyeBarRadius * 2 + saniyeBarThickness, color: 0x222222, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, alpha: 0.7 }); saniyeBarBg.x = saniyeBarCenterX; saniyeBarBg.y = saniyeBarCenterY; saniyeBarBg.zIndex = 10000; game.addChild(saniyeBarBg); // Foreground "fill" arc (white, will be animated by scaling) var saniyeBarFill = LK.getAsset('cellBg', { width: saniyeBarRadius * 2, height: saniyeBarRadius * 2, color: 0xffffff, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, alpha: 0.93 }); saniyeBarFill.x = saniyeBarCenterX; saniyeBarFill.y = saniyeBarCenterY; saniyeBarFill.zIndex = 10001; game.addChild(saniyeBarFill); // Mask for the fill to create a "pie" effect var saniyeBarMask = LK.getAsset('cellBg', { width: saniyeBarRadius * 2, height: saniyeBarRadius * 2, color: 0xffffff, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, alpha: 1 }); saniyeBarMask.x = saniyeBarCenterX; saniyeBarMask.y = saniyeBarCenterY; saniyeBarMask.zIndex = 10002; game.addChild(saniyeBarMask); saniyeBarFill.mask = saniyeBarMask; // Inner circle to create the "thickness" (hollow center) var saniyeBarInner = LK.getAsset('cellBg', { width: (saniyeBarRadius - saniyeBarThickness) * 2, height: (saniyeBarRadius - saniyeBarThickness) * 2, color: 0x800080, shape: 'ellipse', anchorX: 0.5, anchorY: 0.5, alpha: 1 }); saniyeBarInner.x = saniyeBarCenterX; saniyeBarInner.y = saniyeBarCenterY; saniyeBarInner.zIndex = 10003; game.addChild(saniyeBarInner); // Timer text in the center var saniyeBarText = new Text2('0s', { size: 48, fill: "#fff", font: "bold", align: "center" }); saniyeBarText.anchor.set(0.5, 0.5); saniyeBarText.x = saniyeBarCenterX; saniyeBarText.y = saniyeBarCenterY; saniyeBarText.zIndex = 10004; game.addChild(saniyeBarText); var saniyeBarSeconds = 0; var saniyeBarInterval = null; // Helper to update the mask to show a "pie" slice for the current seconds function updateSaniyeBarMask(seconds) { // 30 seconds = full circle var percent = Math.max(0, Math.min(1, seconds / 30)); // The mask is a full ellipse, but we want to show only a "pie" slice // We'll fake this by scaling the mask's Y axis to the percent (not a true pie, but visually works) saniyeBarMask.scaleY = percent; saniyeBarMask.y = saniyeBarCenterY + saniyeBarRadius * (1 - percent); } function startSaniyeBar() { saniyeBarSeconds = 0; saniyeBarText.setText('0s'); updateSaniyeBarMask(0); if (saniyeBarInterval) { LK.clearInterval(saniyeBarInterval); } saniyeBarInterval = LK.setInterval(function () { saniyeBarSeconds++; saniyeBarText.setText(saniyeBarSeconds + 's'); updateSaniyeBarMask(saniyeBarSeconds); // Optionally reset after 30s, or keep filling if (saniyeBarSeconds >= 30) { // Optionally reset or stop // LK.clearInterval(saniyeBarInterval); // saniyeBarInterval = null; // updateSaniyeBarMask(30); } }, 1000); } function stopSaniyeBar() { if (saniyeBarInterval) { LK.clearInterval(saniyeBarInterval); } saniyeBarInterval = null; } // Start saniye bar when info popup is closed (game starts) if (typeof infoPopup !== "undefined" && infoPopup && typeof infoPopup.down === "function") { var _oldInfoPopupDown2 = infoPopup.down; infoPopup.down = function (x, y, obj) { if (_oldInfoPopupDown2) { _oldInfoPopupDown2(x, y, obj); } startSaniyeBar(); }; infoPopupBg.down = infoPopup.down; infoPopupText.down = infoPopup.down; } // Stop saniye bar on win/lose var _oldShowYouWin2 = LK.showYouWin; LK.showYouWin = function () { stopSaniyeBar(); if (_oldShowYouWin2) { _oldShowYouWin2(); } }; var _oldShowGameOver2 = LK.showGameOver; LK.showGameOver = function () { stopSaniyeBar(); if (_oldShowGameOver2) { _oldShowGameOver2(); } }; // --- Card: Reveal Bombs (single use) --- var cardRevealBombsUsed = false; var cardRevealBombsBtn = new Text2('💣 Bombaları Göster', { size: 60, fill: "#fff", font: "bold", padding: 18, align: "center", background: 0xBB2222 }); cardRevealBombsBtn.anchor.set(0.5, 0); cardRevealBombsBtn.x = 2048 / 2; cardRevealBombsBtn.y = 80; cardRevealBombsBtn.interactive = true; cardRevealBombsBtn.buttonMode = true; LK.gui.top.addChild(cardRevealBombsBtn); function showAllBombsTemporarily() { // Reveal all bombs for (var y = 0; y < gridSize; y++) { for (var x = 0; x < gridSize; x++) { var cell = grid[y][x]; if (cell.hasBomb && !cell.isRevealed) { cell.reveal(); cell._wasTempRevealed = true; } } } infoText.setText('Bombs are visible for 10 seconds!'); // Reset score to 0 when bomb reveal card is used score = 0; updateSayaBar(score); // Hide bombs again after 10 seconds LK.setTimeout(function () { for (var y = 0; y < gridSize; y++) { for (var x = 0; x < gridSize; x++) { var cell = grid[y][x]; if (cell._wasTempRevealed) { cell.hide(); cell._wasTempRevealed = false; } } } infoText.setText('Card used. Move: ' + moveCount); }, 10000); } cardRevealBombsBtn.down = function (x, y, obj) { if (cardRevealBombsUsed || gameOver) { return; } cardRevealBombsUsed = true; cardRevealBombsBtn.setText('Kullanıldı'); cardRevealBombsBtn.alpha = 0.5; showAllBombsTemporarily(); }; // Dice tap area (invisible, for touch) var diceTapArea = LK.getAsset('diceTap', { width: diceSize + 60, height: diceSize + 60, color: 0xffffff, shape: 'box', anchorX: 0.5, anchorY: 0.5, alpha: 0.01 }); diceTapArea.x = dice.x; diceTapArea.y = dice.y; game.addChild(diceTapArea); // Info text infoText.setText('Roll the dice to start!'); // --- Show info popup at game start --- var infoPopupBg = LK.getAsset('cellBg', { width: 1800, height: 1450, color: 0x181c22, anchorX: 0.5, anchorY: 0.5, alpha: 0.98 }); infoPopupBg.x = 2048 / 2; infoPopupBg.y = 2732 / 2; infoPopupBg.zIndex = 99999; var infoPopupText = new Text2("Each time you move to a new square, you earn $20 and the green score bar fills up with animation.\n" + "If the bar reaches 100, it stays full and you can use the card one more time (only once per 100). The bar only resets to 0 when you use the bomb reveal card.\n\n" + "NEW CARD: If you double-tap your character, you gain a shield (2 lives). If you step on a bomb with the shield, you don't die, but lose the shield instead!\n\n" + "• Roll the dice, move to a neighboring cell with the same number.\n" + "• Some cells have hidden bombs. Be careful!\n" + "• After 15 moves, a 30 second countdown starts. Hurry up!\n" + "• You can use the red card once to reveal all bombs for 10 seconds (score bar resets to 0 when used).\n" + "• You can also use the card by tapping your character.\n" + "• Double-tap your character to activate the shield (2 lives).\n\n" + "Tap anywhere to start!", { size: 56, fill: "#000", align: "center", font: "bold", padding: 18, wordWrap: true, wordWrapWidth: 1400 }); infoPopupText.anchor.set(0.5, 0.5); infoPopupText.x = 2048 / 2; infoPopupText.y = 2732 / 2; var infoPopup = new Container(); infoPopup.addChild(infoPopupBg); infoPopup.addChild(infoPopupText); game.addChild(infoPopup); infoPopup.down = function (x, y, obj) { if (infoPopup && infoPopup.parent) { infoPopup.parent.removeChild(infoPopup); // Restore English start text after closing info popup infoText.setText('Roll the dice to start!'); } }; infoPopupBg.down = infoPopup.down; infoPopupText.down = infoPopup.down; // --- Event Handlers --- // Dice tap diceTapArea.down = function (x, y, obj) { if (canRoll && !gameOver) { rollDice(); } }; // Cell tap for (var y = 0; y < gridSize; y++) { for (var x = 0; x < gridSize; x++) { grid[y][x].down = onCellDown; } } // --- Game update (not used, but required) --- // --- Online Timer and Leaderboard --- // Timer for how long the player takes to finish the game var onlineTimer = 0; var onlineTimerInterval = null; var onlineTimerActive = false; var onlineTimerText = new Text2('Time: 0.0s', { size: 60, fill: "#222", font: "bold", align: "center" }); onlineTimerText.anchor.set(0.5, 1); onlineTimerText.x = 2048 / 2; onlineTimerText.y = 2732 - 40; onlineTimerText.zIndex = 100000; LK.gui.bottom.addChild(onlineTimerText); onlineTimerText.visible = true; // Start online timer at game start function startOnlineTimer() { onlineTimer = 0; onlineTimerActive = true; onlineTimerText.visible = true; if (onlineTimerInterval) { LK.clearInterval(onlineTimerInterval); } onlineTimerInterval = LK.setInterval(function () { if (!onlineTimerActive) { return; } onlineTimer += 0.1; onlineTimerText.setText('Time: ' + onlineTimer.toFixed(1) + 's'); }, 100); } // Stop online timer function stopOnlineTimer() { onlineTimerActive = false; if (onlineTimerInterval) { LK.clearInterval(onlineTimerInterval); } onlineTimerInterval = null; } // Start timer when info popup is closed (game starts) var _oldInfoPopupDown = infoPopup.down; infoPopup.down = function (x, y, obj) { if (_oldInfoPopupDown) { _oldInfoPopupDown(x, y, obj); } startOnlineTimer(); }; infoPopupBg.down = infoPopup.down; infoPopupText.down = infoPopup.down; // Stop timer on win/lose and show leaderboard function showLeaderboardAndStopTimer(win) { stopOnlineTimer(); // Save time to leaderboard if (typeof LK.submitLeaderboard === "function") { LK.submitLeaderboard({ score: Math.round(onlineTimer * 10), // Lower is better, use 1/10th seconds meta: { time: onlineTimer.toFixed(2), win: !!win } }); } // Show leaderboard popup if (typeof LK.showLeaderboard === "function") { LK.showLeaderboard({ sort: "asc", // Lower time is better label: "Fastest Players (seconds)", formatScore: function formatScore(score, meta) { return (meta && meta.time ? meta.time : (score / 10).toFixed(2)) + "s"; } }); } } // Patch win/lose handlers to stop timer and show leaderboard var _oldShowYouWin = LK.showYouWin; LK.showYouWin = function () { showLeaderboardAndStopTimer(true); if (_oldShowYouWin) { _oldShowYouWin(); } }; var _oldShowGameOver = LK.showGameOver; LK.showGameOver = function () { showLeaderboardAndStopTimer(false); if (_oldShowGameOver) { _oldShowGameOver(); } }; game.update = function () { // Defensive: ensure all global variables referenced in update are defined // If you add per-frame logic, always check variables for undefined before accessing properties! // Example: If you ever add code here, always check for undefined before accessing properties! // if (typeof someVar !== "undefined" && someVar && someVar[0]) { ... } // Example: if (typeof grid !== "undefined" && grid && grid[0]) { ... } // No per-frame logic currently. // Defensive check for common undefined errors if (typeof grid !== "undefined" && grid && grid[0]) { // Example: safe access to grid[0][0] // var cell = grid[0][0]; } if (typeof playerPos !== "undefined" && playerPos !== null && _typeof(playerPos) === "object" && "x" in playerPos && "y" in playerPos && typeof playerPos.x === "number" && typeof playerPos.y === "number") { // Example: safe access to playerPos.x, playerPos.y } // Add more checks as needed if you add per-frame logic in the future }; // Backward compatibility: updateScoreBar is now an alias for updateSayaBar function updateScoreBar(newScore) { updateSayaBar(newScore); }
===================================================================
--- original.js
+++ change.js
@@ -155,8 +155,9 @@
}
if (typeof Symbol === "function" && o && o.constructor === Symbol && o !== Symbol.prototype) {
return "symbol";
}
+ // Defensive: avoid reading properties of undefined (reading '0')
return typeof o;
}
function _typeof(o) {
// Defensive: avoid reading properties of undefined/null
ıdk . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
ıdk . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
ıdk . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
red and big x. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat