HTML and CSS Reference
In-Depth Information
if (moveNumber === 6) {
pieces[7].y++;
}
if (moveNumber === 7) {
pieces[30].x = 5;
pieces[30].y = 1;
pieces[5].killed = true;
clearInterval(timer);
}
moveNumber++;
drawBoard();
drawAllPieces();
if (moveNumber > 7) {
chessContext.font = "30 pt Arial";
chessContext.fillStyle = "black";
chessContext.fillText("Checkmate!", 200, 220);
}
}
return inner;
}
3.
Go to the beginning of the script element and replace the call to drawAllPieces()
with this:
timer = setInterval(makeNextMove(), 2000);
4.
save your changes and press F5 to start the application. After a series of moves the
page should look like Figure 10-5 .
Figure 10-5. The completed chess board
 
Search WWH ::




Custom Search