Game Development Reference
In-Depth Information
The actual adding and checking to see if anyone has won, or if the game is still in
progress, or if the game is tied, is determined by the following method:
private function checkCell(checkRow:int,checkColumn:int):int {
var i:int=0;
//reset the value
//var verifyElement:int = 0;
for (i = 0; i < m_verifyArray.length; i++)
m_verifyArray[i] = 0;
var hotspot:TictactoeHotspot = null;
for(i = 0; i < 3; i++) {
//check vertical
if ((checkRow+i) < 3) {
m_verifyArray[0] +=
m_hotspotArray[checkRow+i]
[checkColumn].value;
if ( m_verifyArray[0] == 3 ||
m_verifyArray[0] == -3 )
markWin(0, checkColumn);
}
//check horizontal
if ((checkColumn+i) < 3) {
m_verifyArray[1] +=
m_hotspotArray[checkRow]
[checkColumn+i].value;
if ( m_verifyArray[1] == 3 ||
m_verifyArray[1] == -3 )
markWin(1, checkRow);
}
//check right diagonal
if ((checkRow+i) < 3 && (checkColumn+i) < 3) {
m_verifyArray[2] +=
m_hotspotArray[checkRow+i]
[checkColumn+i].value;
if ( m_verifyArray[2] == 3 ||
m_verifyArray[2] == -3 )
markWin(2, -1);
}
//check left diagonal
if ((checkRow-i) >= 0 && (checkColumn+i) < 3) {
m_verifyArray[3] +=
m_hotspotArray[checkRow-i]
[checkColumn+i].value;
if ( m_verifyArray[3] == 3 ||
 
Search WWH ::




Custom Search