var board = new Array();
$(document).ready() {
newgame();
}
#function newgame() {
init();
generateOneNumber();
generateOneNumber();
}
## var gridCell = $("#grid-cell-" i "-" j);
gridCell.css ("top" , getPostTop(i, j));
gridCell.css("left", getPostLeft(i, j));
## }# } # updateBoardview();}#function updateBoardview() {
# for (var j = 0; j < 4; j ) {
# $ ("#grid-container").append("
"); # numberCell.css("寬度", 0 px);
# var randx = parseInt(Math.floor(Math.random() * 4));
var randy = parseInt(Math.floor(Math.random() * 4)) );
當(true) {
if (board[randx][randy] == 0) {
中斷;
## } var randx = parseInt(Math.floor(Math.random() * 4)); var randy = parseInt(Math.floor(Math.random() * 4));# } var randNumber = Math.random() < 0.5? 2 : 4; 板[randx][randy] = randNumber; showNumberWithAnimation(randx, randy, randNumber);}