void CheckDiagonal1(Graphics canvas) { // Check diagonal 1 for (int nRow = NUMROWS - 1; nRow >= 0; nRow--) { int nCol = 0; int nThisRow = nRow; int nThisCol = nCol; int nColCount = 0; while (nThisCol < NUMCOLS && nThisRow < NUMROWS) { if (m_nBoard[nThisRow][nThisCol] != 0) { nColCount++; } nThisCol++; nThisRow++; } if (nColCount > 1) { canvas.drawLine( BOARDLEFT + nCol * SQUAREWIDTH + (SQUAREWIDTH / 2), BOARDTOP + nRow * SQUAREHEIGHT + (SQUAREHEIGHT / 2), BOARDLEFT + (nThisCol - 1) * SQUAREWIDTH + (SQUAREWIDTH / 2), BOARDTOP + (nThisRow - 1) * SQUAREHEIGHT + (SQUAREHEIGHT / 2)); m_bClash = true; } } for (int nCol = 1; nCol < NUMCOLS; nCol++) { int nRow = 0; int nThisRow = nRow; int nThisCol = nCol; int nColCount = 0; while (nThisCol < NUMCOLS && nThisRow < NUMROWS) { if (m_nBoard[nThisRow][nThisCol] != 0) { nColCount++; } nThisCol++; nThisRow++; } if (nColCount > 1) { canvas.drawLine( BOARDLEFT + nCol * SQUAREWIDTH + (SQUAREWIDTH / 2), BOARDTOP + nRow * SQUAREHEIGHT + (SQUAREHEIGHT / 2), BOARDLEFT + (nThisCol - 1) * SQUAREWIDTH + (SQUAREWIDTH / 2), BOARDTOP + (nThisRow - 1) * SQUAREHEIGHT + (SQUAREHEIGHT / 2)); m_bClash = true; } } }
void CheckRows(Graphics canvas) { for (int nRow = 0; nRow < NUMROWS; nRow++) { int nRowCount = 0; for (int nCol = 0; nCol < NUMCOLS; nCol++) { if (m_nBoard[nRow][nCol] != 0) { nRowCount++; } } if (nRowCount > 1) { canvas.drawLine( BOARDLEFT + (SQUAREWIDTH / 2), BOARDTOP + nRow * SQUAREHEIGHT + (SQUAREHEIGHT / 2), BOARDLEFT + 7 * SQUAREWIDTH + (SQUAREWIDTH / 2), BOARDTOP + nRow * SQUAREHEIGHT + (SQUAREHEIGHT / 2)); m_bClash = true; } } }
void CheckColumns(Graphics canvas) { // Check all columns for (int nCol = 0; nCol < NUMCOLS; nCol++) { int nColCount = 0; for (int nRow = 0; nRow < NUMROWS; nRow++) { if (m_nBoard[nRow][nCol] != 0) { nColCount++; } } if (nColCount > 1) { canvas.drawLine( BOARDLEFT + nCol * SQUAREWIDTH + (SQUAREWIDTH / 2), BOARDTOP + (SQUAREHEIGHT / 2), BOARDLEFT + nCol * SQUAREWIDTH + (SQUAREWIDTH / 2), BOARDTOP + SQUAREHEIGHT * 7 + (SQUAREHEIGHT / 2)); m_bClash = true; } } }