Code edit (1 edits merged)
Please save this source code
User prompt
Strategic Grid Conquest
Initial prompt
make othello game but not black and white do it orange and grey on table have grids 10x10, with numbers and alphabet characters on its sides, do a button an the to right corner 300x100 with text coordinates and when click on it show a background of the movements of each player.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Cell = Container.expand(function () { var self = Container.call(this); var cellGraphics = self.attachAsset('cell', { anchorX: 0.5, anchorY: 0.5 }); self.row = 0; self.col = 0; self.piece = null; self.down = function (x, y, obj) { if (!self.piece && currentPlayer !== null) { placePiece(self.row, self.col); } }; return self; }); var CoordButton = Container.expand(function () { var self = Container.call(this); var buttonBg = self.attachAsset('coordButton', { anchorX: 0.5, anchorY: 0.5 }); var buttonText = new Text2('Coordinates', { size: 24, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); self.addChild(buttonText); self.down = function (x, y, obj) { toggleHistory(); }; return self; }); var HistoryPanel = Container.expand(function () { var self = Container.call(this); var bg = self.attachAsset('historyBg', { anchorX: 0.5, anchorY: 0.5 }); var titleText = new Text2('Move History', { size: 32, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.y = -280; self.addChild(titleText); self.historyText = new Text2('', { size: 20, fill: 0xFFFFFF }); self.historyText.anchor.set(0.5, 0); self.historyText.y = -240; self.addChild(self.historyText); self.updateHistory = function () { var historyString = ''; for (var i = 0; i < moveHistory.length; i++) { var move = moveHistory[i]; var player = move.player === 0 ? 'Orange' : 'Grey'; historyString += player + ': ' + move.coord + '\n'; } self.historyText.setText(historyString); }; self.down = function (x, y, obj) { toggleHistory(); }; return self; }); var Piece = Container.expand(function () { var self = Container.call(this); self.player = 0; // 0 for orange, 1 for grey self.graphics = null; self.setPlayer = function (player) { if (self.graphics) { self.graphics.destroy(); } self.player = player; var assetId = player === 0 ? 'orangePiece' : 'greyPiece'; self.graphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); }; self.flip = function () { self.setPlayer(1 - self.player); tween(self, { scaleX: 0 }, { duration: 150, onFinish: function onFinish() { self.setPlayer(1 - self.player); tween(self, { scaleX: 1 }, { duration: 150 }); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a3a1a }); /**** * Game Code ****/ var BOARD_SIZE = 10; var CELL_SIZE = 78; var BOARD_WIDTH = BOARD_SIZE * CELL_SIZE; var board = []; var cells = []; var currentPlayer = 0; // 0 for orange, 1 for grey var moveHistory = []; var historyPanel = null; var historyVisible = false; // Create board container var boardContainer = new Container(); boardContainer.x = 1024; boardContainer.y = 1366; game.addChild(boardContainer); // Create board background var boardBg = LK.getAsset('boardBg', { anchorX: 0.5, anchorY: 0.5 }); boardContainer.addChild(boardBg); // Initialize board array and create cells for (var row = 0; row < BOARD_SIZE; row++) { board[row] = []; cells[row] = []; for (var col = 0; col < BOARD_SIZE; col++) { board[row][col] = null; var cell = new Cell(); cell.row = row; cell.col = col; cell.x = (col - 4.5) * CELL_SIZE; cell.y = (row - 4.5) * CELL_SIZE; boardContainer.addChild(cell); cells[row][col] = cell; } } // Create coordinate labels var letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']; for (var i = 0; i < BOARD_SIZE; i++) { // Column labels (A-J) var colLabel = new Text2(letters[i], { size: 24, fill: 0xFFFFFF }); colLabel.anchor.set(0.5, 0.5); colLabel.x = (i - 4.5) * CELL_SIZE; colLabel.y = -440; boardContainer.addChild(colLabel); // Row labels (1-10) var rowLabel = new Text2((i + 1).toString(), { size: 24, fill: 0xFFFFFF }); rowLabel.anchor.set(0.5, 0.5); rowLabel.x = -440; rowLabel.y = (i - 4.5) * CELL_SIZE; boardContainer.addChild(rowLabel); } // Create current player indicator var playerText = new Text2('Current Player: Orange', { size: 36, fill: 0xFF8C00 }); playerText.anchor.set(0.5, 0); playerText.y = 100; LK.gui.top.addChild(playerText); // Create coordinates button var coordButton = new CoordButton(); coordButton.x = -100; coordButton.y = 100; LK.gui.topRight.addChild(coordButton); // Create history panel (initially hidden) historyPanel = new HistoryPanel(); historyPanel.visible = false; game.addChild(historyPanel); historyPanel.x = 1024; historyPanel.y = 1366; // Game functions function getCoordinate(row, col) { return letters[col] + (row + 1); } function placePiece(row, col) { if (board[row][col] !== null) return; // Create and place piece var piece = new Piece(); piece.setPlayer(currentPlayer); cells[row][col].addChild(piece); cells[row][col].piece = piece; board[row][col] = currentPlayer; // Play place sound LK.getSound('place').play(); // Add to move history moveHistory.push({ player: currentPlayer, coord: getCoordinate(row, col) }); // Update history panel if visible if (historyVisible && historyPanel) { historyPanel.updateHistory(); } // Check for flips in all directions var directions = [[-1, 0], [1, 0], [0, -1], [0, 1], // vertical and horizontal [-1, -1], [-1, 1], [1, -1], [1, 1] // diagonals ]; var totalFlips = 0; for (var d = 0; d < directions.length; d++) { var flips = checkDirection(row, col, directions[d][0], directions[d][1]); if (flips.length > 0) { flipPieces(flips); totalFlips += flips.length; } } if (totalFlips > 0) { LK.getSound('flip').play(); } // Switch player currentPlayer = 1 - currentPlayer; updatePlayerText(); // Check for game over checkGameOver(); } function checkDirection(row, col, dRow, dCol) { var flips = []; var r = row + dRow; var c = col + dCol; // Find opponent pieces while (r >= 0 && r < BOARD_SIZE && c >= 0 && c < BOARD_SIZE) { if (board[r][c] === null) { return []; } if (board[r][c] === currentPlayer) { return flips; } flips.push([r, c]); r += dRow; c += dCol; } return []; } function flipPieces(positions) { for (var i = 0; i < positions.length; i++) { var row = positions[i][0]; var col = positions[i][1]; board[row][col] = currentPlayer; cells[row][col].piece.flip(); } } function updatePlayerText() { var player = currentPlayer === 0 ? 'Orange' : 'Grey'; var color = currentPlayer === 0 ? '#ff8c00' : '#808080'; playerText.setText('Current Player: ' + player); playerText.style.fill = color; } function checkGameOver() { var hasEmpty = false; var orangeCount = 0; var greyCount = 0; for (var row = 0; row < BOARD_SIZE; row++) { for (var col = 0; col < BOARD_SIZE; col++) { if (board[row][col] === null) { hasEmpty = true; } else if (board[row][col] === 0) { orangeCount++; } else { greyCount++; } } } if (!hasEmpty) { if (orangeCount > greyCount) { LK.showYouWin(); } else { LK.showGameOver(); } } } function toggleHistory() { historyVisible = !historyVisible; if (historyPanel) { historyPanel.visible = historyVisible; if (historyVisible) { historyPanel.updateHistory(); } } } // Initialize with starting pieces in center placePiece(4, 4); placePiece(4, 5); placePiece(5, 5); placePiece(5, 4);
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,310 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var Cell = Container.expand(function () {
+ var self = Container.call(this);
+ var cellGraphics = self.attachAsset('cell', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.row = 0;
+ self.col = 0;
+ self.piece = null;
+ self.down = function (x, y, obj) {
+ if (!self.piece && currentPlayer !== null) {
+ placePiece(self.row, self.col);
+ }
+ };
+ return self;
+});
+var CoordButton = Container.expand(function () {
+ var self = Container.call(this);
+ var buttonBg = self.attachAsset('coordButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var buttonText = new Text2('Coordinates', {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ self.addChild(buttonText);
+ self.down = function (x, y, obj) {
+ toggleHistory();
+ };
+ return self;
+});
+var HistoryPanel = Container.expand(function () {
+ var self = Container.call(this);
+ var bg = self.attachAsset('historyBg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var titleText = new Text2('Move History', {
+ size: 32,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0);
+ titleText.y = -280;
+ self.addChild(titleText);
+ self.historyText = new Text2('', {
+ size: 20,
+ fill: 0xFFFFFF
+ });
+ self.historyText.anchor.set(0.5, 0);
+ self.historyText.y = -240;
+ self.addChild(self.historyText);
+ self.updateHistory = function () {
+ var historyString = '';
+ for (var i = 0; i < moveHistory.length; i++) {
+ var move = moveHistory[i];
+ var player = move.player === 0 ? 'Orange' : 'Grey';
+ historyString += player + ': ' + move.coord + '\n';
+ }
+ self.historyText.setText(historyString);
+ };
+ self.down = function (x, y, obj) {
+ toggleHistory();
+ };
+ return self;
+});
+var Piece = Container.expand(function () {
+ var self = Container.call(this);
+ self.player = 0; // 0 for orange, 1 for grey
+ self.graphics = null;
+ self.setPlayer = function (player) {
+ if (self.graphics) {
+ self.graphics.destroy();
+ }
+ self.player = player;
+ var assetId = player === 0 ? 'orangePiece' : 'greyPiece';
+ self.graphics = self.attachAsset(assetId, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ };
+ self.flip = function () {
+ self.setPlayer(1 - self.player);
+ tween(self, {
+ scaleX: 0
+ }, {
+ duration: 150,
+ onFinish: function onFinish() {
+ self.setPlayer(1 - self.player);
+ tween(self, {
+ scaleX: 1
+ }, {
+ duration: 150
+ });
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x1a3a1a
+});
+
+/****
+* Game Code
+****/
+var BOARD_SIZE = 10;
+var CELL_SIZE = 78;
+var BOARD_WIDTH = BOARD_SIZE * CELL_SIZE;
+var board = [];
+var cells = [];
+var currentPlayer = 0; // 0 for orange, 1 for grey
+var moveHistory = [];
+var historyPanel = null;
+var historyVisible = false;
+// Create board container
+var boardContainer = new Container();
+boardContainer.x = 1024;
+boardContainer.y = 1366;
+game.addChild(boardContainer);
+// Create board background
+var boardBg = LK.getAsset('boardBg', {
+ anchorX: 0.5,
+ anchorY: 0.5
+});
+boardContainer.addChild(boardBg);
+// Initialize board array and create cells
+for (var row = 0; row < BOARD_SIZE; row++) {
+ board[row] = [];
+ cells[row] = [];
+ for (var col = 0; col < BOARD_SIZE; col++) {
+ board[row][col] = null;
+ var cell = new Cell();
+ cell.row = row;
+ cell.col = col;
+ cell.x = (col - 4.5) * CELL_SIZE;
+ cell.y = (row - 4.5) * CELL_SIZE;
+ boardContainer.addChild(cell);
+ cells[row][col] = cell;
+ }
+}
+// Create coordinate labels
+var letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];
+for (var i = 0; i < BOARD_SIZE; i++) {
+ // Column labels (A-J)
+ var colLabel = new Text2(letters[i], {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ colLabel.anchor.set(0.5, 0.5);
+ colLabel.x = (i - 4.5) * CELL_SIZE;
+ colLabel.y = -440;
+ boardContainer.addChild(colLabel);
+ // Row labels (1-10)
+ var rowLabel = new Text2((i + 1).toString(), {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ rowLabel.anchor.set(0.5, 0.5);
+ rowLabel.x = -440;
+ rowLabel.y = (i - 4.5) * CELL_SIZE;
+ boardContainer.addChild(rowLabel);
+}
+// Create current player indicator
+var playerText = new Text2('Current Player: Orange', {
+ size: 36,
+ fill: 0xFF8C00
+});
+playerText.anchor.set(0.5, 0);
+playerText.y = 100;
+LK.gui.top.addChild(playerText);
+// Create coordinates button
+var coordButton = new CoordButton();
+coordButton.x = -100;
+coordButton.y = 100;
+LK.gui.topRight.addChild(coordButton);
+// Create history panel (initially hidden)
+historyPanel = new HistoryPanel();
+historyPanel.visible = false;
+game.addChild(historyPanel);
+historyPanel.x = 1024;
+historyPanel.y = 1366;
+// Game functions
+function getCoordinate(row, col) {
+ return letters[col] + (row + 1);
+}
+function placePiece(row, col) {
+ if (board[row][col] !== null) return;
+ // Create and place piece
+ var piece = new Piece();
+ piece.setPlayer(currentPlayer);
+ cells[row][col].addChild(piece);
+ cells[row][col].piece = piece;
+ board[row][col] = currentPlayer;
+ // Play place sound
+ LK.getSound('place').play();
+ // Add to move history
+ moveHistory.push({
+ player: currentPlayer,
+ coord: getCoordinate(row, col)
+ });
+ // Update history panel if visible
+ if (historyVisible && historyPanel) {
+ historyPanel.updateHistory();
+ }
+ // Check for flips in all directions
+ var directions = [[-1, 0], [1, 0], [0, -1], [0, 1],
+ // vertical and horizontal
+ [-1, -1], [-1, 1], [1, -1], [1, 1] // diagonals
+ ];
+ var totalFlips = 0;
+ for (var d = 0; d < directions.length; d++) {
+ var flips = checkDirection(row, col, directions[d][0], directions[d][1]);
+ if (flips.length > 0) {
+ flipPieces(flips);
+ totalFlips += flips.length;
+ }
+ }
+ if (totalFlips > 0) {
+ LK.getSound('flip').play();
+ }
+ // Switch player
+ currentPlayer = 1 - currentPlayer;
+ updatePlayerText();
+ // Check for game over
+ checkGameOver();
+}
+function checkDirection(row, col, dRow, dCol) {
+ var flips = [];
+ var r = row + dRow;
+ var c = col + dCol;
+ // Find opponent pieces
+ while (r >= 0 && r < BOARD_SIZE && c >= 0 && c < BOARD_SIZE) {
+ if (board[r][c] === null) {
+ return [];
+ }
+ if (board[r][c] === currentPlayer) {
+ return flips;
+ }
+ flips.push([r, c]);
+ r += dRow;
+ c += dCol;
+ }
+ return [];
+}
+function flipPieces(positions) {
+ for (var i = 0; i < positions.length; i++) {
+ var row = positions[i][0];
+ var col = positions[i][1];
+ board[row][col] = currentPlayer;
+ cells[row][col].piece.flip();
+ }
+}
+function updatePlayerText() {
+ var player = currentPlayer === 0 ? 'Orange' : 'Grey';
+ var color = currentPlayer === 0 ? '#ff8c00' : '#808080';
+ playerText.setText('Current Player: ' + player);
+ playerText.style.fill = color;
+}
+function checkGameOver() {
+ var hasEmpty = false;
+ var orangeCount = 0;
+ var greyCount = 0;
+ for (var row = 0; row < BOARD_SIZE; row++) {
+ for (var col = 0; col < BOARD_SIZE; col++) {
+ if (board[row][col] === null) {
+ hasEmpty = true;
+ } else if (board[row][col] === 0) {
+ orangeCount++;
+ } else {
+ greyCount++;
+ }
+ }
+ }
+ if (!hasEmpty) {
+ if (orangeCount > greyCount) {
+ LK.showYouWin();
+ } else {
+ LK.showGameOver();
+ }
+ }
+}
+function toggleHistory() {
+ historyVisible = !historyVisible;
+ if (historyPanel) {
+ historyPanel.visible = historyVisible;
+ if (historyVisible) {
+ historyPanel.updateHistory();
+ }
+ }
+}
+// Initialize with starting pieces in center
+placePiece(4, 4);
+placePiece(4, 5);
+placePiece(5, 5);
+placePiece(5, 4);
\ No newline at end of file
Modern App Store icon, high definition, square with rounded corners, different othello game squares cells of wood, different wood, different colors, HD colors, for a game titled "Chorizora Othello" and without the description "A territorial strategy game where players flip opponent pieces by trapping them between their own pieces on a 10x10 grid.". with text on the middle of the icon "Chorizora Othello"!
Button "Coordinate". orange color In-Game asset. High contrast. No shadows. 3D