用VS2010做了个井字棋游戏程序 但是下棋的时候 判断胜利的方法有问题 我把代码贴出来 希望大家给我看看 我是新手 谢谢大家了 !!!!
头文件:
// TIC2Dlg.h : 头文件
//
#pragma once
// CTIC2Dlg 对话框
class CTIC2Dlg : public CDialogEx
{
// 构造
public:
CTIC2Dlg(CWnd* pParent = NULL); // 标准构造函数
void update();
void updateqp();
int whowin(int x,int y,int _flag);
void manstep(int x,int y);
int model();
void win();
void lose();
void pingshou();
// 对话框数据
enum { IDD = IDD_TIC2_DIALOG };
int qp[3][3];
int *xt[8][3];
int dys; //控件对应数
int sum; //计算棋盘上有多少子
int flag; //表示谁在下棋 -1人后手(电脑在走) 1人先手(人在走)
int jieguo; //胜负标记
CWnd *q; //控件指针
CButton *qz; //button指针
bool state ; //记录游戏是否在进行
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
HICON m_hIcon;
// 生成的消息映射函数
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
afx_msg void OnButton1();
afx_msg void OnButton2();
afx_msg void OnButton3();
afx_msg void OnButton4();
afx_msg void OnButton5();
afx_msg void OnButton6();
afx_msg void OnButton7();
afx_msg void OnButton8();
afx_msg void OnButton9();
public:
int m_first; //定义先手 1先手 0后手
protected:
virtual void OnOK();
};