User prompt
Now it's a draw if:
User prompt
Make it so that the king is the only piece immune to stampede
User prompt
Please fix the bug: 'Uncaught ReferenceError: gameMode is not defined' in or related to this line: 'scoreTxt.setText('Crazy Chess - ' + gameMode.toUpperCase());' Line Number: 1265
User prompt
Please fix the bug: 'Uncaught ReferenceError: gameMode is not defined' in or related to this line: 'scoreTxt.setText('Crazy Chess - ' + gameMode.toUpperCase());' Line Number: 1265
User prompt
CRAZY MODE DOSENT WORK; FIX THAT
User prompt
CRAZY MODE DOSENT WORK; FIX THAT
User prompt
Make buttons bigger and more spaced out
User prompt
When I tap the crazy mode button, it makes me go to classic mode
User prompt
Make the classic mode button stop dancing
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(bg, 0.1, {' Line Number: 368 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add a button that, when you tap crazy mode, makes you go to the crazy mode
User prompt
Make the buttons for each gamemode a little more spaced out
User prompt
Crazy mode is the same as classic mode but the AI has a chance to use some crazy abilities after moving a piece! (Abilities: Freeze: makes a white piece not move for 2 turns; Instant promotion: turns a black piece either into a queen, bishop or rook; Stampede: kills 3 random pieces [black pieces included]; Summon: summons a rook out of nowhere on an empty tile)
User prompt
Crazy mode is the same as classic mode but the AI has crazy abilities!
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(bg, 0.1, {' Line Number: 178 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Now when you tap the "start" Button it makes you go to a game mode screen
User prompt
Add a title screen with the name of the game being "Crazy chess"
Code edit (1 edits merged)
Please save this source code
User prompt
Chess Master
Initial prompt
Chess
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var ChessPiece = Container.expand(function (type, color) {
var self = Container.call(this);
self.type = type;
self.color = color;
self.hasMoved = false;
var pieceId = color + type.charAt(0).toUpperCase() + type.slice(1);
var pieceGraphics = self.attachAsset(pieceId, {
anchorX: 0.5,
anchorY: 0.5
});
var label;
switch (type) {
case 'pawn':
label = '';
break;
case 'rook':
label = 'R';
break;
case 'knight':
label = 'N';
break;
case 'bishop':
label = 'B';
break;
case 'queen':
label = 'Q';
break;
case 'king':
label = 'K';
break;
}
if (label) {
var text = new Text2(label, {
size: 40,
fill: color === 'white' ? "#000000" : "#ffffff"
});
text.anchor.set(0.5, 0.5);
self.addChild(text);
}
return self;
});
var ChessSquare = Container.expand(function (row, col, color) {
var self = Container.call(this);
self.row = row;
self.col = col;
self.color = color;
self.piece = null;
var squareGraphics = self.attachAsset(color === 'white' ? 'whiteSquare' : 'blackSquare', {
anchorX: 0,
anchorY: 0
});
self.highlight = function (type) {
if (type === 'selected') {
squareGraphics.tint = 0x829769;
} else if (type === 'validMove') {
squareGraphics.tint = 0xcdd26a;
} else {
// Reset to original color
squareGraphics.tint = color === 'white' ? 0xf0d9b5 : 0xb58863;
}
};
self.setPiece = function (piece) {
if (self.piece) {
self.removeChild(self.piece);
}
self.piece = piece;
if (piece) {
self.addChild(piece);
piece.x = squareGraphics.width / 2;
piece.y = squareGraphics.height / 2;
}
};
self.down = function (x, y, obj) {
game.selectSquare(self);
};
return self;
});
var GameModeScreen = Container.expand(function () {
var self = Container.call(this);
// Create title text
var titleText = new Text2('Select Game Mode', {
size: 80,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -250;
self.addChild(titleText);
// Create mode buttons
var classicButton = new Text2('CLASSIC', {
size: 60,
fill: 0xFFFFFF
});
classicButton.anchor.set(0.5, 0.5);
classicButton.y = -50;
self.addChild(classicButton);
var crazyButton = new Text2('CRAZY MODE', {
size: 60,
fill: 0xFFFFFF
});
crazyButton.anchor.set(0.5, 0.5);
crazyButton.y = 50;
self.addChild(crazyButton);
var tournamentButton = new Text2('TOURNAMENT', {
size: 60,
fill: 0xFFFFFF
});
tournamentButton.anchor.set(0.5, 0.5);
tournamentButton.y = 150;
self.addChild(tournamentButton);
var backButton = new Text2('< BACK', {
size: 40,
fill: 0xFFFFFF
});
backButton.anchor.set(0.5, 0.5);
backButton.y = 300;
self.addChild(backButton);
// Add highlighting for buttons
var buttons = [classicButton, crazyButton, tournamentButton, backButton];
var buttonBackgrounds = [];
// Create button backgrounds
for (var i = 0; i < buttons.length; i++) {
var btn = buttons[i];
var bg = LK.getAsset('blackSquare', {
anchorX: 0.5,
anchorY: 0.5,
width: btn.width + 40,
height: btn.height + 20,
tint: 0x3a3a3a
});
bg.alpha = 0.7;
bg.x = btn.x;
bg.y = btn.y;
buttonBackgrounds.push(bg);
self.addChild(bg);
self.addChild(btn); // Re-add button to put it on top
}
// Add button hover effects
for (var i = 0; i < buttons.length; i++) {
(function (index) {
var btn = buttons[index];
var bg = buttonBackgrounds[index];
btn.interactive = true;
btn.down = function (x, y, obj) {
// Flash button when clicked
tween(bg, {
alpha: 1
}, {
duration: 100,
onFinish: function onComplete() {
tween(bg, {
alpha: 0.7
}, {
duration: 100
});
}
});
// Handle button action
if (index === 0) {
// Classic mode
game.gameMode = 'classic';
game.startGame();
} else if (index === 1) {
// Crazy mode
game.gameMode = 'crazy';
game.startGame();
} else if (index === 2) {
// Tournament mode
game.gameMode = 'tournament';
game.startGame();
} else if (index === 3) {
// Back button
game.showTitleScreen();
}
};
})(i);
}
// Pulse animation for the first button
var pulseScale = 1;
var increasing = true;
self.update = function () {
// Pulse effect for the Classic button
if (increasing) {
pulseScale += 0.002;
if (pulseScale >= 1.05) {
increasing = false;
}
} else {
pulseScale -= 0.002;
if (pulseScale <= 0.95) {
increasing = true;
}
}
classicButton.scale.set(pulseScale);
buttonBackgrounds[0].scale.set(pulseScale);
};
return self;
});
var TitleScreen = Container.expand(function () {
var self = Container.call(this);
// Create title text
var titleText = new Text2('Crazy Chess', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
self.addChild(titleText);
// Create start button
var startButton = new Text2('TAP TO START', {
size: 60,
fill: 0xFFFFFF
});
startButton.anchor.set(0.5, 0.5);
startButton.y = 200;
self.addChild(startButton);
// Add pulsing animation to the start button
var pulseScale = 1;
var increasing = true;
self.update = function () {
// Pulse effect for start button
if (increasing) {
pulseScale += 0.003;
if (pulseScale >= 1.1) {
increasing = false;
}
} else {
pulseScale -= 0.003;
if (pulseScale <= 0.9) {
increasing = true;
}
}
startButton.scale.set(pulseScale);
};
// Handle tap anywhere to start
self.down = function () {
game.showGameModeScreen();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c2c2c
});
/****
* Game Code
****/
// Game constants
var BOARD_SIZE = 8;
var SQUARE_SIZE = 100;
var BOARD_OFFSET_X = (2048 - BOARD_SIZE * SQUARE_SIZE) / 2;
var BOARD_OFFSET_Y = (2732 - BOARD_SIZE * SQUARE_SIZE) / 2;
// Game state variables
var board = [];
var selectedSquare = null;
var validMoves = [];
var currentPlayer = 'white';
var gameState = 'title'; // 'title', 'modeSelect', 'playing', 'check', 'checkmate', 'stalemate'
var aiThinking = false;
var titleScreen = null;
var gameModeScreen = null;
var gameMode = 'classic'; // 'classic', 'crazy', 'tournament'
// Initialize the chess board
function initializeBoard() {
board = [];
// Create the 8x8 chess board
for (var row = 0; row < BOARD_SIZE; row++) {
board[row] = [];
for (var col = 0; col < BOARD_SIZE; col++) {
var squareColor = (row + col) % 2 === 0 ? 'white' : 'black';
var square = new ChessSquare(row, col, squareColor);
square.x = BOARD_OFFSET_X + col * SQUARE_SIZE;
square.y = BOARD_OFFSET_Y + row * SQUARE_SIZE;
board[row][col] = square;
game.addChild(square);
}
}
// Place the pieces on the board
placePieces();
}
// Place all chess pieces in their starting positions
function placePieces() {
// Place pawns
for (var col = 0; col < BOARD_SIZE; col++) {
board[1][col].setPiece(new ChessPiece('pawn', 'black'));
board[6][col].setPiece(new ChessPiece('pawn', 'white'));
}
// Place rooks
board[0][0].setPiece(new ChessPiece('rook', 'black'));
board[0][7].setPiece(new ChessPiece('rook', 'black'));
board[7][0].setPiece(new ChessPiece('rook', 'white'));
board[7][7].setPiece(new ChessPiece('rook', 'white'));
// Place knights
board[0][1].setPiece(new ChessPiece('knight', 'black'));
board[0][6].setPiece(new ChessPiece('knight', 'black'));
board[7][1].setPiece(new ChessPiece('knight', 'white'));
board[7][6].setPiece(new ChessPiece('knight', 'white'));
// Place bishops
board[0][2].setPiece(new ChessPiece('bishop', 'black'));
board[0][5].setPiece(new ChessPiece('bishop', 'black'));
board[7][2].setPiece(new ChessPiece('bishop', 'white'));
board[7][5].setPiece(new ChessPiece('bishop', 'white'));
// Place queens
board[0][3].setPiece(new ChessPiece('queen', 'black'));
board[7][3].setPiece(new ChessPiece('queen', 'white'));
// Place kings
board[0][4].setPiece(new ChessPiece('king', 'black'));
board[7][4].setPiece(new ChessPiece('king', 'white'));
}
// Select a square on the chess board
game.selectSquare = function (square) {
// If AI is thinking, don't allow moves
if (aiThinking || gameState === 'checkmate' || gameState === 'stalemate') {
return;
}
// If the current player is not the human player, don't allow moves
if (currentPlayer !== 'white') {
return;
}
// Clear previous selections
clearHighlights();
// If a square is already selected and the new square is a valid move
if (selectedSquare && isValidMove(square)) {
// Move the piece
movePiece(selectedSquare, square);
// Reset selection
selectedSquare = null;
validMoves = [];
// Check for check/checkmate
checkGameState();
// If game is still playing, switch to AI turn
if (gameState === 'playing' || gameState === 'check') {
switchPlayer();
// Start AI turn
aiThinking = true;
LK.setTimeout(makeAIMove, 1000);
}
}
// If clicking on a piece of the current player
else if (square.piece && square.piece.color === currentPlayer) {
// Select the square
selectedSquare = square;
square.highlight('selected');
// Calculate valid moves
validMoves = calculateValidMoves(square);
// Highlight valid moves
for (var i = 0; i < validMoves.length; i++) {
var move = validMoves[i];
board[move.row][move.col].highlight('validMove');
}
}
};
// Check if a move to the target square is valid
function isValidMove(targetSquare) {
for (var i = 0; i < validMoves.length; i++) {
var move = validMoves[i];
if (move.row === targetSquare.row && move.col === targetSquare.col) {
return true;
}
}
return false;
}
// Move a piece from one square to another
function movePiece(fromSquare, toSquare) {
var piece = fromSquare.piece;
// Handle capture
if (toSquare.piece) {
LK.getSound('capture').play();
} else {
LK.getSound('move').play();
}
// Move the piece
fromSquare.setPiece(null);
toSquare.setPiece(piece);
// Mark piece as moved (for castling and pawn double move)
piece.hasMoved = true;
// Handle pawn promotion
if (piece.type === 'pawn' && (toSquare.row === 0 || toSquare.row === 7)) {
promotePawn(toSquare);
}
}
// Promote a pawn to a queen or random piece in crazy mode
function promotePawn(square) {
var piece = square.piece;
if (gameMode === 'crazy' && piece.color === 'black') {
// In crazy mode, AI gets random promotions
var randomPiece = Math.random();
var pieceType;
if (randomPiece < 0.3) {
pieceType = 'queen';
} else if (randomPiece < 0.6) {
pieceType = 'rook';
} else if (randomPiece < 0.8) {
pieceType = 'knight';
} else {
pieceType = 'bishop';
}
square.setPiece(new ChessPiece(pieceType, piece.color));
} else {
// Default promotion to queen
square.setPiece(new ChessPiece('queen', piece.color));
}
LK.getSound('promotion').play();
// Show effect for crazy mode AI promotion
if (gameMode === 'crazy' && piece.color === 'black') {
LK.effects.flashObject(square, 0xFF00FF, 500);
var effectText = new Text2("CRAZY PROMOTION!", {
size: 40,
fill: 0xFF00FF
});
effectText.anchor.set(0.5, 0.5);
effectText.x = square.x + SQUARE_SIZE / 2;
effectText.y = square.y - 30;
game.addChild(effectText);
LK.setTimeout(function () {
game.removeChild(effectText);
}, 1500);
}
}
// Clear highlights from all squares
function clearHighlights() {
for (var row = 0; row < BOARD_SIZE; row++) {
for (var col = 0; col < BOARD_SIZE; col++) {
board[row][col].highlight();
}
}
}
// Calculate valid moves for a piece
function calculateValidMoves(square) {
var piece = square.piece;
var moves = [];
if (!piece) {
return moves;
}
var row = square.row;
var col = square.col;
switch (piece.type) {
case 'pawn':
calculatePawnMoves(row, col, piece, moves);
break;
case 'rook':
calculateRookMoves(row, col, piece, moves);
break;
case 'knight':
calculateKnightMoves(row, col, piece, moves);
break;
case 'bishop':
calculateBishopMoves(row, col, piece, moves);
break;
case 'queen':
calculateRookMoves(row, col, piece, moves);
calculateBishopMoves(row, col, piece, moves);
break;
case 'king':
calculateKingMoves(row, col, piece, moves);
break;
}
// Filter out moves that would put the king in check
return filterCheckMoves(square, moves);
}
// Calculate valid moves for a pawn
function calculatePawnMoves(row, col, piece, moves) {
var direction = piece.color === 'white' ? -1 : 1;
// Move forward one square
if (isValidSquare(row + direction, col) && !board[row + direction][col].piece) {
moves.push({
row: row + direction,
col: col
});
// Move forward two squares from starting position
if (!piece.hasMoved && isValidSquare(row + 2 * direction, col) && !board[row + 2 * direction][col].piece) {
moves.push({
row: row + 2 * direction,
col: col
});
}
}
// Captures
var captureDirections = [{
row: direction,
col: -1
}, {
row: direction,
col: 1
}];
// In crazy mode, black pawns can capture diagonally forward AND backward
if (gameMode === 'crazy' && piece.color === 'black') {
captureDirections.push({
row: -direction,
col: -1
});
captureDirections.push({
row: -direction,
col: 1
});
}
for (var i = 0; i < captureDirections.length; i++) {
var dir = captureDirections[i];
var newRow = row + dir.row;
var newCol = col + dir.col;
if (isValidSquare(newRow, newCol) && board[newRow][newCol].piece && board[newRow][newCol].piece.color !== piece.color) {
moves.push({
row: newRow,
col: newCol
});
}
}
}
// Calculate valid moves for a rook
function calculateRookMoves(row, col, piece, moves) {
var directions = [{
row: -1,
col: 0
},
// up
{
row: 1,
col: 0
},
// down
{
row: 0,
col: -1
},
// left
{
row: 0,
col: 1
} // right
];
calculateSlidingMoves(row, col, piece, moves, directions);
}
// Calculate valid moves for a bishop
function calculateBishopMoves(row, col, piece, moves) {
var directions = [{
row: -1,
col: -1
},
// up-left
{
row: -1,
col: 1
},
// up-right
{
row: 1,
col: -1
},
// down-left
{
row: 1,
col: 1
} // down-right
];
calculateSlidingMoves(row, col, piece, moves, directions);
}
// Calculate valid moves for sliding pieces (rook, bishop, queen)
function calculateSlidingMoves(row, col, piece, moves, directions) {
for (var i = 0; i < directions.length; i++) {
var dir = directions[i];
var newRow = row + dir.row;
var newCol = col + dir.col;
while (isValidSquare(newRow, newCol)) {
var targetSquare = board[newRow][newCol];
if (!targetSquare.piece) {
// Empty square, can move here
moves.push({
row: newRow,
col: newCol
});
} else {
// Found a piece
if (targetSquare.piece.color !== piece.color) {
// Can capture opponent's piece
moves.push({
row: newRow,
col: newCol
});
}
// Can't move past a piece
break;
}
newRow += dir.row;
newCol += dir.col;
}
}
}
// Calculate valid moves for a knight
function calculateKnightMoves(row, col, piece, moves) {
var knightDirections = [{
row: -2,
col: -1
}, {
row: -2,
col: 1
}, {
row: -1,
col: -2
}, {
row: -1,
col: 2
}, {
row: 1,
col: -2
}, {
row: 1,
col: 2
}, {
row: 2,
col: -1
}, {
row: 2,
col: 1
}];
for (var i = 0; i < knightDirections.length; i++) {
var dir = knightDirections[i];
var newRow = row + dir.row;
var newCol = col + dir.col;
if (isValidSquare(newRow, newCol)) {
var targetSquare = board[newRow][newCol];
if (!targetSquare.piece || targetSquare.piece.color !== piece.color) {
moves.push({
row: newRow,
col: newCol
});
}
}
}
}
// Calculate valid moves for a king
function calculateKingMoves(row, col, piece, moves) {
var kingDirections = [{
row: -1,
col: -1
}, {
row: -1,
col: 0
}, {
row: -1,
col: 1
}, {
row: 0,
col: -1
}, {
row: 0,
col: 1
}, {
row: 1,
col: -1
}, {
row: 1,
col: 0
}, {
row: 1,
col: 1
}];
for (var i = 0; i < kingDirections.length; i++) {
var dir = kingDirections[i];
var newRow = row + dir.row;
var newCol = col + dir.col;
if (isValidSquare(newRow, newCol)) {
var targetSquare = board[newRow][newCol];
if (!targetSquare.piece || targetSquare.piece.color !== piece.color) {
moves.push({
row: newRow,
col: newCol
});
}
}
}
// Castling
if (!piece.hasMoved) {
// Kingside castling
if (canCastle(row, col, 0, 3)) {
moves.push({
row: row,
col: col + 2
});
}
// Queenside castling
if (canCastle(row, col, 0, -4)) {
moves.push({
row: row,
col: col - 2
});
}
}
}
// Check if castling is possible
function canCastle(row, col, rowOffset, colOffset) {
var rookCol = colOffset > 0 ? 7 : 0;
var rookRow = row;
// Check if there's a rook in the corner
var rookSquare = board[rookRow][rookCol];
if (!rookSquare.piece || rookSquare.piece.type !== 'rook' || rookSquare.piece.hasMoved) {
return false;
}
// Check if there are pieces between the king and the rook
var startCol = Math.min(col, rookCol) + 1;
var endCol = Math.max(col, rookCol) - 1;
for (var c = startCol; c <= endCol; c++) {
if (board[row][c].piece) {
return false;
}
}
// Check if the king would move through or into check
var direction = colOffset > 0 ? 1 : -1;
if (isSquareAttacked(row, col, otherPlayer(currentPlayer)) || isSquareAttacked(row, col + direction, otherPlayer(currentPlayer)) || isSquareAttacked(row, col + 2 * direction, otherPlayer(currentPlayer))) {
return false;
}
return true;
}
// Filter out moves that would put the king in check
function filterCheckMoves(fromSquare, moves) {
var validMoves = [];
var piece = fromSquare.piece;
for (var i = 0; i < moves.length; i++) {
var move = moves[i];
// Simulate the move
var originalPiece = board[move.row][move.col].piece;
board[move.row][move.col].piece = piece;
board[fromSquare.row][fromSquare.col].piece = null;
// Check if the king is in check after the move
var inCheck = isKingInCheck(piece.color);
// Undo the move
board[fromSquare.row][fromSquare.col].piece = piece;
board[move.row][move.col].piece = originalPiece;
if (!inCheck) {
validMoves.push(move);
}
}
return validMoves;
}
// Check if a square is valid (within the board)
function isValidSquare(row, col) {
return row >= 0 && row < BOARD_SIZE && col >= 0 && col < BOARD_SIZE;
}
// Check if the king is in check
function isKingInCheck(color) {
// Find the king
var kingSquare = findKing(color);
if (!kingSquare) {
return false;
}
// Check if the king is attacked by any opponent's piece
return isSquareAttacked(kingSquare.row, kingSquare.col, otherPlayer(color));
}
// Check if a square is attacked by any piece of the given color
function isSquareAttacked(row, col, attackerColor) {
for (var r = 0; r < BOARD_SIZE; r++) {
for (var c = 0; c < BOARD_SIZE; c++) {
var square = board[r][c];
if (square.piece && square.piece.color === attackerColor) {
var moves = [];
switch (square.piece.type) {
case 'pawn':
// Pawns attack diagonally
var direction = square.piece.color === 'white' ? -1 : 1;
var attackDirections = [{
row: direction,
col: -1
}, {
row: direction,
col: 1
}];
for (var i = 0; i < attackDirections.length; i++) {
var dir = attackDirections[i];
var attackRow = r + dir.row;
var attackCol = c + dir.col;
if (attackRow === row && attackCol === col) {
return true;
}
}
break;
case 'rook':
calculateRookMoves(r, c, square.piece, moves);
break;
case 'knight':
calculateKnightMoves(r, c, square.piece, moves);
break;
case 'bishop':
calculateBishopMoves(r, c, square.piece, moves);
break;
case 'queen':
calculateRookMoves(r, c, square.piece, moves);
calculateBishopMoves(r, c, square.piece, moves);
break;
case 'king':
var kingDirections = [{
row: -1,
col: -1
}, {
row: -1,
col: 0
}, {
row: -1,
col: 1
}, {
row: 0,
col: -1
}, {
row: 0,
col: 1
}, {
row: 1,
col: -1
}, {
row: 1,
col: 0
}, {
row: 1,
col: 1
}];
for (var i = 0; i < kingDirections.length; i++) {
var dir = kingDirections[i];
var attackRow = r + dir.row;
var attackCol = c + dir.col;
if (attackRow === row && attackCol === col) {
return true;
}
}
break;
}
// Check if the square is in the list of moves
for (var i = 0; i < moves.length; i++) {
var move = moves[i];
if (move.row === row && move.col === col) {
return true;
}
}
}
}
}
return false;
}
// Find the king of the given color
function findKing(color) {
for (var row = 0; row < BOARD_SIZE; row++) {
for (var col = 0; col < BOARD_SIZE; col++) {
var square = board[row][col];
if (square.piece && square.piece.type === 'king' && square.piece.color === color) {
return {
row: row,
col: col
};
}
}
}
return null;
}
// Get the other player's color
function otherPlayer(color) {
return color === 'white' ? 'black' : 'white';
}
// Switch the current player
function switchPlayer() {
currentPlayer = otherPlayer(currentPlayer);
}
// Check the game state (check, checkmate, stalemate)
function checkGameState() {
// Check if the current player's king is in check
var inCheck = isKingInCheck(currentPlayer);
// Get all possible moves for the current player
var allMoves = getAllPossibleMoves(currentPlayer);
if (inCheck) {
if (allMoves.length === 0) {
// Checkmate
gameState = 'checkmate';
endGame(otherPlayer(currentPlayer) + ' wins by checkmate!');
} else {
// Check
gameState = 'check';
LK.getSound('check').play();
}
} else if (allMoves.length === 0) {
// Stalemate
gameState = 'stalemate';
endGame('Draw by stalemate!');
} else {
gameState = 'playing';
}
}
// Get all possible moves for a player
function getAllPossibleMoves(color) {
var allMoves = [];
for (var row = 0; row < BOARD_SIZE; row++) {
for (var col = 0; col < BOARD_SIZE; col++) {
var square = board[row][col];
if (square.piece && square.piece.color === color) {
var moves = calculateValidMoves(square);
for (var i = 0; i < moves.length; i++) {
allMoves.push({
fromRow: row,
fromCol: col,
toRow: moves[i].row,
toCol: moves[i].col
});
}
}
}
}
return allMoves;
}
// End the game
function endGame(message) {
var gameOverText = new Text2(message, {
size: 60,
fill: 0xFFFFFF
});
gameOverText.anchor.set(0.5, 0.5);
gameOverText.x = 2048 / 2;
gameOverText.y = 200;
game.addChild(gameOverText);
// Update score based on winner
if (gameState === 'checkmate') {
if (currentPlayer === 'black') {
// White wins
LK.setScore(100);
} else {
// Black wins (AI wins)
LK.setScore(0);
}
} else {
// Draw
LK.setScore(50);
}
// Show game over after a short delay
LK.setTimeout(function () {
LK.showGameOver();
}, 3000);
}
// Make an AI move
function makeAIMove() {
if (gameState === 'checkmate' || gameState === 'stalemate') {
aiThinking = false;
return;
}
// Get all possible moves for the AI
var possibleMoves = getAllPossibleMoves('black');
if (possibleMoves.length === 0) {
aiThinking = false;
return;
}
// In crazy mode, the AI has special abilities
if (gameMode === 'crazy') {
// Randomly decide to use a special ability (30% chance)
if (Math.random() < 0.3) {
// Choose a random special ability
var specialAbility = Math.floor(Math.random() * 3);
switch (specialAbility) {
case 0:
// Super Knight - Knight can move to any empty square
applyKnightSpecialMove();
return;
case 1:
// Queen Dupe - Create a duplicate queen if possible
if (applyQueenDuplication()) {
return;
}
break;
case 2:
// Pawn Storm - Advance all pawns one space
if (applyPawnStorm()) {
return;
}
break;
}
}
}
// Standard move logic if no special ability was used
// Simple AI: pick a random move (with some weight toward captures)
var bestMove = null;
var bestScore = -1;
for (var i = 0; i < possibleMoves.length; i++) {
var move = possibleMoves[i];
var score = 0;
// Target square
var targetSquare = board[move.toRow][move.toCol];
// Prioritize captures
if (targetSquare.piece) {
// Score based on piece value
if (targetSquare.piece.type === 'pawn') {
score = 1;
} else if (targetSquare.piece.type === 'knight' || targetSquare.piece.type === 'bishop') {
score = 3;
} else if (targetSquare.piece.type === 'rook') {
score = 5;
} else if (targetSquare.piece.type === 'queen') {
score = 9;
}
}
// Add some randomness
score += Math.random();
if (score > bestScore) {
bestScore = score;
bestMove = move;
}
}
// If we couldn't find a better move, pick a random one
if (!bestMove) {
bestMove = possibleMoves[Math.floor(Math.random() * possibleMoves.length)];
}
// Make the move
var fromSquare = board[bestMove.fromRow][bestMove.fromCol];
var toSquare = board[bestMove.toRow][bestMove.toCol];
// Highlight the selected square
fromSquare.highlight('selected');
// Wait a bit before making the move
LK.setTimeout(function () {
// Move the piece
movePiece(fromSquare, toSquare);
// Clear highlights
clearHighlights();
// Check for check/checkmate
checkGameState();
// Switch back to player
switchPlayer();
// AI turn is over
aiThinking = false;
}, 500);
}
// Create score display
var scoreTxt = new Text2('Crazy Chess', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create turn display
var turnText = new Text2('Your Turn', {
size: 40,
fill: 0xFFFFFF
});
turnText.anchor.set(0.5, 0);
turnText.y = 70;
LK.gui.top.addChild(turnText);
// Special ability: Super Knight - A knight can teleport to any empty square
function applyKnightSpecialMove() {
// Find a knight
var knightSquare = null;
for (var row = 0; row < BOARD_SIZE; row++) {
for (var col = 0; col < BOARD_SIZE; col++) {
if (board[row][col].piece && board[row][col].piece.color === 'black' && board[row][col].piece.type === 'knight') {
knightSquare = board[row][col];
break;
}
}
if (knightSquare) {
break;
}
}
if (!knightSquare) {
return false;
}
// Find an empty square to teleport to
var emptySquares = [];
for (var row = 0; row < BOARD_SIZE; row++) {
for (var col = 0; col < BOARD_SIZE; col++) {
// Find squares that aren't next to the player's king
var kingSquare = findKing('white');
var distToKing = Math.abs(row - kingSquare.row) + Math.abs(col - kingSquare.col);
if (!board[row][col].piece && distToKing < 4 && Math.random() < 0.7) {
emptySquares.push(board[row][col]);
} else if (!board[row][col].piece) {
emptySquares.push(board[row][col]);
}
}
}
if (emptySquares.length === 0) {
return false;
}
// Pick a random empty square
var targetSquare = emptySquares[Math.floor(Math.random() * emptySquares.length)];
// Flash effect on knight
LK.effects.flashObject(knightSquare, 0x9900FF, 500);
// Wait a bit then teleport
LK.setTimeout(function () {
knightSquare.highlight('selected');
// Show message
var effectText = new Text2("SUPER KNIGHT!", {
size: 40,
fill: 0x9900FF
});
effectText.anchor.set(0.5, 0.5);
effectText.x = knightSquare.x + SQUARE_SIZE / 2;
effectText.y = knightSquare.y - 30;
game.addChild(effectText);
LK.setTimeout(function () {
// Teleport the knight
var knight = knightSquare.piece;
knightSquare.setPiece(null);
targetSquare.setPiece(knight);
knight.hasMoved = true;
// Flash effect on destination
LK.effects.flashObject(targetSquare, 0x9900FF, 500);
// Remove effect text
game.removeChild(effectText);
// Clear highlights
clearHighlights();
// Check game state
checkGameState();
// Switch back to player
switchPlayer();
// AI turn is over
aiThinking = false;
}, 1000);
}, 500);
return true;
}
// Special ability: Queen Duplication - Create a copy of the queen if possible
function applyQueenDuplication() {
// Find the queen
var queenSquare = null;
for (var row = 0; row < BOARD_SIZE; row++) {
for (var col = 0; col < BOARD_SIZE; col++) {
if (board[row][col].piece && board[row][col].piece.color === 'black' && board[row][col].piece.type === 'queen') {
queenSquare = board[row][col];
break;
}
}
if (queenSquare) {
break;
}
}
if (!queenSquare) {
return false;
}
// Find an empty square next to the queen
var directions = [{
row: -1,
col: -1
}, {
row: -1,
col: 0
}, {
row: -1,
col: 1
}, {
row: 0,
col: -1
}, {
row: 0,
col: 1
}, {
row: 1,
col: -1
}, {
row: 1,
col: 0
}, {
row: 1,
col: 1
}];
var emptySquares = [];
for (var i = 0; i < directions.length; i++) {
var dir = directions[i];
var newRow = queenSquare.row + dir.row;
var newCol = queenSquare.col + dir.col;
if (isValidSquare(newRow, newCol) && !board[newRow][newCol].piece) {
emptySquares.push(board[newRow][newCol]);
}
}
if (emptySquares.length === 0) {
return false;
}
// Pick a random empty square
var targetSquare = emptySquares[Math.floor(Math.random() * emptySquares.length)];
// Flash effect on queen
LK.effects.flashObject(queenSquare, 0xFF00FF, 500);
// Wait a bit then duplicate
LK.setTimeout(function () {
queenSquare.highlight('selected');
// Show message
var effectText = new Text2("QUEEN DUPLICATE!", {
size: 40,
fill: 0xFF00FF
});
effectText.anchor.set(0.5, 0.5);
effectText.x = queenSquare.x + SQUARE_SIZE / 2;
effectText.y = queenSquare.y - 30;
game.addChild(effectText);
LK.setTimeout(function () {
// Create a duplicate queen (actually a pawn that looks like a queen)
var newPawn = new ChessPiece('pawn', 'black');
targetSquare.setPiece(newPawn);
// Flash effect on new queen
LK.effects.flashObject(targetSquare, 0xFF00FF, 500);
// Remove effect text
game.removeChild(effectText);
// Clear highlights
clearHighlights();
// Check game state
checkGameState();
// Switch back to player
switchPlayer();
// AI turn is over
aiThinking = false;
}, 1000);
}, 500);
return true;
}
// Special ability: Pawn Storm - Advance all pawns forward one square if possible
function applyPawnStorm() {
// Find all pawns
var pawnSquares = [];
for (var row = 0; row < BOARD_SIZE; row++) {
for (var col = 0; col < BOARD_SIZE; col++) {
if (board[row][col].piece && board[row][col].piece.color === 'black' && board[row][col].piece.type === 'pawn') {
pawnSquares.push(board[row][col]);
}
}
}
if (pawnSquares.length === 0) {
return false;
}
// Check if any pawn can move forward
var canMove = false;
var movablePawns = [];
for (var i = 0; i < pawnSquares.length; i++) {
var pawnSquare = pawnSquares[i];
var forwardRow = pawnSquare.row + 1;
var forwardCol = pawnSquare.col;
if (isValidSquare(forwardRow, forwardCol) && !board[forwardRow][forwardCol].piece) {
canMove = true;
movablePawns.push({
from: pawnSquare,
to: board[forwardRow][forwardCol]
});
}
}
if (!canMove) {
return false;
}
// Flash effect on all pawns
for (var i = 0; i < pawnSquares.length; i++) {
LK.effects.flashObject(pawnSquares[i], 0x00FFFF, 500);
}
// Show message
var effectText = new Text2("PAWN STORM!", {
size: 60,
fill: 0x00FFFF
});
effectText.anchor.set(0.5, 0.5);
effectText.x = 2048 / 2;
effectText.y = 200;
game.addChild(effectText);
// Wait a bit then move all pawns forward
LK.setTimeout(function () {
// Move all pawns that can move
for (var i = 0; i < movablePawns.length; i++) {
var move = movablePawns[i];
movePiece(move.from, move.to);
}
// Remove effect text
game.removeChild(effectText);
// Clear highlights
clearHighlights();
// Check game state
checkGameState();
// Switch back to player
switchPlayer();
// AI turn is over
aiThinking = false;
}, 1000);
return true;
}
// Game update function
game.update = function () {
// If in title screen, update title screen
if (gameState === 'title' && titleScreen) {
titleScreen.update();
return;
}
// If in game mode selection screen, update that screen
if (gameState === 'modeSelect' && gameModeScreen) {
gameModeScreen.update();
return;
}
// Update turn text
if (gameState === 'checkmate') {
if (currentPlayer === 'black') {
turnText.setText('You Win!');
} else {
turnText.setText('AI Wins!');
}
} else if (gameState === 'stalemate') {
turnText.setText('Draw!');
} else if (aiThinking) {
turnText.setText('AI Thinking...');
} else {
turnText.setText(currentPlayer === 'white' ? 'Your Turn' : 'AI Turn');
}
};
// Method to show the game mode selection screen
game.showGameModeScreen = function () {
// Remove title screen if it exists
if (titleScreen) {
game.removeChild(titleScreen);
titleScreen = null;
}
// Remove game mode screen if it already exists
if (gameModeScreen) {
game.removeChild(gameModeScreen);
}
// Create and add game mode screen
gameModeScreen = new GameModeScreen();
gameModeScreen.x = 2048 / 2;
gameModeScreen.y = 2732 / 2;
game.addChild(gameModeScreen);
// Update game state
gameState = 'modeSelect';
};
// Method to show the title screen
game.showTitleScreen = function () {
// Remove game mode screen if it exists
if (gameModeScreen) {
game.removeChild(gameModeScreen);
gameModeScreen = null;
}
// Create and add title screen
titleScreen = new TitleScreen();
titleScreen.x = 2048 / 2;
titleScreen.y = 2732 / 2;
game.addChild(titleScreen);
// Update game state
gameState = 'title';
};
// Method to start the game from mode selection screen
game.startGame = function () {
// Remove game mode screen if it exists
if (gameModeScreen) {
game.removeChild(gameModeScreen);
gameModeScreen = null;
}
// Change state to playing
gameState = 'playing';
// Update game title based on selected mode
scoreTxt.setText('Crazy Chess - ' + gameMode.toUpperCase());
// Initialize the chess board
initializeBoard();
// Show the score and turn text
scoreTxt.visible = true;
turnText.visible = true;
};
// Show title screen first
titleScreen = new TitleScreen();
titleScreen.x = 2048 / 2;
titleScreen.y = 2732 / 2;
game.addChild(titleScreen);
// Hide score and turn text initially
scoreTxt.visible = false;
turnText.visible = false;
; ===================================================================
--- original.js
+++ change.js
@@ -389,13 +389,45 @@
if (piece.type === 'pawn' && (toSquare.row === 0 || toSquare.row === 7)) {
promotePawn(toSquare);
}
}
-// Promote a pawn to a queen
+// Promote a pawn to a queen or random piece in crazy mode
function promotePawn(square) {
var piece = square.piece;
- square.setPiece(new ChessPiece('queen', piece.color));
+ if (gameMode === 'crazy' && piece.color === 'black') {
+ // In crazy mode, AI gets random promotions
+ var randomPiece = Math.random();
+ var pieceType;
+ if (randomPiece < 0.3) {
+ pieceType = 'queen';
+ } else if (randomPiece < 0.6) {
+ pieceType = 'rook';
+ } else if (randomPiece < 0.8) {
+ pieceType = 'knight';
+ } else {
+ pieceType = 'bishop';
+ }
+ square.setPiece(new ChessPiece(pieceType, piece.color));
+ } else {
+ // Default promotion to queen
+ square.setPiece(new ChessPiece('queen', piece.color));
+ }
LK.getSound('promotion').play();
+ // Show effect for crazy mode AI promotion
+ if (gameMode === 'crazy' && piece.color === 'black') {
+ LK.effects.flashObject(square, 0xFF00FF, 500);
+ var effectText = new Text2("CRAZY PROMOTION!", {
+ size: 40,
+ fill: 0xFF00FF
+ });
+ effectText.anchor.set(0.5, 0.5);
+ effectText.x = square.x + SQUARE_SIZE / 2;
+ effectText.y = square.y - 30;
+ game.addChild(effectText);
+ LK.setTimeout(function () {
+ game.removeChild(effectText);
+ }, 1500);
+ }
}
// Clear highlights from all squares
function clearHighlights() {
for (var row = 0; row < BOARD_SIZE; row++) {
@@ -461,8 +493,19 @@
}, {
row: direction,
col: 1
}];
+ // In crazy mode, black pawns can capture diagonally forward AND backward
+ if (gameMode === 'crazy' && piece.color === 'black') {
+ captureDirections.push({
+ row: -direction,
+ col: -1
+ });
+ captureDirections.push({
+ row: -direction,
+ col: 1
+ });
+ }
for (var i = 0; i < captureDirections.length; i++) {
var dir = captureDirections[i];
var newRow = row + dir.row;
var newCol = col + dir.col;
@@ -908,13 +951,70 @@
if (possibleMoves.length === 0) {
aiThinking = false;
return;
}
- // Simple AI: pick a random move
- var randomMove = possibleMoves[Math.floor(Math.random() * possibleMoves.length)];
+ // In crazy mode, the AI has special abilities
+ if (gameMode === 'crazy') {
+ // Randomly decide to use a special ability (30% chance)
+ if (Math.random() < 0.3) {
+ // Choose a random special ability
+ var specialAbility = Math.floor(Math.random() * 3);
+ switch (specialAbility) {
+ case 0:
+ // Super Knight - Knight can move to any empty square
+ applyKnightSpecialMove();
+ return;
+ case 1:
+ // Queen Dupe - Create a duplicate queen if possible
+ if (applyQueenDuplication()) {
+ return;
+ }
+ break;
+ case 2:
+ // Pawn Storm - Advance all pawns one space
+ if (applyPawnStorm()) {
+ return;
+ }
+ break;
+ }
+ }
+ }
+ // Standard move logic if no special ability was used
+ // Simple AI: pick a random move (with some weight toward captures)
+ var bestMove = null;
+ var bestScore = -1;
+ for (var i = 0; i < possibleMoves.length; i++) {
+ var move = possibleMoves[i];
+ var score = 0;
+ // Target square
+ var targetSquare = board[move.toRow][move.toCol];
+ // Prioritize captures
+ if (targetSquare.piece) {
+ // Score based on piece value
+ if (targetSquare.piece.type === 'pawn') {
+ score = 1;
+ } else if (targetSquare.piece.type === 'knight' || targetSquare.piece.type === 'bishop') {
+ score = 3;
+ } else if (targetSquare.piece.type === 'rook') {
+ score = 5;
+ } else if (targetSquare.piece.type === 'queen') {
+ score = 9;
+ }
+ }
+ // Add some randomness
+ score += Math.random();
+ if (score > bestScore) {
+ bestScore = score;
+ bestMove = move;
+ }
+ }
+ // If we couldn't find a better move, pick a random one
+ if (!bestMove) {
+ bestMove = possibleMoves[Math.floor(Math.random() * possibleMoves.length)];
+ }
// Make the move
- var fromSquare = board[randomMove.fromRow][randomMove.fromCol];
- var toSquare = board[randomMove.toRow][randomMove.toCol];
+ var fromSquare = board[bestMove.fromRow][bestMove.fromCol];
+ var toSquare = board[bestMove.toRow][bestMove.toCol];
// Highlight the selected square
fromSquare.highlight('selected');
// Wait a bit before making the move
LK.setTimeout(function () {
@@ -944,8 +1044,238 @@
});
turnText.anchor.set(0.5, 0);
turnText.y = 70;
LK.gui.top.addChild(turnText);
+// Special ability: Super Knight - A knight can teleport to any empty square
+function applyKnightSpecialMove() {
+ // Find a knight
+ var knightSquare = null;
+ for (var row = 0; row < BOARD_SIZE; row++) {
+ for (var col = 0; col < BOARD_SIZE; col++) {
+ if (board[row][col].piece && board[row][col].piece.color === 'black' && board[row][col].piece.type === 'knight') {
+ knightSquare = board[row][col];
+ break;
+ }
+ }
+ if (knightSquare) {
+ break;
+ }
+ }
+ if (!knightSquare) {
+ return false;
+ }
+ // Find an empty square to teleport to
+ var emptySquares = [];
+ for (var row = 0; row < BOARD_SIZE; row++) {
+ for (var col = 0; col < BOARD_SIZE; col++) {
+ // Find squares that aren't next to the player's king
+ var kingSquare = findKing('white');
+ var distToKing = Math.abs(row - kingSquare.row) + Math.abs(col - kingSquare.col);
+ if (!board[row][col].piece && distToKing < 4 && Math.random() < 0.7) {
+ emptySquares.push(board[row][col]);
+ } else if (!board[row][col].piece) {
+ emptySquares.push(board[row][col]);
+ }
+ }
+ }
+ if (emptySquares.length === 0) {
+ return false;
+ }
+ // Pick a random empty square
+ var targetSquare = emptySquares[Math.floor(Math.random() * emptySquares.length)];
+ // Flash effect on knight
+ LK.effects.flashObject(knightSquare, 0x9900FF, 500);
+ // Wait a bit then teleport
+ LK.setTimeout(function () {
+ knightSquare.highlight('selected');
+ // Show message
+ var effectText = new Text2("SUPER KNIGHT!", {
+ size: 40,
+ fill: 0x9900FF
+ });
+ effectText.anchor.set(0.5, 0.5);
+ effectText.x = knightSquare.x + SQUARE_SIZE / 2;
+ effectText.y = knightSquare.y - 30;
+ game.addChild(effectText);
+ LK.setTimeout(function () {
+ // Teleport the knight
+ var knight = knightSquare.piece;
+ knightSquare.setPiece(null);
+ targetSquare.setPiece(knight);
+ knight.hasMoved = true;
+ // Flash effect on destination
+ LK.effects.flashObject(targetSquare, 0x9900FF, 500);
+ // Remove effect text
+ game.removeChild(effectText);
+ // Clear highlights
+ clearHighlights();
+ // Check game state
+ checkGameState();
+ // Switch back to player
+ switchPlayer();
+ // AI turn is over
+ aiThinking = false;
+ }, 1000);
+ }, 500);
+ return true;
+}
+// Special ability: Queen Duplication - Create a copy of the queen if possible
+function applyQueenDuplication() {
+ // Find the queen
+ var queenSquare = null;
+ for (var row = 0; row < BOARD_SIZE; row++) {
+ for (var col = 0; col < BOARD_SIZE; col++) {
+ if (board[row][col].piece && board[row][col].piece.color === 'black' && board[row][col].piece.type === 'queen') {
+ queenSquare = board[row][col];
+ break;
+ }
+ }
+ if (queenSquare) {
+ break;
+ }
+ }
+ if (!queenSquare) {
+ return false;
+ }
+ // Find an empty square next to the queen
+ var directions = [{
+ row: -1,
+ col: -1
+ }, {
+ row: -1,
+ col: 0
+ }, {
+ row: -1,
+ col: 1
+ }, {
+ row: 0,
+ col: -1
+ }, {
+ row: 0,
+ col: 1
+ }, {
+ row: 1,
+ col: -1
+ }, {
+ row: 1,
+ col: 0
+ }, {
+ row: 1,
+ col: 1
+ }];
+ var emptySquares = [];
+ for (var i = 0; i < directions.length; i++) {
+ var dir = directions[i];
+ var newRow = queenSquare.row + dir.row;
+ var newCol = queenSquare.col + dir.col;
+ if (isValidSquare(newRow, newCol) && !board[newRow][newCol].piece) {
+ emptySquares.push(board[newRow][newCol]);
+ }
+ }
+ if (emptySquares.length === 0) {
+ return false;
+ }
+ // Pick a random empty square
+ var targetSquare = emptySquares[Math.floor(Math.random() * emptySquares.length)];
+ // Flash effect on queen
+ LK.effects.flashObject(queenSquare, 0xFF00FF, 500);
+ // Wait a bit then duplicate
+ LK.setTimeout(function () {
+ queenSquare.highlight('selected');
+ // Show message
+ var effectText = new Text2("QUEEN DUPLICATE!", {
+ size: 40,
+ fill: 0xFF00FF
+ });
+ effectText.anchor.set(0.5, 0.5);
+ effectText.x = queenSquare.x + SQUARE_SIZE / 2;
+ effectText.y = queenSquare.y - 30;
+ game.addChild(effectText);
+ LK.setTimeout(function () {
+ // Create a duplicate queen (actually a pawn that looks like a queen)
+ var newPawn = new ChessPiece('pawn', 'black');
+ targetSquare.setPiece(newPawn);
+ // Flash effect on new queen
+ LK.effects.flashObject(targetSquare, 0xFF00FF, 500);
+ // Remove effect text
+ game.removeChild(effectText);
+ // Clear highlights
+ clearHighlights();
+ // Check game state
+ checkGameState();
+ // Switch back to player
+ switchPlayer();
+ // AI turn is over
+ aiThinking = false;
+ }, 1000);
+ }, 500);
+ return true;
+}
+// Special ability: Pawn Storm - Advance all pawns forward one square if possible
+function applyPawnStorm() {
+ // Find all pawns
+ var pawnSquares = [];
+ for (var row = 0; row < BOARD_SIZE; row++) {
+ for (var col = 0; col < BOARD_SIZE; col++) {
+ if (board[row][col].piece && board[row][col].piece.color === 'black' && board[row][col].piece.type === 'pawn') {
+ pawnSquares.push(board[row][col]);
+ }
+ }
+ }
+ if (pawnSquares.length === 0) {
+ return false;
+ }
+ // Check if any pawn can move forward
+ var canMove = false;
+ var movablePawns = [];
+ for (var i = 0; i < pawnSquares.length; i++) {
+ var pawnSquare = pawnSquares[i];
+ var forwardRow = pawnSquare.row + 1;
+ var forwardCol = pawnSquare.col;
+ if (isValidSquare(forwardRow, forwardCol) && !board[forwardRow][forwardCol].piece) {
+ canMove = true;
+ movablePawns.push({
+ from: pawnSquare,
+ to: board[forwardRow][forwardCol]
+ });
+ }
+ }
+ if (!canMove) {
+ return false;
+ }
+ // Flash effect on all pawns
+ for (var i = 0; i < pawnSquares.length; i++) {
+ LK.effects.flashObject(pawnSquares[i], 0x00FFFF, 500);
+ }
+ // Show message
+ var effectText = new Text2("PAWN STORM!", {
+ size: 60,
+ fill: 0x00FFFF
+ });
+ effectText.anchor.set(0.5, 0.5);
+ effectText.x = 2048 / 2;
+ effectText.y = 200;
+ game.addChild(effectText);
+ // Wait a bit then move all pawns forward
+ LK.setTimeout(function () {
+ // Move all pawns that can move
+ for (var i = 0; i < movablePawns.length; i++) {
+ var move = movablePawns[i];
+ movePiece(move.from, move.to);
+ }
+ // Remove effect text
+ game.removeChild(effectText);
+ // Clear highlights
+ clearHighlights();
+ // Check game state
+ checkGameState();
+ // Switch back to player
+ switchPlayer();
+ // AI turn is over
+ aiThinking = false;
+ }, 1000);
+ return true;
+}
// Game update function
game.update = function () {
// If in title screen, update title screen
if (gameState === 'title' && titleScreen) {
Black horse. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
White horse. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Black lawnmower. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
White lawnmower. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Black crown. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
White crown. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
White cannon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Black cannon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Black queen. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
White queen. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Black pawn. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
White pawn. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
White goat. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Bear trap. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows