previous

page 6

next

Of course when the game starts, all the cells will be empty and we will need an onClick attribute so we can respond when the player clicks on a cell.

<img src='counters/0.png' class='cell' id='0' cn='0' onClick='cell_clicked(this);'>
<img src='counters/0.png' class='cell' id='1' cn='0' onClick='cell_clicked(this);'>
<img src='counters/0.png' class='cell' id='2' cn='0' onClick='cell_clicked(this);'>
<img src='counters/0.png' class='cell' id='3' cn='0' onClick='cell_clicked(this);'>
<img src='counters/0.png' class='cell' id='4' cn='0' onClick='cell_clicked(this);'>

Wow! But that's it! That is all (all ?) we need to make the game.
Please study the above very carefully, asking yourself what each part is for.
Use the previous pages for checking any uncertainties.

Let's use JavaScript to produce the above 5 lines.
I find the hardest part is getting all the quotes in the right place.
First I observe that the only thing changing is the id number so I copy everything up to the id number like this:

... and paste it between double quotes as the value of variable s1.
Then I copy everything after the id number and paste it into variable s2.

I'll show you what I ended up with on the next page.

previous
next