This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0x07 = 7 | |
0x17 = 7 + 16 | |
0x27 = 7 + 16 +16 | |
0x37 = 7 + 16 + 16 + 16 | |
0x47 = 7 + 16 + 16 + 16 + 16 | |
0x57 = 7 + 16 + 16 + 16 + 16 + 16 | |
// etc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
drawBoard(board); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPieceName(pieceValue){ | |
switch (pieceValue) { | |
case WHITE_KING: | |
return 'WHITE_KING'; | |
break; | |
case WHITE_QUEEN: | |
return 'WHITE_QUEEN'; | |
break; | |
case WHITE_ROOK: | |
return 'WHITE_ROOK'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#board { | |
height: 400px; | |
width: 400px; | |
} | |
#board .column { | |
height: 50px; | |
width: 50px; | |
background: #fee472; | |
float: left; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#board .column .WHITE_KNIGHT { | |
background: url('../images/wKnight.png'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="column dark"> | |
<div class="WHITE_KNIGHT"></div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function drawBoard(board){ | |
var str = ''; | |
for( var i = 0 ; i < 8 ; i++ ){ | |
str += '<div class="row">'; | |
for( var j = 0 ; j < 8 ; j++ ){ | |
str += '<div class="column ' + | |
( (i + j) % 2 === 0 ? 'light': 'dark') + '">' + | |
'<div class="' + getPieceName(board[i][j]) + '"></div>' + | |
'</div>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var board = [[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var board = [[BLACK_ROOK, BLACK_KNIGHT, BLACK_BISHOP, BLACK_QUEEN, BLACK_KING, BLACK_BISHOP, BLACK_KNIGHT, BLACK_ROOK], | |
[BLACK_PAWN, BLACK_PAWN, BLACK_PAWN, BLACK_PAWN, BLACK_PAWN, BLACK_PAWN, BLACK_PAWN, BLACK_PAWN], | |
[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0], | |
[0,0,0,0,0,0,0,0], | |
[WHITE_PAWN, WHITE_PAWN, WHITE_PAWN, WHITE_PAWN, WHITE_PAWN, WHITE_PAWN, WHITE_PAWN, WHITE_PAWN], | |
[WHITE_ROOK, WHITE_KNIGHT, WHITE_BISHOP, WHITE_QUEEN, WHITE_KING, WHITE_BISHOP, WHITE_KNIGHT, WHITE_ROOK]]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var WHITE_KING = 100; | |
var WHITE_QUEEN = 90; | |
var WHITE_ROOK = 50; | |
var WHITE_BISHOP = 31; | |
var WHITE_KNIGHT = 30; | |
var WHITE_PAWN = 10; | |
var BLACK_KING = -WHITE_KING; | |
var BLACK_QUEEN = -WHITE_QUEEN; | |
var BLACK_ROOK = -WHITE_ROOK; |