User prompt
Also submit scores to the core system when updating scores
User prompt
Do not subtract 25px from board position in reset
User prompt
Add a 16px black outline to the level text
User prompt
Move boardGraphics to the left and up by 3px
User prompt
Increase font size of level indicator by 50%
User prompt
Set alpha on background in game to .5
User prompt
Set alpha on background in game to .7
User prompt
Add a background element to the games class, center it
User prompt
when resetting board set firstClick to false
User prompt
on scoreTxt add a black drop shadow
User prompt
set scoreTxt size to 220
User prompt
set scoreTxt weight to 800 and size to 250
User prompt
in NumberTile set label size to 120
User prompt
set strokeThickness to 16 in NumberTile
User prompt
For NumberTile use pastel versions of the current colors
Code edit (1 edits merged)
Please save this source code
User prompt
In NumberTile set numberGraphics alpha to 0 if number == 0
User prompt
Inside board set boardGraphics x and y to -25
User prompt
Move boardGraphics 25 px up and left
User prompt
Move board background element 25 px up and left
User prompt
Incase strokeThickness to 8 on number tile
User prompt
on number tile alpha set label outline to black
User prompt
set NumberTile alpha to .5
/**** * Classes ****/ var Mine = Container.expand(function () { var self = Container.call(this); var mineGraphics = self.attachAsset('mine', { anchorX: 0.5, anchorY: 0.5 }); }); var NumberTile = Container.expand(function (number) { var self = Container.call(this); var tileType = number === 0 ? 'number_0' : 'number_other'; var numberGraphics = self.createAsset(tileType, { anchorX: 0.5, anchorY: 0.5 }); numberGraphics.alpha = number === 0 ? 0 : .5; if (number >= 1) { var dangerColors = [0x77dd77, 0x779ecb, 0xfff79a, 0xcb99c9, 0xaec6cf, 0xff6961, 0xb19cd9, 0xfdfd96]; var label = new Text2(number.toString(), { size: 120, fill: '#ffffff', align: 'center', weight: 800, stroke: '#000000', strokeThickness: 16 }); label.anchor.set(0.5); label.tint = dangerColors[number - 1]; 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.attachAsset('cell', { anchorX: 0.5, anchorY: 0.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.parent.parent.score++; LK.setScore(self.parent.parent.score); self.parent.parent.scoreTxt.setText(LK.getScore().toString()); } }; 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(5 + self.resetCount); self.calculateAllNeighborMines(); self.resetCount++; var totalWidth = self.cells.length * 180; var totalHeight = self.cells[0].length * 180; self.x = (2048 - totalWidth) / 2; self.y = (2732 - totalHeight) / 2; var levelText = new Text2('Level ' + self.resetCount, { size: 225, fill: '#ffffff', align: 'center', weight: 800, stroke: '#000000', strokeThickness: 16 }); levelText.anchor.set(0.5); levelText.x = totalWidth / 2; levelText.y = totalHeight / 2; self.addChild(levelText); LK.setTimeout(function () { levelText.destroy(); }, 1000); }; 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 && !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]; if (Math.abs(neighbor.gridX - x) + Math.abs(neighbor.gridY - y) === 1) { 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) { if (cellX >= 0 && cellX < self.cells.length && cellY >= 0 && cellY < self.cells[cellX].length) { var cell = self.cells[cellX][cellY]; } if (cell && !cell.isRevealed) { if (cell.isMine && !self.firstClick) { self.firstClick = true; cell.isMine = false; var randomX, randomY, randomCell; do { randomX = Math.floor(Math.random() * self.cells.length); randomY = Math.floor(Math.random() * self.cells[randomX].length); randomCell = self.cells[randomX][randomY]; } while (randomCell.isMine); randomCell.placeMine(); self.calculateAllNeighborMines(); } self.revealCellAndNeighbors(cellX, cellY); self.firstClick = true; if (cell.isMine) { gameOver = true; self.revealAllMines(); LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } else { var unrevealedCells = 0; var mineCells = 0; for (var x = 0; x < self.cells.length; x++) { for (var y = 0; y < self.cells[x].length; y++) { if (!self.cells[x][y].isRevealed) { unrevealedCells++; if (self.cells[x][y].isMine) { mineCells++; } } } } if (unrevealedCells === mineCells) { LK.effects.flashScreen(0x00ff00, 1000); self.resetBoard(); } } } }; 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.attachAsset('board', {}); boardGraphics.x = -28; boardGraphics.y = -28; self.cells = []; self.firstClick = false; self.firstClick = false; self.resetCount = 0; 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 getNeighbor(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); } } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var background = game.attachAsset('background', { anchorX: 0.5, anchorY: 0.5 }); background.alpha = 0.5; background.x = 2048 / 2; background.y = 2732 / 2; game.addChild(background); game.setBackgroundColor(0x89a6bb); game.score = 0; game.scoreTxt = new Text2(game.score.toString(), { size: 220, fill: '#ffffff', weight: 800, dropShadow: true, dropShadowColor: '#000000', dropShadowBlur: 4, dropShadowAngle: Math.PI / 6, dropShadowDistance: 6 }); game.scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(game.scoreTxt); var board = game.addChild(new Board()); var gameOver = false; board.resetBoard();
===================================================================
--- original.js
+++ change.js
@@ -1,12 +1,21 @@
+/****
+* Classes
+****/
var Mine = Container.expand(function () {
var self = Container.call(this);
- var mineGraphics = self.createAsset('mine', 'Mine Graphics', .5, .5);
+ var mineGraphics = self.attachAsset('mine', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
});
var NumberTile = Container.expand(function (number) {
var self = Container.call(this);
var tileType = number === 0 ? 'number_0' : 'number_other';
- var numberGraphics = self.createAsset(tileType, 'Number Tile Graphics', .5, .5);
+ var numberGraphics = self.createAsset(tileType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
numberGraphics.alpha = number === 0 ? 0 : .5;
if (number >= 1) {
var dangerColors = [0x77dd77, 0x779ecb, 0xfff79a, 0xcb99c9, 0xaec6cf, 0xff6961, 0xb19cd9, 0xfdfd96];
var label = new Text2(number.toString(), {
@@ -31,14 +40,19 @@
self.gridY = y;
self.x = x * 180 + 90;
self.y = y * 180 + 90;
};
- var cellGraphics = self.createAsset('cell', 'Cell Graphics', .5, .5);
+ var cellGraphics = self.attachAsset('cell', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
self.isMine = false;
self.isRevealed = false;
self.neighborMines = 0;
self.reveal = function () {
- if (self.isRevealed) return;
+ if (self.isRevealed) {
+ return;
+ }
self.isRevealed = true;
if (self.isMine) {
cellGraphics.visible = false;
var mine = self.addChild(new Mine());
@@ -46,9 +60,10 @@
cellGraphics.visible = false;
var number = self.addChild(new NumberTile(self.neighborMines));
self.addChild(number);
self.parent.parent.score++;
- self.parent.parent.scoreTxt.setText(self.parent.parent.score.toString());
+ LK.setScore(self.parent.parent.score);
+ self.parent.parent.scoreTxt.setText(LK.getScore().toString());
}
};
self.placeMine = function () {
self.isMine = true;
@@ -99,19 +114,24 @@
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 (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;
+ if (x < 0 || x >= self.cells.length || y < 0 || y >= self.cells[x].length) {
+ return;
+ }
var cell = self.cells[x][y];
if (cell && !cell.isRevealed) {
cell.reveal();
if (cell.neighborMines === 0) {
@@ -184,9 +204,9 @@
}
}
}
};
- var boardGraphics = self.createAsset('board', 'Board Graphics', 0, 0);
+ var boardGraphics = self.attachAsset('board', {});
boardGraphics.x = -28;
boardGraphics.y = -28;
self.cells = [];
self.firstClick = false;
@@ -203,9 +223,11 @@
}
}
};
self.revealCell = function (x, y) {
- if (x < 0 || x >= self.cells.length || y < 0 || y >= self.cells[x].length) return;
+ 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;
@@ -222,14 +244,17 @@
}
}
};
self.calculateAllNeighborMines = function () {
- var getNeighbor = function (x, y) {
+ var getNeighbor = function getNeighbor(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 (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]);
}
}
@@ -242,29 +267,40 @@
}
}
};
});
-var Game = Container.expand(function () {
- var self = Container.call(this);
- var background = self.createAsset('background', 'Game Background', 0.5, 0.5);
- background.alpha = 0.5;
- background.x = 2048 / 2;
- background.y = 2732 / 2;
- self.addChild(background);
- LK.stageContainer.setBackgroundColor(0x89a6bb);
- self.score = 0;
- self.scoreTxt = new Text2(self.score.toString(), {
- size: 220,
- fill: '#ffffff',
- weight: 800,
- dropShadow: true,
- dropShadowColor: '#000000',
- dropShadowBlur: 4,
- dropShadowAngle: Math.PI / 6,
- dropShadowDistance: 6
- });
- self.scoreTxt.anchor.set(.5, 0);
- LK.gui.topCenter.addChild(self.scoreTxt);
- var board = self.addChild(new Board());
- var gameOver = false;
- board.resetBoard();
+
+/****
+* Initialize Game
+****/
+var game = new LK.Game({
+ backgroundColor: 0x000000
});
+
+/****
+* Game Code
+****/
+var background = game.attachAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+background.alpha = 0.5;
+background.x = 2048 / 2;
+background.y = 2732 / 2;
+game.addChild(background);
+game.setBackgroundColor(0x89a6bb);
+game.score = 0;
+game.scoreTxt = new Text2(game.score.toString(), {
+ size: 220,
+ fill: '#ffffff',
+ weight: 800,
+ dropShadow: true,
+ dropShadowColor: '#000000',
+ dropShadowBlur: 4,
+ dropShadowAngle: Math.PI / 6,
+ dropShadowDistance: 6
+});
+game.scoreTxt.anchor.set(.5, 0);
+LK.gui.topCenter.addChild(game.scoreTxt);
+var board = game.addChild(new Board());
+var gameOver = false;
+board.resetBoard();
\ No newline at end of file
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.