User prompt
Oyun çok yavaş ve arada bir duruyor
User prompt
Kareler çok küçük. Oyun çok yavaş çalışıyor
User prompt
Oyun alanı ekranı kaplasın
User prompt
Oyun alanı büyük olsun
User prompt
Hatayı düzelt
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'fill')' in or related to this line: 'self.numberText.style.fill = colors[self.adjacentMines] || '#000000';' Line Number: 74
Code edit (1 edits merged)
Please save this source code
User prompt
Minesweeper Classic
Initial prompt
Bana bir mayın tarlası oyunu yap. Ses efektli olsun
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var MineTile = Container.expand(function (row, col) { var self = Container.call(this); self.row = row; self.col = col; self.isMine = false; self.isRevealed = false; self.isFlagged = false; self.adjacentMines = 0; var tileGraphics = self.attachAsset('tile', { anchorX: 0, anchorY: 0 }); var numberText = new Text2('', { size: 32, fill: 0x000000 }); numberText.anchor.set(0.5, 0.5); numberText.x = 32; numberText.y = 32; self.addChild(numberText); self.numberText = numberText; self.tileGraphics = tileGraphics; self.setMine = function () { self.isMine = true; }; self.setAdjacentMines = function (count) { self.adjacentMines = count; }; self.reveal = function () { if (self.isRevealed || self.isFlagged) return false; self.isRevealed = true; if (self.isMine) { self.removeChild(self.tileGraphics); self.tileGraphics = self.attachAsset('mineTile', { anchorX: 0, anchorY: 0 }); self.addChildAt(self.tileGraphics, 0); self.numberText.setText('💣'); LK.getSound('explosion').play(); return false; } else { self.removeChild(self.tileGraphics); self.tileGraphics = self.attachAsset('revealedTile', { anchorX: 0, anchorY: 0 }); self.addChildAt(self.tileGraphics, 0); if (self.adjacentMines > 0) { self.numberText.setText(self.adjacentMines.toString()); var colors = ['', '#0000ff', '#008000', '#ff0000', '#800080', '#800000', '#008080', '#000000', '#808080']; self.numberText.fill = colors[self.adjacentMines] || '#000000'; } LK.getSound('tileReveal').play(); return true; } }; self.toggleFlag = function () { if (self.isRevealed) return; self.isFlagged = !self.isFlagged; if (self.isFlagged) { self.removeChild(self.tileGraphics); self.tileGraphics = self.attachAsset('flagTile', { anchorX: 0, anchorY: 0 }); self.addChildAt(self.tileGraphics, 0); self.numberText.setText('🚩'); LK.getSound('flag').play(); } else { self.removeChild(self.tileGraphics); self.tileGraphics = self.attachAsset('tile', { anchorX: 0, anchorY: 0 }); self.addChildAt(self.tileGraphics, 0); self.numberText.setText(''); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x888888 }); /**** * Game Code ****/ var GRID_WIDTH = 32; var GRID_HEIGHT = 42; var MINE_COUNT = 200; var TILE_SIZE = 64; var TILE_SPACING = 0; var grid = []; var gameBoard; var gameStarted = false; var gameOver = false; var isVictory = false; var tilesRevealed = 0; var totalSafeTiles = GRID_WIDTH * GRID_HEIGHT - MINE_COUNT; var pressStartTime = 0; var longPressThreshold = 500; var currentPressedTile = null; function initializeGrid() { grid = []; gameBoard = new Container(); game.addChild(gameBoard); var boardWidth = GRID_WIDTH * (TILE_SIZE + TILE_SPACING) - TILE_SPACING; var boardHeight = GRID_HEIGHT * (TILE_SIZE + TILE_SPACING) - TILE_SPACING; gameBoard.x = (2048 - boardWidth) / 2; gameBoard.y = (2732 - boardHeight) / 2; for (var row = 0; row < GRID_HEIGHT; row++) { grid[row] = []; for (var col = 0; col < GRID_WIDTH; col++) { var tile = new MineTile(row, col); tile.x = col * (TILE_SIZE + TILE_SPACING); tile.y = row * (TILE_SIZE + TILE_SPACING); grid[row][col] = tile; gameBoard.addChild(tile); } } } function placeMines(excludeRow, excludeCol) { var minesPlaced = 0; var attempts = 0; while (minesPlaced < MINE_COUNT && attempts < 1000) { var row = Math.floor(Math.random() * GRID_HEIGHT); var col = Math.floor(Math.random() * GRID_WIDTH); if (row === excludeRow && col === excludeCol || grid[row][col].isMine) { attempts++; continue; } grid[row][col].setMine(); minesPlaced++; attempts++; } calculateAdjacentMines(); } function calculateAdjacentMines() { for (var row = 0; row < GRID_HEIGHT; row++) { for (var col = 0; col < GRID_WIDTH; col++) { if (!grid[row][col].isMine) { var count = 0; for (var dr = -1; dr <= 1; dr++) { for (var dc = -1; dc <= 1; dc++) { var newRow = row + dr; var newCol = col + dc; if (newRow >= 0 && newRow < GRID_HEIGHT && newCol >= 0 && newCol < GRID_WIDTH) { if (grid[newRow][newCol].isMine) { count++; } } } } grid[row][col].setAdjacentMines(count); } } } } function revealTile(row, col) { if (row < 0 || row >= GRID_HEIGHT || col < 0 || col >= GRID_WIDTH) return; if (grid[row][col].isRevealed || grid[row][col].isFlagged) return; var success = grid[row][col].reveal(); if (!success && grid[row][col].isMine) { gameOver = true; revealAllMines(); LK.setTimeout(function () { LK.showGameOver(); }, 1000); return; } tilesRevealed++; if (grid[row][col].adjacentMines === 0) { for (var dr = -1; dr <= 1; dr++) { for (var dc = -1; dc <= 1; dc++) { revealTile(row + dr, col + dc); } } } if (tilesRevealed >= totalSafeTiles) { isVictory = true; gameOver = true; LK.getSound('victory').play(); LK.setTimeout(function () { LK.showYouWin(); }, 1000); } } function revealAllMines() { for (var row = 0; row < GRID_HEIGHT; row++) { for (var col = 0; col < GRID_WIDTH; col++) { if (grid[row][col].isMine && !grid[row][col].isRevealed) { grid[row][col].reveal(); } } } } function getTileAt(x, y) { var boardPos = gameBoard.toLocal({ x: x, y: y }); var col = Math.floor(boardPos.x / (TILE_SIZE + TILE_SPACING)); var row = Math.floor(boardPos.y / (TILE_SIZE + TILE_SPACING)); if (row >= 0 && row < GRID_HEIGHT && col >= 0 && col < GRID_WIDTH) { var tileX = col * (TILE_SIZE + TILE_SPACING); var tileY = row * (TILE_SIZE + TILE_SPACING); if (boardPos.x >= tileX && boardPos.x < tileX + TILE_SIZE && boardPos.y >= tileY && boardPos.y < tileY + TILE_SIZE) { return grid[row][col]; } } return null; } game.down = function (x, y, obj) { if (gameOver) return; var tile = getTileAt(x, y); if (!tile) return; pressStartTime = Date.now(); currentPressedTile = tile; }; game.up = function (x, y, obj) { if (gameOver || !currentPressedTile) return; var pressDuration = Date.now() - pressStartTime; var tile = getTileAt(x, y); if (tile === currentPressedTile) { if (pressDuration >= longPressThreshold) { tile.toggleFlag(); } else { if (!gameStarted) { placeMines(tile.row, tile.col); gameStarted = true; } if (!tile.isFlagged) { revealTile(tile.row, tile.col); } } } currentPressedTile = null; }; initializeGrid();
===================================================================
--- original.js
+++ change.js
@@ -18,14 +18,14 @@
anchorX: 0,
anchorY: 0
});
var numberText = new Text2('', {
- size: 20,
+ size: 32,
fill: 0x000000
});
numberText.anchor.set(0.5, 0.5);
- numberText.x = 20;
- numberText.y = 20;
+ numberText.x = 32;
+ numberText.y = 32;
self.addChild(numberText);
self.numberText = numberText;
self.tileGraphics = tileGraphics;
self.setMine = function () {
@@ -97,13 +97,13 @@
/****
* Game Code
****/
-var GRID_WIDTH = 20;
-var GRID_HEIGHT = 26;
-var MINE_COUNT = 80;
-var TILE_SIZE = 40;
-var TILE_SPACING = 1;
+var GRID_WIDTH = 32;
+var GRID_HEIGHT = 42;
+var MINE_COUNT = 200;
+var TILE_SIZE = 64;
+var TILE_SPACING = 0;
var grid = [];
var gameBoard;
var gameStarted = false;
var gameOver = false;
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Minesweeper Classic" and with the description "Classic minesweeper puzzle game with grid-based mine detection, logical deduction gameplay, and immersive sound effects.". No text on banner!
Kırmızı mayın tarlası bayrağı. In-Game asset. 2d. High contrast. No shadows
Kareli bir oyun alanı. In-Game asset. 2d. High contrast. No shadows