previous

page 8

next
square_clicked function
function square_clicked(el) {
if (g_player && g_squares[el.id]==0) {
g_player=false;
do_x(el.id);
if (check()) {
show_result();
} else {
setTimeout(computer,2000);
}
}
}

Notice I've also added a check that the player is clicking on an empty square.

computer function
...
do_x(id);
g_player=true;
return; // all done
...

Well, you should now have a game that is working reasonably well.

Time to have a look at what else we can add to make the game even better.

If you'd like to use my images, you can download them here.

previous
next