HTML and CSS Reference
In-Depth Information
{ type: "pawn", color: "white", row: 6, column: 4, pos: "e2", killed: false },
{ type: "pawn", color: "white", row: 6, column: 5, pos: "f2", killed: false },
{ type: "pawn", color: "white", row: 6, column: 6, pos: "g2", killed: false },
{ type: "pawn", color: "white", row: 6, column: 7, pos: "h2", killed: false },
{ type: "rook", color: "white", row: 7, column: 0, pos: "a1", killed: false },
{ type: "rook", color: "white", row: 7, column: 7, pos: "h1", killed: false },
{ type: "knight", color: "white", row: 7, column: 1, pos: "b12", killed: false },
{ type: "knight", color: "white", row: 7, column: 6, pos: "g1", killed: false },
{ type: "bishop", color: "white", row: 7, column: 2, pos: "c1", killed: false },
{ type: "bishop", color: "white", row: 7, column: 5, pos: "f1", killed: false },
{ type: "queen", color: "white", row: 7, column: 3, pos: "d1", killed: false },
{ type: "king", color: "white", row: 7, column: 4, pos: "e1", killed: false },
{ type: "pawn", color: "black", row: 1, column: 0, pos: "a7", killed: false },
{ type: "pawn", color: "black", row: 1, column: 1, pos: "b7", killed: false },
{ type: "pawn", color: "black", row: 1, column: 2, pos: "c7", killed: false },
{ type: "pawn", color: "black", row: 1, column: 3, pos: "d7", killed: false },
{ type: "pawn", color: "black", row: 1, column: 4, pos: "e7", killed: false },
{ type: "pawn", color: "black", row: 1, column: 5, pos: "f7", killed: false },
{ type: "pawn", color: "black", row: 1, column: 6, pos: "g7", killed: false },
{ type: "pawn", color: "black", row: 1, column: 7, pos: "h7", killed: false },
{ type: "rook", color: "black", row: 0, column: 0, pos: "a8", killed: false },
{ type: "rook", color: "black", row: 0, column: 7, pos: "h8", killed: false },
{ type: "knight", color: "black", row: 0, column: 1, pos: "b8", killed: false },
{ type: "knight", color: "black", row: 0, column: 6, pos: "g8", killed: false },
{ type: "bishop", color: "black", row: 0, column: 2, pos: "c8", killed: false },
{ type: "bishop", color: "black", row: 0, column: 5, pos: "f8", killed: false },
{ type: "queen", color: "black", row: 0, column: 3, pos: "d8", killed: false },
{ type: "king", color: "black", row: 0, column: 4, pos: "e8", killed: false }
];
The pieceTypes[] array defines the properties needed to display each piece such as height and width. It also
specifies the corresponding index in the images[] array for both the black and white images. The pieces[] array
contains the same details used in the previous chapter such as row and column, and defines the starting position
for each of the 32 pieces.
Opening the Database
Add the code shown in Listing 11-4 to the script object, just after the call to drawBoard() (and before the
implementation of the drawBoard() function).
Listing 11-4. Opening the database
var dbEng = window.indexedDB ||
window.webkitIndexedDB || // Chrome
window.mozIndexedDB || // Firefox
window.msIndexedDB; // IE
var db; // This is a handle to the database
 
Search WWH ::




Custom Search