MFC实现五子棋二人对弈
void CWzqView::vDrawPiece(CPoint pointBoard, int nType, CDC* pDC) { CRgn rgnPiece; CPoint pointView = ptConvertBP2VP(pointBoard); rgnPiece.CreateEllipticRgn( pointView.x - WIDTH_Piece, pointView.y - WIDTH_Piece, pointView.x + WIDTH_Piece, pointView.y + WIDTH_Piece); int pos_x,pos_y; pos_x = pointBoard.x; pos_y = pointBoard.y; CBrush brush; if (map[pos_x][pos_y]!=0) return ; if (nextColor == 1){ // next is black brush.CreateSolidBrush(COLOR_PieceBlack); map[pos_x][pos_y] = 1; nextColor = 2; if (szylover(map,pos_x,pos_y) == 1){ MessageBox("Black win!"); exit(0); } }else{ brush.CreateSolidBrush(COLOR_PieceSZY); map[pos_x][pos_y] = 2; nextColor = 1; if (szylover(map,pos_x,pos_y) == 1){ MessageBox("red win"); exit(0); } } pDC->FillRgn(&rgnPiece, &brush); rgnPiece.DeleteObject(); } // CWzqView::vDrawPiece
用户评论