HTML5 Tic-Tac-Toe

I have written a small HTML 5 game. It uses SVG for the presentation and the jQuery Javascript Library. I hope it can serve you as an example for a simple interaction with JavaScript

Try it out or look at the sources in github.

tictactoe

How it works:

The game consists of three files:

  1. tictactoe.html is a HTML 5 file with an embedded SVG graphics representing the playfield.
  2. tictactoe.js contains the javascript code
  3. jquery which is linked in directly from the google CDN

The code in tictactoe.js is using jQuery to hide and show the O’s and X’s in the playfield as the game proceeds.

jQuery is a java script library which makes it easy to manipulate the DOM, i.e. the structure of the document while it is being displayed in the browser. It also abstracts away differences between different browsers. Google hosts several versions of jQuery so you dont even need to have it on your server, only a reference to the google hosted copy is needed. This has the further advantage that the library is possibly already cached when the user has used a different site with jQuery before.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: