02.02.2013 Views

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

Flash MX 2004 Games : Art to ActionScript

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5 cBoard = new Array(64);<br />

6 pBoard = new Array(64);<br />

7 makeBoard();<br />

8 initGame();<br />

9 s<strong>to</strong>p();<br />

Listing 16.1<br />

Chapter 16: Board games<br />

The arrays are used throughout the program <strong>to</strong> s<strong>to</strong>re the data needed. The array ‘flip’ s<strong>to</strong>res<br />

which directions from a given square have a line that can be flipped after executing a legal move.<br />

‘board’ contains the current view of the board in a computer-friendly manner. ‘cBoard’ s<strong>to</strong>res the<br />

temporary board after the computer has made a possible move and is used in the code for evaluating<br />

the computer’s best option. ‘pBoard’ s<strong>to</strong>res the player’s move following the computer’s move and<br />

is used for evaluating the player’s least best move after the computer has made a temporary move.<br />

We will look at the use of these arrays in more detail later in the chapter. Then we have a call <strong>to</strong><br />

a simple function that duplicates and positions the single movie clip ‘piece’.<br />

1 function makeBoard(){<br />

2 var row, col, name, mc, count=1;<br />

3<br />

4 for(row=0; row

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!