User prompt
Instead of coloring the numberGraphics color the label
User prompt
Only add 5 mines to the board
User prompt
do not set a timeout around show game over
User prompt
When auto revealing tiles. Do not auto reveal diagonal tiles. however make sure you don't count mines differently than your currently do
User prompt
Do not set a timer around showgameover
User prompt
When auto revealing tiles. Do not auto reveal diagonal tiles.
User prompt
Update dangerColors such that no colors are close to each other
User prompt
Update the dangerColors such that all colors of the rainbow is used. However order them from friendly color to danger color. (1-8). Make sure no two colors are to similar
User prompt
Update the dangerColors such that all colors of the rainbow is used. However order them from friendly color to danger color. (1-8)
User prompt
Add 15 bombs when placing mines
User prompt
when number is equal or larger than one. in Number cell, tint the background based on how dangerous the cell is. With 1 being friendly and 8 being evil.
User prompt
For number tiles, only use two types of tiles. One for zero and one for all other numbers
User prompt
when game over flash the screen red for 1 sc
User prompt
When resetting the board in onCellClicked flash the screen green for 1 sec
User prompt
After clicking a cell, if the only cells not revealed are mines, reset the board
User prompt
Only add 4 mines
User prompt
in onCellClicked after calling revealCellAndNeighbors set firstClick to true
User prompt
Don't set firstClick unless we pressed a cell
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'cell.isRevealed')' in this line: 'if (!cell.isRevealed) {' Line Number: 112
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'cell.isRevealed')' in this line: 'if (!cell.isRevealed) {' Line Number: 112
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'self.cells[cellX][cellY]')' in this line: 'var cell = self.cells[cellX][cellY];' Line Number: 109
User prompt
always set self.firstClick in onCellClicked
User prompt
After moving a potential first click mine, remember to call calculateAllNeighborMines to update the board
User prompt
When clicking a reset board for the first time, if the board is a mine. Convert this element into a normal tile instead such that the player does not die on the first click
User prompt
In resetBoard set x,y of self such that the board is centered on the screen
var Mine = Container.expand(function () { var self = Container.call(this); var mineGraphics = self.createAsset('mine', 'Mine Graphics', .5, .5); }); var NumberTile = Container.expand(function (number) { var self = Container.call(this); var numberGraphics = self.createAsset('number_' + number, 'Number ' + number + ' Graphics', .5, .5); if (number >= 1) { var label = new Text2(number.toString(), { size: 100, fill: '#ffffff', align: 'center' }); label.anchor.set(0.5); self.addChild(label); } }); var Cell = Container.expand(function () { var self = Container.call(this); self.gridX = 0; self.gridY = 0; self.setPosition = function (x, y) { self.gridX = x; self.gridY = y; self.x = x * 180 + 90; self.y = y * 180 + 90; }; var cellGraphics = self.createAsset('cell', 'Cell Graphics', .5, .5); self.isMine = false; self.isRevealed = false; self.neighborMines = 0; self.reveal = function () { if (self.isRevealed) return; self.isRevealed = true; if (self.isMine) { cellGraphics.visible = false; var mine = self.addChild(new Mine()); } else { cellGraphics.visible = false; var number = self.addChild(new NumberTile(self.neighborMines)); self.addChild(number); } }; self.placeMine = function () { self.isMine = true; }; self.calculateNeighborMines = function (getNeighbor) { self.neighborMines = 0; var neighbors = getNeighbor(self.gridX, self.gridY); for (var i = 0; i < neighbors.length; i++) { if (neighbors[i].isMine) { self.neighborMines++; } } }; }); var Board = Container.expand(function () { var self = Container.call(this); self.resetBoard = function () { for (var x = 0; x < self.cells.length; x++) { for (var y = 0; y < self.cells[x].length; y++) { self.cells[x][y].destroy(); } } self.cells = []; self.generateBoard(10, 10); self.placeMines(10); self.calculateAllNeighborMines(); var totalWidth = self.cells.length * 180; var totalHeight = self.cells[0].length * 180; self.x = (2048 - totalWidth) / 2; self.y = (2732 - totalHeight) / 2; }; self.getNeighbors = function (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, ny = y + dy; if (nx >= 0 && nx < self.cells.length && ny >= 0 && ny < self.cells[nx].length) { neighbors.push(self.cells[nx][ny]); } } } return neighbors; }; self.revealCellAndNeighbors = function (x, y) { if (x < 0 || x >= self.cells.length || y < 0 || y >= self.cells[x].length) return; var cell = self.cells[x][y]; if (!cell.isRevealed) { cell.reveal(); if (cell.neighborMines === 0) { var neighbors = self.getNeighbors(x, y); for (var i = 0; i < neighbors.length; i++) { var neighbor = neighbors[i]; self.revealCellAndNeighbors(neighbor.gridX, neighbor.gridY); } } } }; self.on('down', function (obj) { var pos = obj.event.getLocalPosition(self); var cellX = Math.floor(pos.x / 180); var cellY = Math.floor(pos.y / 180); self.onCellClicked(cellX, cellY); }); self.onCellClicked = function (cellX, cellY) { var cell = self.cells[cellX][cellY]; if (!cell.isRevealed) { self.revealCellAndNeighbors(cellX, cellY); if (cell.isMine) { gameOver = true; self.revealAllMines(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } }; self.revealAllMines = function () { for (var x = 0; x < self.cells.length; x++) { for (var y = 0; y < self.cells[x].length; y++) { var cell = self.cells[x][y]; if (cell.isMine) { cell.reveal(); } } } }; var boardGraphics = self.createAsset('board', 'Board Graphics', .5, .5); self.cells = []; self.generateBoard = function (width, height) { for (var x = 0; x < width; x++) { self.cells[x] = []; for (var y = 0; y < height; y++) { var cell = new Cell(); self.addChild(cell); self.cells[x][y] = cell; cell.setPosition(x, y); } } }; self.revealCell = function (x, y) { if (x < 0 || x >= self.cells.length || y < 0 || y >= self.cells[x].length) return; var cell = self.cells[x][y]; if (!cell.isRevealed) { cell.reveal(); return cell.isMine; } }; self.placeMines = function (mineCount) { var placedMines = 0; while (placedMines < mineCount) { var x = Math.floor(Math.random() * self.cells.length); var y = Math.floor(Math.random() * self.cells[x].length); if (!self.cells[x][y].isMine) { self.cells[x][y].placeMine(); placedMines++; } } }; self.calculateAllNeighborMines = function () { var getNeighbor = function (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, ny = y + dy; if (nx >= 0 && nx < self.cells.length && ny >= 0 && ny < self.cells[nx].length) { neighbors.push(self.cells[nx][ny]); } } } return neighbors; }; for (var x = 0; x < self.cells.length; x++) { for (var y = 0; y < self.cells[x].length; y++) { self.cells[x][y].calculateNeighborMines(getNeighbor); } } }; }); var Game = Container.expand(function () { var self = Container.call(this); var board = self.addChild(new Board()); var gameOver = false; board.resetBoard(); });
var Mine = Container.expand(function () {
var self = Container.call(this);
var mineGraphics = self.createAsset('mine', 'Mine Graphics', .5, .5);
});
var NumberTile = Container.expand(function (number) {
var self = Container.call(this);
var numberGraphics = self.createAsset('number_' + number, 'Number ' + number + ' Graphics', .5, .5);
if (number >= 1) {
var label = new Text2(number.toString(), {
size: 100,
fill: '#ffffff',
align: 'center'
});
label.anchor.set(0.5);
self.addChild(label);
}
});
var Cell = Container.expand(function () {
var self = Container.call(this);
self.gridX = 0;
self.gridY = 0;
self.setPosition = function (x, y) {
self.gridX = x;
self.gridY = y;
self.x = x * 180 + 90;
self.y = y * 180 + 90;
};
var cellGraphics = self.createAsset('cell', 'Cell Graphics', .5, .5);
self.isMine = false;
self.isRevealed = false;
self.neighborMines = 0;
self.reveal = function () {
if (self.isRevealed) return;
self.isRevealed = true;
if (self.isMine) {
cellGraphics.visible = false;
var mine = self.addChild(new Mine());
} else {
cellGraphics.visible = false;
var number = self.addChild(new NumberTile(self.neighborMines));
self.addChild(number);
}
};
self.placeMine = function () {
self.isMine = true;
};
self.calculateNeighborMines = function (getNeighbor) {
self.neighborMines = 0;
var neighbors = getNeighbor(self.gridX, self.gridY);
for (var i = 0; i < neighbors.length; i++) {
if (neighbors[i].isMine) {
self.neighborMines++;
}
}
};
});
var Board = Container.expand(function () {
var self = Container.call(this);
self.resetBoard = function () {
for (var x = 0; x < self.cells.length; x++) {
for (var y = 0; y < self.cells[x].length; y++) {
self.cells[x][y].destroy();
}
}
self.cells = [];
self.generateBoard(10, 10);
self.placeMines(10);
self.calculateAllNeighborMines();
var totalWidth = self.cells.length * 180;
var totalHeight = self.cells[0].length * 180;
self.x = (2048 - totalWidth) / 2;
self.y = (2732 - totalHeight) / 2;
};
self.getNeighbors = function (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, ny = y + dy;
if (nx >= 0 && nx < self.cells.length && ny >= 0 && ny < self.cells[nx].length) {
neighbors.push(self.cells[nx][ny]);
}
}
}
return neighbors;
};
self.revealCellAndNeighbors = function (x, y) {
if (x < 0 || x >= self.cells.length || y < 0 || y >= self.cells[x].length) return;
var cell = self.cells[x][y];
if (!cell.isRevealed) {
cell.reveal();
if (cell.neighborMines === 0) {
var neighbors = self.getNeighbors(x, y);
for (var i = 0; i < neighbors.length; i++) {
var neighbor = neighbors[i];
self.revealCellAndNeighbors(neighbor.gridX, neighbor.gridY);
}
}
}
};
self.on('down', function (obj) {
var pos = obj.event.getLocalPosition(self);
var cellX = Math.floor(pos.x / 180);
var cellY = Math.floor(pos.y / 180);
self.onCellClicked(cellX, cellY);
});
self.onCellClicked = function (cellX, cellY) {
var cell = self.cells[cellX][cellY];
if (!cell.isRevealed) {
self.revealCellAndNeighbors(cellX, cellY);
if (cell.isMine) {
gameOver = true;
self.revealAllMines();
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
};
self.revealAllMines = function () {
for (var x = 0; x < self.cells.length; x++) {
for (var y = 0; y < self.cells[x].length; y++) {
var cell = self.cells[x][y];
if (cell.isMine) {
cell.reveal();
}
}
}
};
var boardGraphics = self.createAsset('board', 'Board Graphics', .5, .5);
self.cells = [];
self.generateBoard = function (width, height) {
for (var x = 0; x < width; x++) {
self.cells[x] = [];
for (var y = 0; y < height; y++) {
var cell = new Cell();
self.addChild(cell);
self.cells[x][y] = cell;
cell.setPosition(x, y);
}
}
};
self.revealCell = function (x, y) {
if (x < 0 || x >= self.cells.length || y < 0 || y >= self.cells[x].length) return;
var cell = self.cells[x][y];
if (!cell.isRevealed) {
cell.reveal();
return cell.isMine;
}
};
self.placeMines = function (mineCount) {
var placedMines = 0;
while (placedMines < mineCount) {
var x = Math.floor(Math.random() * self.cells.length);
var y = Math.floor(Math.random() * self.cells[x].length);
if (!self.cells[x][y].isMine) {
self.cells[x][y].placeMine();
placedMines++;
}
}
};
self.calculateAllNeighborMines = function () {
var getNeighbor = function (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, ny = y + dy;
if (nx >= 0 && nx < self.cells.length && ny >= 0 && ny < self.cells[nx].length) {
neighbors.push(self.cells[nx][ny]);
}
}
}
return neighbors;
};
for (var x = 0; x < self.cells.length; x++) {
for (var y = 0; y < self.cells[x].length; y++) {
self.cells[x][y].calculateNeighborMines(getNeighbor);
}
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var board = self.addChild(new Board());
var gameOver = false;
board.resetBoard();
});
Sea mine. Minesweeper. Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Watery background. 10x10 Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single white square. Round corners. Vector. Simple details. Flat shaded. No shadows. No outlines.