全:
PlaySound("./music/music1.wav",NULL,SND_FILENAME|SND_ASYNC |SND_LOOP);
该函数最好用但只能播放一首 同时播放后面的会替代前面的
有三种播放方法:
方法1:
可以的
HWND hMCI;
CString choose = _T("./music/music.wav"); //音乐文件的路径
hMCI = MCIWndCreate(NULL, NULL,WS_POPUP|MCIWNDF_NOPLAYBAR|MCIWNDF_NOMENU,choose);
MCIWndPlay(hMCI); //播放音乐
先包含头文件 #include <Vfw.H>
在项目属性->配置属性->Linker->Input->Additional Dependencies 写入 VFW32.lib
下面是实现:
HWND hMCI;
HWND hMCI;
CString choose = _T("E:\\MyDocument\\Music\\乔任梁 - 和你在一起.mp3"); //音乐文件的路径
hMCI = MCIWndCreate(NULL, NULL,WS_POPUP|MCIWNDF_NOPLAYBAR|MCIWNDF_NOMENU,choose);
MCIWndPlay(hMCI); //播放音乐
该函数需要:
#include <mmsystem.h>
#pragma comment(lib, "WINMM.LIB")
以上就可以实现MP3音乐的播放了,是不是很简单!
当然,关于播放音乐还有很多函数,以上只是例举了一个函数MCIWndPlay,还有MCIWndStop,MCIWndPause,MCIWndResume等等。同时,这个VFM32.lib库中还包括了对视频的操作,比如捕捉摄像头视频,播放AVI格式的视频等等,功能非常强大!
http://blog.csdn.net/liuyi1207164339/article/details/46679689
但不知道如何关掉播放 所以用的少
方法2: 临时播放 播放器有多个 可以进行多线程播放
PlaySound("./music/music.wav",NULL,SND_FILENAME|SND_ASYNC |SND_LOOP);循环播放
PlaySound(NULL,NULL,SND_FILENAME|SND_ASYNC |SND_LOOP); 关掉播放
PlaySound("ring.wav",NULL,SND_FILENAME|SND_SYNC); 单次播放
叫地主抢地主可以用短暂的 PlaySound方法
背景乐月用循环的 PlaySound
http://blog.csdn.net/qiuchenl/article/details/7774641
方法3: 可以永久性的关闭和播放 比较常用 但不可以重复播放 里面只有一个播放器 播放同一首歌的时候会出现占用现象 不可以被覆盖掉歌曲 ,播放器只有一个所以打开另一个时候先应该关掉原来的。而playsound可以覆盖掉原来的歌曲 ,播放器可以开多个但为了出现混合播放所以播放另一个时候先关闭掉这个。
叫地主抢地主 胜利和输 可以用playsound短暂播放器播放,至于如何关闭掉我觉得可以在背景函数里用flag6开关去控制到底播放那个。也可以在走棋函数里用flag控制到底播放
void CMyDlg::Onzouqi() //走棋音
{
// TODO: Add your control notification handler code here
if(flag4%2==1)
{
/*
CString str;
//capture.release();
//CFileDialog *File;
MCI_OPEN_PARMS mciopenparms;//打开
MCI_PLAY_PARMS mciplayparms;//播放
//FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi)|*.avi")); //生成一个对话框
str="./sound/yidong.wav";
//while(1)
//{
mciopenparms.lpstrElementName=str;//播放路径,文件为mid格式
mciopenparms.lpstrDeviceType=NULL;//文件类型
MCIERROR ret = mciSendCommand(0,MCI_OPEN,MCI_DEVTYPE_WAVEFORM_AUDIO,
(DWORD)(LPVOID)&mciopenparms);//向MCI设备发送命令消息
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
m_count=mciopenparms.wDeviceID;
mciplayparms.dwCallback=(DWORD)GetSafeHwnd();
mciplayparms.dwFrom=0;
ret = mciSendCommand(m_count,MCI_PLAY,MCI_FROM| MCI_NOTIFY ,(DWORD)(LPVOID)& mciplayparms);
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
//mciSendCommand (m_DeviceID, MCI_CLOSE, NULL, NULL);
*/
flag4++;
}
else
{
mciSendCommand(m_count,MCI_CLOSE,0,NULL);
flag4++;
//同时也是关闭播放设备,所有声音都会停止// TODO: 在此添加控件通知处理程序代码
}
}
void CMyDlg::Onzouqi1() //走棋音函数
{
// PlaySound("./music/music1.wav",NULL,SND_FILENAME|SND_ASYNC |SND_LOOP);
CString str;
//capture.release();
//CFileDialog *File;
MCI_OPEN_PARMS mciopenparms;//打开
MCI_PLAY_PARMS mciplayparms;//播放
//FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi)|*.avi")); //生成一个对话框
str="./sound/yidong.wav";
//while(1)
//{
mciopenparms.lpstrElementName=str;//播放路径,文件为mid格式
mciopenparms.lpstrDeviceType=NULL;//文件类型
MCIERROR ret = mciSendCommand(0,MCI_OPEN,MCI_DEVTYPE_WAVEFORM_AUDIO,
(DWORD)(LPVOID)&mciopenparms);//向MCI设备发送命令消息
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
m_count=mciopenparms.wDeviceID;
mciplayparms.dwCallback=(DWORD)GetSafeHwnd();
mciplayparms.dwFrom=0;
ret = mciSendCommand(m_count,MCI_PLAY,MCI_FROM| MCI_NOTIFY ,(DWORD)(LPVOID)& mciplayparms);
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
//mciSendCommand (m_DeviceID, MCI_CLOSE, NULL, NULL);
}
所以:1、PlaySound("./music/music.wav",NULL,SND_FILENAME|SND_ASYNC |SND_LOOP);循环播放
背景音乐重复播放所选择这个
2. 由于会出现占用现象所以走棋和背景音乐不可以同时用方法3.走棋声方法3因为方法3是可以统一关掉播放器 便于统一管理。
全部代码:象棋 播放背景音乐和走子声音
// 象棋Dlg.cpp : implementation file
#include "stdafx.h"
#include "象棋.h"
#include "象棋Dlg.h"
#include "PieceBlackJu.h"
#include "math.h"
#include "Change.h"
#include <ctime>
#include<string.h>
#include <windows.h>
#include <mmsystem.h>
#include <conio.h>
#include <iostream>
#include <Vfw.H>
using namespace std;
#include<stdlib.h>
#pragma comment(lib, "WINMM.LIB")
#pragma comment(lib,"winmm.lib")
#pragma warning (disable:4996)
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static int Checkerboard[9][10]; //用于记录棋盘格子的状态
static int TemCheckerboard[9][10];
int i, j, status, selpiece; //在Onstart函数中进行初始化,并对变量进行备注
int m, n; //用于记录选中棋子的坐标
MCIDEVICEID m_count;
int or;
int score1;
int flag2=0;
int flag=2; //切换棋盘 2
int flag1=0;//判断是否是全为农民的情况 全为农民则是友谊赛 彼此都不得分
int flag3=0; //背景音乐开关 奇关偶开
int flag4=0;//走棋音乐开关
//残生随机数
unsigned long int player1score; //记录分数
unsigned long int player2score; //记录分数
unsigned long int score; //记录分数
unsigned int s;
unsigned int s1;
unsigned int cout1=0;
#include <io.h>
#include <fcntl.h>
void OpenConsole()
{
AllocConsole();
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
int hCrt = _open_osfhandle((long)handle,_O_TEXT);
FILE * hf = _fdopen( hCrt, "w" );
*stdout = *hf;
}
BOOL Pstatus = true , movevalue, gameover;
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DAT
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
m_black = _T("");
m_red = _T("");
m_score = _T("");
m_player1 = _T("");
m_player2 = _T("");
m_cout1 = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
srand((unsigned)time(0));
s=rand()%10+1;
srand((unsigned)time(0));
s1=rand()%10+1;
m_board = new CBitmap;
m_back = new CBitmap;
m_blackma = new CBitmap;
m_blackju = new CBitmap;
m_blackxiang = new CBitmap;
m_blackshi = new CBitmap;
m_blackjiang = new CBitmap;
m_blackpao = new CBitmap;
m_blackzu = new CBitmap;
m_redma = new CBitmap;
m_redju = new CBitmap;
m_redxiang = new CBitmap;
m_redshi = new CBitmap;
m_redshuai = new CBitmap;
m_redpao = new CBitmap;
m_redzu = new CBitmap;
m_select = new CBitmap;
//下面是实现位图的画法 添加棋子
m_board->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/qipan.bmp",IMAGE_BITMAP,460,525,LR_LOADFROMFILE);
m_blackma->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackma.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackju->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackju.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackxiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackxiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackshi->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackshi.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackpao->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackpao.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackzu->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackzu.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackjiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackjiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redma->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redma.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redju->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redju.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redxiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redxiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redshi->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redshi.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redpao->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redpao.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redzu->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redzu.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redshuai->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redshuai.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_select->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/selected.bmp",IMAGE_BITMAP,51,51,LR_LOADFROMFILE);
m_back->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/mark.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Text(pDX, IDC_EDIT3, m_black);
DDX_Text(pDX, IDC_EDIT4, m_red);
DDX_Text(pDX, IDC_EDIT5, m_score);
DDX_Text(pDX, IDC_EDIT6, m_player1);
DDX_Text(pDX, IDC_EDIT7, m_player2);
DDX_Text(pDX, IDC_EDIT8, m_cout1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_LBUTTONDOWN() //点击窗体,响应OnLButtonDown函数
ON_BN_CLICKED(ID_START, Onstart) //点击ID_START属性的按钮,响应Onstart函数
ON_BN_CLICKED(IDC_BUTTONC, Onchanges)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDOK2, OnOK2)
ON_WM_SETCURSOR()
ON_BN_CLICKED(IDC_GAVEUP, DoGaveUp)
ON_BN_CLICKED(IDC_QIUHE, DoTie)
ON_BN_CLICKED(IDC_HUIQI, DoUndo)
ON_BN_CLICKED(IDzouqi, Onzouqi)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//read1();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE);// Set big icon
SetIcon(m_hIcon, FALSE);// Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
//以下是实现棋盘背景的画法
CDC thmem3 ;
CClientDC dc(this);
thmem3.CreateCompatibleDC(&dc);
thmem3.SelectObject(m_board);
dc.BitBlt(0,0,460,525,&thmem3,0,0,SRCCOPY);
CDialog::OnPaint();
}
}
//点击窗体响应函数
void CMyDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
int curx = int ((point.x - 5) / 51);//对点击的点整数化,与绘制位图的坐标配合,实现棋盘定格
int cury = int ((point.y - 7) / 51);
CDC thmem4 ;
CClientDC dc(this);
thmem4.CreateCompatibleDC(&dc);
if(status % 2 == 0 && Pstatus && !gameover)//黑方第一次点击响应的IF语句
{
m = curx;
n = cury;
if(Checkerboard[curx][cury] == BLACK_JU)//如果点击的是黑色的车,则选中黑色车
{
selpiece = BLACK_JU;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);//在选定的棋子上覆盖一张m_select指向的图片,带到凸显选定棋子的目的
status ++;
}
else if(Checkerboard[curx][cury] == BLACK_MA)
{
selpiece = BLACK_MA;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == BLACK_XIANG)
{
selpiece = BLACK_XIANG;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == BLACK_SHI)
{
selpiece = BLACK_SHI;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == BLACK_JIANG)
{
selpiece = BLACK_JIANG;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == BLACK_PAO)
{
selpiece = BLACK_PAO;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == BLACK_ZU)
{
selpiece = BLACK_ZU;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else
{
//
}
}
if(status % 2 == 0 && !Pstatus && !gameover)//红方第一次点击响应的IF语句
{
m = curx;
n = cury;
if(Checkerboard[curx][cury] == RED_JU)//如果点击的是红色的车,则选中红色车
{
selpiece = RED_JU;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == RED_MA)
{
selpiece = RED_MA;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == RED_XIANG)
{
selpiece = RED_XIANG;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == RED_SHI)
{
selpiece = RED_SHI;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == RED_SHUAI)
{
selpiece = RED_SHUAI;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == RED_PAO)
{
selpiece = RED_PAO;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
else if(Checkerboard[curx][cury] == RED_ZU)
{
selpiece = RED_ZU;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
status ++;
}
}
else if(status % 2 == 1 && Pstatus && !gameover)//黑方第二次点击响应的IF语句
{
if(Checkerboard[curx][cury] >=BLACK_JU && Checkerboard[curx][cury] <= BLACK_ZU) //如果下次点击的是己方的棋子,则改变选中的棋子
{
m = curx;
n = cury;
//当下次点击是己方棋子时,重绘棋盘,将选定棋子的凸显效果转移至下一颗选定的棋子
CDC thmem5 ;
CClientDC dc(this);
thmem5.CreateCompatibleDC(&dc);
thmem5.SelectObject(m_board);
dc.BitBlt(0,0,460,525,&thmem5,0,0,SRCCOPY);
DoDraw();
if(Checkerboard[curx][cury] == BLACK_JU)
{
selpiece = BLACK_JU;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == BLACK_MA)
{
selpiece = BLACK_MA;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == BLACK_XIANG)
{
selpiece = BLACK_XIANG;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == BLACK_SHI)
{
selpiece = BLACK_SHI;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == BLACK_JIANG)
{
selpiece = BLACK_JIANG;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == BLACK_PAO)
{
selpiece = BLACK_PAO;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == BLACK_ZU)
{
selpiece = BLACK_ZU;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
}
else
{
if(selpiece == BLACK_JU)//如果选中的棋子是黑色车,则调用黑色车的move方法
{
PieceBlackJu BlackJu;
BlackJu.Tseatx = curx;//将第二次点击的坐标赋值给对象将来的坐标
BlackJu.Tseaty = cury;
BlackJu.seatx = m;//将第一次点击的坐标赋值给对象现在的坐标
BlackJu.seaty = n;
movevalue = BlackJu.Move(BlackJu);
}
else if(selpiece == BLACK_MA )
{
PieceBlackMa BlackMa;
BlackMa.Tseatx = curx;
BlackMa.Tseaty = cury;
BlackMa.seatx = m;
BlackMa.seaty = n;
movevalue = BlackMa.Move(BlackMa);
}
else if(selpiece == BLACK_XIANG )
{
PieceBlackXiang BlackXiang;
BlackXiang.Tseatx = curx;
BlackXiang.Tseaty = cury;
BlackXiang.seatx = m;
BlackXiang.seaty = n;
movevalue = BlackXiang.Move(BlackXiang);
}
else if(selpiece == BLACK_SHI )
{
PieceBlackShi BlackShi;
BlackShi.Tseatx = curx;
BlackShi.Tseaty = cury;
BlackShi.seatx = m;
BlackShi.seaty = n;
movevalue = BlackShi.Move(BlackShi);
}
else if(selpiece == BLACK_JIANG )
{
PieceBlackJiang BlackJiang;
BlackJiang.Tseatx = curx;
BlackJiang.Tseaty = cury;
BlackJiang.seatx = m;
BlackJiang.seaty = n;
movevalue = BlackJiang.Move(BlackJiang);
}
else if(selpiece == BLACK_ZU )
{
PieceBlackZu BlackZu;
BlackZu.Tseatx = curx;
BlackZu.Tseaty = cury;
BlackZu.seatx = m;
BlackZu.seaty = n;
movevalue = BlackZu.Move(BlackZu);
}
else if(selpiece == BLACK_PAO )
{
PieceBlackPao BlackPao;
BlackPao.Tseatx = curx;
BlackPao.Tseaty = cury;
BlackPao.seatx = m;
BlackPao.seaty = n;
movevalue = BlackPao.Move(BlackPao);
}
if(movevalue) //如果move方法返回的值为true则表示是合法操作
{
ChessPiece Judge;
for(i = 0; i < 9; i++)
for(j = 0; j <10; j ++)
{
TemCheckerboard[i][j] = Checkerboard[i][j];
}
Checkerboard[curx][cury] = Checkerboard[m][n];//落子,用以前的坐标替换掉现在的坐标
Checkerboard[m][n] = 0;//将以前所在棋盘格状态置为0
status ++;
zouqi();
//重绘棋盘背景,实现棋子移动
CDC thmem2 ;
CClientDC dc(this);
thmem2.CreateCompatibleDC(&dc);
thmem2.SelectObject(m_board);
dc.BitBlt(0,0,460,525,&thmem2,0,0,SRCCOPY);
DoDraw();
GetDlgItem(IDC_HUIQI)->EnableWindow(true);
Judge.Judge();
ButtonColor();
Pstatus = !Pstatus;//切换下棋方
}
else
{
//MessageBox(TEXT("不能到达这里"),"出错啦!");
}
}
}
else if(status % 2 == 1 && !Pstatus && !gameover)
{
if(Checkerboard[curx][cury] >= RED_JU && Checkerboard[curx][cury] <= RED_ZU) //如果下次点击的是己方的棋子,则改变选中的棋子
{
m = curx;
n = cury;
CDC thmem6 ;
CClientDC dc(this);
thmem6.CreateCompatibleDC(&dc);
thmem6.SelectObject(m_board);
dc.BitBlt(0,0,460,525,&thmem6,0,0,SRCCOPY);
DoDraw();
if(Checkerboard[curx][cury] == RED_JU)
{
selpiece = RED_JU;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == RED_MA)
{
selpiece = RED_MA;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == RED_XIANG)
{
selpiece = RED_XIANG;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == RED_SHI)
{
selpiece = RED_SHI;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == RED_SHUAI)
{
selpiece = RED_SHUAI;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == RED_PAO)
{
selpiece = RED_PAO;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
else if(Checkerboard[curx][cury] == RED_ZU)
{
selpiece = RED_ZU;
thmem4.SelectObject(m_select);
dc.BitBlt((m * 51)+2,(n * 51)+4,51,51,&thmem4,0,0,SRCAND);
}
}
else
{
if(selpiece == RED_JU)
{
PieceRedJu RedJu;
RedJu.Tseatx = curx;
RedJu.Tseaty = cury;
RedJu.seatx = m;
RedJu.seaty = n;
movevalue = RedJu.Move(RedJu);
}
else if(selpiece == RED_MA) //生成红象对象
{
PieceRedMa RedMa;
RedMa.Tseatx = curx;
RedMa.Tseaty = cury;
RedMa.seatx = m;
RedMa.seaty = n;
movevalue = RedMa.Move(RedMa);
}
else if(selpiece == RED_XIANG) //生成红象对象
{
PieceRedXiang RedXiang;
RedXiang.Tseatx = curx;
RedXiang.Tseaty = cury;
RedXiang.seatx = m;
RedXiang.seaty = n;
movevalue = RedXiang.Move(RedXiang);
}
else if(selpiece == RED_SHI) //生成红象对象
{
PieceRedShi RedShi;
RedShi.Tseatx = curx;
RedShi.Tseaty = cury;
RedShi.seatx = m;
RedShi.seaty = n;
movevalue = RedShi.Move(RedShi);
}
else if(selpiece == RED_SHUAI) //生成红象对象
{
PieceRedShuai RedShuai;
RedShuai.Tseatx = curx;
RedShuai.Tseaty = cury;
RedShuai.seatx = m;
RedShuai.seaty = n;
movevalue = RedShuai.Move(RedShuai);
}
else if(selpiece == RED_ZU) //生成红象对象
{
PieceRedZu RedZu;
RedZu.Tseatx = curx;
RedZu.Tseaty = cury;
RedZu.seatx = m;
RedZu.seaty = n;
movevalue = RedZu.Move(RedZu);
}
else if(selpiece == RED_PAO) //生成红象对象
{
PieceRedPao RedPao;
RedPao.Tseatx = curx;
RedPao.Tseaty = cury;
RedPao.seatx = m;
RedPao.seaty = n;
movevalue = RedPao.Move(RedPao);
}
if(movevalue)
{
ChessPiece Judge;
for(i = 0; i < 9; i++)
for(j = 0; j <10; j ++)
{
TemCheckerboard[i][j] = Checkerboard[i][j];
}
Checkerboard[curx][cury] = Checkerboard[m][n];//落子
Checkerboard[m][n] = 0;
status ++;
//重绘棋盘背景,实现棋子移动
CDC thmem2 ;
CClientDC dc(this);
thmem2.CreateCompatibleDC(&dc);
thmem2.SelectObject(m_board);
dc.BitBlt(0,0,460,525,&thmem2,0,0,SRCCOPY);
DoDraw();
GetDlgItem(IDC_HUIQI)->EnableWindow(true);
Judge.Judge();
ButtonColor();
Pstatus = !Pstatus;
cout1++;
zouqi();
}
else
{
//MessageBox(TEXT("不能到达这里"),"出错啦!");
}
}
}
// TODO: 在此添加控件通知处理程序代码
char c1[10] = "";
itoa(cout1, c1, 10);
m_cout1 = c1;//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
}
//棋盘绘制函数
void CMyDlg::DoDraw()
{
CDC thmem1 ;
CClientDC dc(this);
thmem1.CreateCompatibleDC(&dc);
for(i = 0; i < 9; i ++)
for(j = 0; j < 10; j++)
{
switch(Checkerboard[i][j])
{
case BLACK_JU :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_blackju);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case BLACK_MA :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_blackma);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case BLACK_XIANG :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_blackxiang);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case BLACK_SHI :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_blackshi);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case BLACK_JIANG :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_blackjiang);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case BLACK_PAO :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_blackpao);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case BLACK_ZU :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_blackzu);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case RED_JU :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_redju);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case RED_MA :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_redma);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case RED_XIANG :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_redxiang);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case RED_SHI :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_redshi);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case RED_SHUAI :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_redshuai);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case RED_PAO :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_redpao);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
case RED_ZU :
thmem1.SelectObject (m_back);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,MERGEPAINT);
thmem1.SelectObject(m_redzu);
dc.BitBlt((i * 51)+5,(j * 51)+7,45,45,&thmem1,0,0,SRCAND);
break;
default :
break;
}
}
}
HCURSOR CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
//换肤
void CMyDlg::Onchanges()
{ // flag++;
if(flag==1)
{
//下面是实现位图的画法 添加棋子
m_board->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/qipan.bmp",IMAGE_BITMAP,460,525,LR_LOADFROMFILE);
m_blackma->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackma.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackju->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackju.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackxiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackxiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackshi->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackshi.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackpao->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackpao.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackzu->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackzu.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackjiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/blackjiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redma->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redma.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redju->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redju.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redxiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redxiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redshi->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redshi.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redpao->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redpao.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redzu->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redzu.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redshuai->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/redshuai.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_select->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/selected.bmp",IMAGE_BITMAP,51,51,LR_LOADFROMFILE);
m_back->m_hObject = (HBITMAP)::LoadImage (NULL,"./1/mark.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
Onstart1();
flag++;
}
else if(flag==2)
{
//下面是实现位图的画法 添加棋子
m_board->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/qipan.bmp",IMAGE_BITMAP,460,525,LR_LOADFROMFILE);
m_blackma->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/blackma.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackju->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/blackju.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackxiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/blackxiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackshi->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/blackshi.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackpao->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/blackpao.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackzu->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/blackzu.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackjiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/blackjiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redma->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/redma.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redju->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/redju.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redxiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/redxiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redshi->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/redshi.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redpao->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/redpao.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redzu->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/redzu.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redshuai->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/redshuai.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_select->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/selected.bmp",IMAGE_BITMAP,51,51,LR_LOADFROMFILE);
m_back->m_hObject = (HBITMAP)::LoadImage (NULL,"./2/mark.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
Onstart1();
flag++;
}
else if(flag==3)
{
//下面是实现位图的画法 添加棋子
m_board->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/qipan.bmp",IMAGE_BITMAP,460,525,LR_LOADFROMFILE);
m_blackma->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/blackma.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackju->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/blackju.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackxiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/blackxiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackshi->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/blackshi.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackpao->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/blackpao.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackzu->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/blackzu.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_blackjiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/blackjiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redma->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/redma.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redju->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/redju.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redxiang->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/redxiang.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redshi->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/redshi.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redpao->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/redpao.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redzu->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/redzu.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_redshuai->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/redshuai.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_select->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/selected.bmp",IMAGE_BITMAP,51,51,LR_LOADFROMFILE);
m_back->m_hObject = (HBITMAP)::LoadImage (NULL,"./3/mark.bmp",IMAGE_BITMAP,45,45,LR_LOADFROMFILE);
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
Onstart1();
flag=1;
}
}
//点击开始响应的函数
void CMyDlg::Onstart1() //开始按钮
{
//flag++;
//重绘棋盘背景,实现棋子移动
CDC thmem2 ;
CClientDC dc(this);
thmem2.CreateCompatibleDC(&dc);
thmem2.SelectObject(m_board);
dc.BitBlt(0,0,460,525,&thmem2,0,0,SRCCOPY);
// 棋盘数组初始化
for(j = 0; j < 10; j ++)
for(i = 0; i < 9; i ++)
{
if(j == 0) //初始化第0行棋盘
{
if(i < 5)
{
Checkerboard[i][j] = i + 1;//依次跟车马象所在棋格赋值为123
}
else
{
Checkerboard[i][j] = 9 - i;//依次跟将士象所在棋格赋值为543
}
}
else if(j == 2)
{
if(i == 1 || i == 7)
{
Checkerboard[i][j] = 6;
}
else
{
Checkerboard[i][j] = 0;//为第2行其他非跑所在棋格赋值为0
}
}
else if(j == 3)
{
if(i % 2 == 0)
{
Checkerboard[i][j] = 7;//为卒所在棋格赋值为7
}
else
{
Checkerboard[i][j] = 0;
}
}
else if(j == 6)
{
if(i % 2 == 0)
{
Checkerboard[i][j] = 14;
}
else
{
Checkerboard[i][j] = 0;
}
}
else if(j == 7)
{
if(i == 1 || i == 7)
{
Checkerboard[i][j] = 13;
}
else
{
Checkerboard[i][j] = 0;
}
}
else if(j == 9)
{
if(i < 5)
{
Checkerboard[i][j] = i + 8;
}
else
{
Checkerboard[i][j] = 16 - i;
}
}
else
{
Checkerboard[i][j] = 0;
}
}
/*status = 0; //用于区分第一次点击和第二次点击的变量
selpiece = 0; //用于记录点击选中的棋子的变量
Pstatus = false;//用于切换下棋方得变量
movevalue = false;//用于储存move方法返回的值
gameover = false;//用于判断游戏是否结束
GetDlgItem(IDC_RENSHU)->EnableWindow(true);
GetDlgItem(IDC_QIUHE)->EnableWindow(true);
GetDlgItem(IDC_HUIQI)->EnableWindow(true);
DoDraw(); */
/*else
{
Onchangef();
s1++;
}*/
/*if(IDYES == AfxMessageBox("红方是否叫地主?",MB_YESNO))
{
if(IDYES == AfxMessageBox("黑方是否抢地主?",MB_YESNO))
{
if(IDYES == AfxMessageBox("红方是否抢地主?",MB_YESNO))
{
}
else
{
// MessageBox(TEXT("对方不同意悔棋!"),"结果");
}
}
else
{
// MessageBox(TEXT("对方不同意悔棋!"),"结果"); //红方是地主
}
}
else
{
if(IDYES == AfxMessageBox("黑方是否叫地主?",MB_YESNO))
{
}
else
{
// MessageBox(TEXT("对方不同意悔棋!"),"结果");
}
}*/
}
//点击开始响应的函数
void CMyDlg::Onstart() //开始按钮
{
PlaySound(NULL,NULL,SND_FILENAME|SND_SYNC); //背景音乐
//初始数据:
score1=0;
cout1=0;
flag2=0;
flag1=0;
//残生随机数
score=0; //记录分数
player1score=0; //记录分数
player2score=0; //记录分数
char c2[10] = "";
itoa(cout1, c2, 10);
m_cout1 = c2;//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
read1();
//flag++;
//重绘棋盘背景,实现棋子移动
CDC thmem2 ;
CClientDC dc(this);
thmem2.CreateCompatibleDC(&dc);
thmem2.SelectObject(m_board);
dc.BitBlt(0,0,460,525,&thmem2,0,0,SRCCOPY);
// 棋盘数组初始化
for(j = 0; j < 10; j ++)
for(i = 0; i < 9; i ++)
{
if(j == 0) //初始化第0行棋盘
{
if(i < 5)
{
Checkerboard[i][j] = i + 1;//依次跟车马象所在棋格赋值为123
}
else
{
Checkerboard[i][j] = 9 - i;//依次跟将士象所在棋格赋值为543
}
}
else if(j == 2)
{
if(i == 1 || i == 7)
{
Checkerboard[i][j] = 6;
}
else
{
Checkerboard[i][j] = 0;//为第2行其他非跑所在棋格赋值为0
}
}
else if(j == 3)
{
if(i % 2 == 0)
{
Checkerboard[i][j] = 7;//为卒所在棋格赋值为7
}
else
{
Checkerboard[i][j] = 0;
}
}
else if(j == 6)
{
if(i % 2 == 0)
{
Checkerboard[i][j] = 14;
}
else
{
Checkerboard[i][j] = 0;
}
}
else if(j == 7)
{
if(i == 1 || i == 7)
{
Checkerboard[i][j] = 13;
}
else
{
Checkerboard[i][j] = 0;
}
}
else if(j == 9)
{
if(i < 5)
{
Checkerboard[i][j] = i + 8;
}
else
{
Checkerboard[i][j] = 16 - i;
}
}
else
{
Checkerboard[i][j] = 0;
}
}
status = 0; //用于区分第一次点击和第二次点击的变量
selpiece = 0; //用于记录点击选中的棋子的变量
Pstatus = false;//用于切换下棋方得变量
movevalue = false;//用于储存move方法返回的值
gameover = false;//用于判断游戏是否结束
GetDlgItem(IDC_RENSHU)->EnableWindow(true);
GetDlgItem(IDC_QIUHE)->EnableWindow(true);
GetDlgItem(IDC_HUIQI)->EnableWindow(true);
DoDraw();
if(s%2==0)
{
or=1;
if(IDYES == AfxMessageBox("红方是否叫地主?",MB_YESNO))
{ PlaySound("./sound/Man/叫地主.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
if(IDYES == AfxMessageBox("黑方是否抢地主?",MB_YESNO))
{ PlaySound("./sound/Woman/抢地主0.wav",NULL,SND_FILENAME|SND_SYNC); //强地主
if(IDYES == AfxMessageBox("红方是否抢地主?",MB_YESNO))
{ //结束 红方是地主
// TODO: 在此添加控件通知处理程序代码
// char conet[200] = "";
PlaySound("./sound/Man/抢地主0.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
m_black ="农民";//print是编辑框中添加的cstring变量
m_red = "地主";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=80;
flag1=2;//全农民
s++;
}
else
{ PlaySound("./sound/Man/不抢.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
// MessageBox(TEXT("对方不同意悔棋!"),"结果");
m_black ="地主";//print是编辑框中添加的cstring变量
m_red = "农民";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=40;
flag1=3;//全农民
s++;
}
}
else
{ PlaySound("./sound/Woman/不抢.wav",NULL,SND_FILENAME|SND_SYNC); //强地主
// MessageBox(TEXT("对方不同意悔棋!"),"结果"); //红方是地主
m_black ="农民";//print是编辑框中添加的cstring变量
m_red = "地主";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=20;
flag1=2;//全农民
s++;
}
}
else
{
PlaySound("./sound/Man/不叫.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
if(IDYES == AfxMessageBox("黑方是否叫地主?",MB_YESNO))
{
PlaySound("./sound/Woman/叫地主.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
m_black ="地主";//print是编辑框中添加的cstring变量
m_red = "农民";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=20;
flag1=3;//全农民
s++;
}
else
{ PlaySound("./sound/Woman/不叫.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
// MessageBox(TEXT("对方不同意悔棋!"),"结果");
// MessageBox(TEXT("红黑双方都不!"),"结果");
/* m_red = "农民";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=0;
flag1=1;//全农民*/
// PlaySound("./sound/Man/不叫.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
m_black ="农民";//print是编辑框中添加的cstring变量
m_red = "地主";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=10;
flag1=2;//全农民
s++;
}
}
// s++;
}
else
{
or=0;
if(IDYES == AfxMessageBox("黑方是否叫地主?",MB_YESNO))
{ PlaySound("./sound/Woman/叫地主.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
if(IDYES == AfxMessageBox("红方是否抢地主?",MB_YESNO))
{ PlaySound("./sound/Man/抢地主0.wav",NULL,SND_FILENAME|SND_SYNC); //强地主
if(IDYES == AfxMessageBox("黑方是否抢地主?",MB_YESNO))
{ PlaySound("./sound/Woman/抢地主0.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
//结束 红方是地主
// TODO: 在此添加控件通知处理程序代码
// char conet[200] = "";
m_black ="地主";//print是编辑框中添加的cstring变量
m_red = "农民";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=80;
flag1=3;//全农民
s++;
}
else
{PlaySound("./sound/Woman/不抢.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
// MessageBox(TEXT("对方不同意悔棋!"),"结果");
m_black ="农民";//print是编辑框中添加的cstring变量
m_red = "地主";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=40;
flag1=2;//全农民
s++;
}
}
else
{PlaySound("./sound/Man/不抢.wav",NULL,SND_FILENAME|SND_SYNC); //强地主
// MessageBox(TEXT("对方不同意悔棋!"),"结果"); //红方是地主
m_black ="地主";//print是编辑框中添加的cstring变量
m_red = "农民";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=20;
flag1=3;//全农民
s++;
}
}
else
{
PlaySound("./sound/Woman/不叫.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
if(IDYES == AfxMessageBox("红方是否叫地主?",MB_YESNO))
{ PlaySound("./sound/Man/叫地主.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
m_black ="农民";//print是编辑框中添加的cstring变量
m_red = "地主";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=20;
flag1=2;//全农民
s++;
}
else //都不抢
{PlaySound("./sound/Man/不叫.wav",NULL,SND_FILENAME|SND_SYNC); //叫地主
m_black ="地主";//print是编辑框中添加的cstring变量
m_red = "农民";//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
score=10;
flag1=3;//全农民
s++;
}
}
// s++;
}
PlaySound(NULL,NULL,SND_FILENAME|SND_ASYNC |SND_LOOP); //背景
if(flag3%2==0)
{
//mciSendCommand(m_count,MCI_CLOSE,0,NULL);
OnOK22();
}
// TODO: 在此添加控件通知处理程序代码
char c1[10] = "";
itoa(score, c1, 10);
m_score = c1;//print是编辑框中添加的cstring变量
UpdateData(FALSE);//显示到灰色编辑框中
// write();
}
void CMyDlg:: write()
{
//写数据 分数
FILE *fp1;
char name3[20];//最好全局
fp1=fopen("player1.lgc","wb");//f_out指针等价于打开h1文件,并且折星读操作,读于屏幕的。
// fp2=fopen("common_survive备份.lgc","w");//只写与r+
itoa(player1score, name3, 10);//地主胜2倍分数
fputs(name3,fp1);
fclose(fp1);
fp1=fopen("player2.lgc","wb");//f_out指针等价于打开h1文件,并且折星读操作,读于屏幕的。
// fp2=fopen("common_survive备份.lgc","w");//只写与r+
itoa(player2score, name3,10);//地主胜2倍分数 表示10进制的形式转换
fputs(name3,fp1);
fclose(fp1);
//read();
}
void CMyDlg:: read1()
{
//显示分数
FILE *fp1;
char name3[20];//最好全局
fp1=fopen("player1.lgc","rb");//f_out指针等价于打开h1文件,并且折星读操作,读于屏幕的。
// fp2=fopen("common_survive备份.lgc","w");//只写与r+
fgets(name3,20,fp1);
m_player1=name3;
player1score=atoi(name3);
fclose(fp1);
UpdateData(FALSE);//显示到灰色编辑框中
fp1=fopen("player2.lgc","rb");//f_out指针等价于打开h1文件,并且折星读操作,读于屏幕的。
// fp2=fopen("common_survive备份.lgc","w");//只写与r+
fgets(name3,20,fp1);
m_player2=name3;
player2score=atoi(name3);
fclose(fp1);
UpdateData(FALSE);//显示到灰色编辑框中
}
BOOL PieceBlackJu::Move(PieceBlackJu &BlackJu)
{
int i, j;
int min, max;
if(BlackJu.seatx == BlackJu.Tseatx && BlackJu.seaty != BlackJu.Tseaty)
{
min = min(BlackJu.seaty,BlackJu.Tseaty);
max = max(BlackJu.seaty,BlackJu.Tseaty);
i = BlackJu.seatx;
for(j = min +1; j <= max; j ++)
{
if(j == max) //循环执行到最后,则表明中间没子
{
return true;
break;
}
else if(Checkerboard[i][j] == 0)//路径上无棋子的情况
{
continue;
}
else //路径上有棋子的情况
{
return false;
break;
}
}
}
else if(BlackJu.seaty == BlackJu.Tseaty && BlackJu.seatx != BlackJu.Tseatx)
{
min = min(BlackJu.seatx,BlackJu.Tseatx);
max = max(BlackJu.seatx,BlackJu.Tseatx);
j = BlackJu.seaty;
for(i = min +1; i <= max; i ++)
{
if(i == max) //循环执行到最后,则返回最后一点的值
{
return true;
break;
}
else if(Checkerboard[i][j] == 0)//路径上无棋子的情况
{
continue;
}
else //路径上有棋子的情况
{
return false;
break;
}
}
}
else
{
return false;
}
}
BOOL PieceRedJu::Move(PieceRedJu &RedJu)
{
int i, j;
int min, max;
if(RedJu.seatx == RedJu.Tseatx && RedJu.seaty != RedJu.Tseaty)
{
min = min(RedJu.seaty,RedJu.Tseaty);
max = max(RedJu.seaty,RedJu.Tseaty);
i = RedJu.seatx;
for(j = min +1; j <= max; j ++)
{
if(j == max) //循环执行到最后,则表明中间无子
{
return true;
break;
}
else if(Checkerboard[i][j] == 0)//路径上无棋子的情况
{
continue;
}
else //路径上有棋子的情况
{
return false;
break;
}
}
}
else if(RedJu.seaty == RedJu.Tseaty && RedJu.seatx != RedJu.Tseatx)
{
min = min(RedJu.seatx,RedJu.Tseatx);
max = max(RedJu.seatx,RedJu.Tseatx);
j = RedJu.seaty;
for(i = min +1; i <= max; i ++)
{
if(i == max) //循环执行到最后,则返回最后一点的值
{
return true;
break;
}
else if(Checkerboard[i][j] == 0)//路径上无棋子的情况
{
continue;
}
else //路径上有棋子的情况
{
return false;
break;
}
}
}
else
{
return false;
}
}
//红马的move()函数
BOOL PieceRedMa::Move(PieceRedMa &RedMa)
{
//(x,y)表示原来马的坐标;(Tx,Ty)表示马可能走的坐标
int x = RedMa.seatx;
int tx = RedMa.Tseatx;
int y = RedMa.seaty;
int ty = RedMa.Tseaty;
if(Checkerboard[tx][ty] >= 0 && Checkerboard[tx][ty] <= 7)//当(tx,ty)为空(用0表示)或黑子(1~7表示)时,可下
{
if(Checkerboard[x +1 ][y] == 0 && tx ==x + 2 && ty == y + 1)//(x+1,y)为空,(tx,ty)=(x+2,y+1)
{
return true;
/*个人观点:用如下代码代替上一句return语句,然后直接初始化棋盘或许可以实现棋盘重绘。
Checkerboard[tx][ty]==BLACK_MA;
Checkerboard[x][y]==0;
*/
}
else if(Checkerboard[x + 1][y] == 0 && tx == x + 2 && ty == y - 1)//(x+1,y)为空:表示不蹩马脚;(tx,ty)=(x+2,y-1):马走斜日
{
return true;
}
else if(Checkerboard[x - 1][y] == 0 && tx == x - 2 && ty == y + 1)//(x-1,y)为空,(tx,ty)=(x-2,y+1)
{
return true;
}
else if(Checkerboard[x - 1][y] == 0 && tx == x-2 && ty == y - 1)//(x-1,y)为空,(tx,ty)=(x-2,y-1)
{
return true;
}
else if(Checkerboard[x][y + 1] == 0 && tx == x + 1 && ty == y + 2)//(x,y+1)为空,(tx,ty)=(x+1,y+2)
{
return true;
}
else if(Checkerboard[x][y + 1] == 0 && tx == x - 1 && ty == y + 2)//(x,y+1)为空,(tx,ty)=(x-1,y+2)
{
return true;
}
else if(Checkerboard[x][y - 1] == 0 && tx == x + 1 && ty == y - 2)//(x,y-1)为空,(tx,ty)=(x+1,y-2)
{
return true;
}
else if(Checkerboard[x][y - 1] == 0 && tx == x - 1 && ty == y - 2)//(x,y-1)为空,(tx,ty)=(x-1,y-2)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
BOOL PieceBlackMa::Move(PieceBlackMa &BlackMa)
{
//(x,y)表示原来黑马的坐标;(Tx,Ty)表示黑马可能走的坐标
int x = BlackMa.seatx;
int tx = BlackMa.Tseatx;
int y = BlackMa.seaty;
int ty = BlackMa.Tseaty;
if(Checkerboard[tx][ty] == 0 || (Checkerboard[tx][ty] >= 8 && Checkerboard[tx][ty] <= 14))
{
if(Checkerboard[x + 1][y] == 0 && tx == x + 2 && ty == y + 1)//(x+1,y)为空:表示不蹩马脚;(tx,ty)=(x+2,y-1):马走斜日
{
return true;
/*个人观点:用如下代码代替上一句return语句,然后直接初始化棋盘或许可以实现棋盘重绘。
Checkerboard[tx][ty]==BLACK_MA;
Checkerboard[x][y]==0;
*/
}
else if(Checkerboard[x + 1][y] == 0 && tx == x + 2 && ty == y - 1)//(x+1,y)为空,(tx,ty)=(x+2,y-1)
{
return true;
}
else if(Checkerboard[x - 1][y] == 0 && tx == x - 2 && ty == y + 1)//(x-1,y)为空,(tx,ty)=(x-2,y+1)
{
return true;
}
else if(Checkerboard[x - 1][y] == 0 && tx == x - 2 && ty == y - 1)//(x-1,y)为空,(tx,ty)=(x-2,y-1)
{
return true;
}
else if(Checkerboard[x][y + 1] == 0 && tx == x + 1 && ty == y + 2)//(x,y+1)为空,(tx,ty)=(x+1,y+2)
{
return true;
}
else if(Checkerboard[x][y + 1] == 0 && tx == x - 1 && ty == y + 2)//(x,y+1)为空,(tx,ty)=(x-1,y+2)
{
return true;
}
else if(Checkerboard[x][y - 1] == 0 && tx == x + 1 && ty == y - 2)//(x,y-1)为空,(tx,ty)=(x+1,y-2)
{
return true;
}
else if(Checkerboard[x][y - 1] == 0 && tx == x - 1 && ty == y - 2)//(x,y-1)为空,(tx,ty)=(x-1,y-2)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
BOOL PieceBlackXiang::Move(PieceBlackXiang &BlackXiang)
{
if(BlackXiang.Tseaty <= 4) //是否越界判断
{
if((BlackXiang.Tseatx - BlackXiang.seatx) == 2 && (BlackXiang.Tseaty - BlackXiang.seaty) == 2)//坐标都增加的情况
{
if(Checkerboard[BlackXiang.seatx + 1][BlackXiang.seaty + 1] == 0)
{
return true;
}
else
{
return false;
}
}
else if((BlackXiang.Tseatx - BlackXiang.seatx) == 2 && (BlackXiang.Tseaty-BlackXiang.seaty) == -2)
{
if(Checkerboard[BlackXiang.seatx + 1][BlackXiang.seaty - 1] == 0)
{
return true;
}
else
{
return false;
}
}
else if((BlackXiang.Tseatx - BlackXiang.seatx) == -2 && (BlackXiang.Tseaty - BlackXiang.seaty) == 2)
{
if(Checkerboard[BlackXiang.seatx - 1][BlackXiang.seaty + 1] == 0)
{
return true;
}
else
{
return false;
}
}
else if((BlackXiang.Tseatx - BlackXiang.seatx) == -2 && (BlackXiang.Tseaty-BlackXiang.seaty) == -2)
{
if(Checkerboard[BlackXiang.seatx - 1][BlackXiang.seaty - 1] == 0)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
BOOL PieceRedXiang::Move(PieceRedXiang &RedXiang)
{
if(RedXiang.Tseaty >= 5) //是否越界判断
{
if((RedXiang.Tseatx-RedXiang.seatx) == 2 && (RedXiang.Tseaty-RedXiang.seaty) == 2)//坐标都增加的情况
{
if(Checkerboard[RedXiang.seatx + 1][RedXiang.seaty + 1] == 0)
{
return true;
}
else
{
return false;
}
}
else if((RedXiang.Tseatx - RedXiang.seatx) == 2 && (RedXiang.Tseaty-RedXiang.seaty) == -2)
{
if(Checkerboard[RedXiang.seatx + 1][RedXiang.seaty-1] == 0)
{
return true;
}
else
{
return false;
}
}
else if((RedXiang.Tseatx - RedXiang.seatx) == -2 && (RedXiang.Tseaty - RedXiang.seaty) == 2)
{
if(Checkerboard[RedXiang.seatx - 1][RedXiang.seaty+1] == 0)
{
return true;
}
else
{
return false;
}
}
else if((RedXiang.Tseatx - RedXiang.seatx) == -2 && (RedXiang.Tseaty - RedXiang.seaty) == -2)
{
if(Checkerboard[RedXiang.seatx - 1][RedXiang.seaty-1] == 0)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
//士的move方法
BOOL PieceRedShi::Move(PieceRedShi &RedShi)
{
if((abs(RedShi.seatx - RedShi.Tseatx) == 1) && (abs(RedShi.seaty - RedShi.Tseaty) == 1) && (RedShi.Tseatx >=3 && RedShi.Tseatx <=5 && RedShi.Tseaty >=7 && RedShi.Tseaty <= 9))
return true;
else
return false;
}
BOOL PieceBlackShi::Move(PieceBlackShi &BlackShi)
{
if((abs(BlackShi.seatx-BlackShi.Tseatx) ==1 ) && (abs(BlackShi.seaty - BlackShi.Tseaty) == 1) && (BlackShi.Tseatx >=3 && BlackShi.Tseatx <= 5 && BlackShi.Tseaty >= 0 && BlackShi.Tseaty <= 2))
return true;
else
return false;
}
//将的move方法
BOOL PieceRedShuai::Move(PieceRedShuai &RedShuai)
{
if((RedShuai.Tseatx==RedShuai.seatx) && (Checkerboard[RedShuai.Tseatx][RedShuai.Tseaty] == BLACK_JIANG ) )
{
for(int i=RedShuai.seaty-1; i > RedShuai.Tseaty; i-- )
{
if( Checkerboard[RedShuai.Tseatx][i]!=0 )//中间有子
{
return false;
break;
}
else if(i==(RedShuai.Tseaty+1)) //中间无子
{
return true;
}
}
}
else if(RedShuai.Tseatx >= 3 && RedShuai.Tseatx <= 5 && RedShuai.Tseaty >= 7 && RedShuai.Tseaty <= 9)
{
if((abs(RedShuai.Tseatx - RedShuai.seatx) == 1 && (RedShuai.Tseaty == RedShuai.seaty)) || (abs(RedShuai.Tseaty - RedShuai.seaty) == 1) && (RedShuai.Tseatx == RedShuai.seatx))
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
BOOL PieceBlackJiang::Move(PieceBlackJiang &BlackJiang)
{
//老头子见面
if((BlackJiang.Tseatx == BlackJiang.seatx) && (Checkerboard[BlackJiang.Tseatx][BlackJiang.Tseaty] == RED_SHUAI ) )
{
for(int i = BlackJiang.seaty+1; i < BlackJiang.Tseaty; i ++ )
{
if(Checkerboard[BlackJiang.Tseatx][i] != 0 )//中间有子
{
return false;
break;
}
else if(i == (BlackJiang.Tseaty-1)) //中间无子
{
return true;
}
}
}
else if(BlackJiang.Tseatx >= 3 && BlackJiang.Tseatx <= 5 && BlackJiang.Tseaty >= 0 && BlackJiang.Tseaty <= 2)
{
if((abs(BlackJiang.Tseatx - BlackJiang.seatx) == 1 && (BlackJiang.Tseaty == BlackJiang.seaty)) || (abs(BlackJiang.Tseaty - BlackJiang.seaty) == 1) && (BlackJiang.Tseatx == BlackJiang.seatx))
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
//卒的move方法
BOOL PieceBlackZu::Move(PieceBlackZu &BlackZu)
{
if(BlackZu.Tseatx == BlackZu.seatx && BlackZu.Tseaty - BlackZu.seaty == 1) //向前一步
{
return true;
}
else if(BlackZu.Tseaty == BlackZu.seaty && abs(BlackZu.Tseatx - BlackZu.seatx) == 1) //左右一步
{
if(BlackZu.seaty >= 5 && BlackZu.seaty <= 9) //过河
{
return true;
}
else //没过河
{
return false;
}
}
else //既不是向前一步,也不是左右一步
{
return false;
}
}
BOOL PieceRedZu::Move(PieceRedZu &RedZu)
{
if(RedZu.Tseatx == RedZu.seatx && RedZu.seaty - RedZu.Tseaty == 1) //向前一步
{
return true;
}
else if(RedZu.seaty == RedZu.Tseaty && abs(RedZu.seatx - RedZu.Tseatx) == 1) //左右一步
{
if(RedZu.seaty <= 4 && RedZu.seaty >= 0) //过河
{
return true;
}
else //没过河
{
return false;
}
}
else //既不是向前一步,也不是左右一步
{
return false;
}
}
//炮的move方法
BOOL PieceBlackPao::Move(PieceBlackPao &BlackPao)
{
int a,b;
int min,max,flag;
if(BlackPao.seatx == BlackPao.Tseatx && BlackPao.seaty != BlackPao.Tseaty) //上下移动
{
min = min(BlackPao.seaty , BlackPao.Tseaty);
max = max(BlackPao.seaty , BlackPao.Tseaty);
a = BlackPao.Tseatx;
flag = 0;
for(b = min + 1; b < max; b++)
{
if(Checkerboard[a][b] == 0)
{
continue;
}
else
{
flag++;
}
}
}
else if(BlackPao.seatx != BlackPao.Tseatx && BlackPao.seaty == BlackPao.Tseaty) //左右移动
{
min = min(BlackPao.seatx , BlackPao.Tseatx);
max = max(BlackPao.seatx , BlackPao.Tseatx);
b = BlackPao.Tseaty;
flag = 0;
for(a = min + 1; a < max; a++)
{
if(Checkerboard[a][b] == 0)
{
continue;
}
else
{
flag++;
}
}
}
else //斜向移动
{
return false;
}
a = BlackPao.Tseatx;
b = BlackPao.Tseaty;
if(flag == 1) //中途有且只有一个棋子
{
if(Checkerboard[a][b] != 0) //新地址有对方的红色棋子
{
return true;
}
else //新地址没有棋子
{
return false;
}
}
else //中途没有棋子或不止一个棋子
{
if(Checkerboard[a][b] != 0) //新地址有棋子
{
return false;
}
else //新地址没有棋子
{
if(flag == 0)
{
return true;
}
else
{
return false;
}
}
}
}
BOOL PieceRedPao::Move(PieceRedPao &RedPao)
{
int a, b;
int min, max, flag;
if(RedPao.seatx == RedPao.Tseatx && RedPao.seaty != RedPao.Tseaty) //上下移动
{
min = min(RedPao.seaty, RedPao.Tseaty);
max = max(RedPao.seaty, RedPao.Tseaty);
a = RedPao.Tseatx;
flag = 0;
for(b = min + 1; b < max; b++)
{
if(Checkerboard[a][b] == 0)
{
continue;
}
else
{
flag++;
}
}
}
else if(RedPao.seatx != RedPao.Tseatx && RedPao.seaty == RedPao.Tseaty) //左右移动
{
min = min(RedPao.seatx , RedPao.Tseatx);
max = max(RedPao.seatx , RedPao.Tseatx);
b = RedPao.Tseaty;
flag = 0;
for(a = min + 1; a < max; a++)
{
if(Checkerboard[a][b] == 0)
{
continue;
}
else
{
flag++;
}
}
}
else //斜向移动
{
return false;
}
a = RedPao.Tseatx;
b = RedPao.Tseaty;
if(flag == 1) //中途有且只有一个棋子
{
if(Checkerboard[a][b] != 0) //新地址有对方的黑色棋子
{
return true;
}
else //新地址没有棋子
{
return false;
}
}
else //中途没有棋子或不止一个棋子
{
if(Checkerboard[a][b] != 0) //新地址有棋子
{
return false;
}
else //新地址没有棋子
{
if(flag == 0)
{
return true;
}
else
{
return false;
}
}
}
}
void ChessPiece::Judge()
{
int numjiang = 0, numshuai = 0;
for(i = 3; i <= 5; i++)
{
for(j = 0; j <= 2; j++)//扫描将所在区域
{
if(Checkerboard[i][j] == BLACK_JIANG)
{
numjiang ++;
break;
}
else if(Checkerboard[i][j] == RED_SHUAI)
{
numshuai ++;
break;
}
else
{
continue;
}
}
for(j = 7; j <= 9; j++)//扫描帅所在区域
{
if(Checkerboard[i][j] == 12)
{
numshuai ++;
break;
}
else if(Checkerboard[i][j] == 5)
{
numjiang ++;
break;
}
else
{
continue;
}
}
}
switch (cout1/5+1)
{
case 1: score1=600;
break;
case 2: score1=300;
break;
case 3: score1=200;
break;
case 4: score1=150;
break;
case 5: score1=120;
break;
case 6: score1=100;
break;
case 7: score1=80;
break;
case 8: score1= 70 ;
break;
case 9: score1=60;
break;
case 10: score1=50;
break;
case 11:case 12: case 13: case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:
case 26: case 27:case 28:case 29:case 30:
score1=(30-cout1/5)*2;
break;
case 31: score1=0;
break;
default: break;
}
if(numjiang == 0)//如果将所在区域没有将的属性,则红方胜
{
if(flag1==2) //红地主 黑农民
{
char c1[100] = "红方胜!玩家1输";
char c2[10] = "";
itoa(2*score+score1, c2, 10);//地主胜2倍分数
char c3[10] = "";
itoa(score+score1, c3, 10);//输1倍分数
strcat(c1,c3);
strcat(c1,"分,玩家2赢");
strcat(c1,c2);
strcat(c1,"分");
MessageBox(TEXT(c1),"胜负已分");
player1score-=score+score1;
player2score+=2*score+score1;
flag2=2;
}
else if(flag1==3) //红农民黑地主
{
char c1[100] = "红方胜!玩家1输";
char c2[10] = "";
itoa(score+score1, c2, 10);//地主胜2倍分数
char c3[10] = "";
itoa(2*score+score1, c3, 10);//输1倍分数
strcat(c1,c3);
strcat(c1,"分,玩家2赢");
strcat(c1,c2);
strcat(c1,"分");
MessageBox(TEXT(c1),"胜负已分");
player1score-=2*score+score1;
player2score+=score+score1;
}
gameover = true;
flag2=2;
}
else if(numshuai == 0)//如果帅所在区域没有帅的属性,则黑方胜
{ if(flag1==3)
// MessageBox(TEXT("黑方胜!"),"胜负已分");
{
char c1[100] = "黑方胜!玩家1赢";
char c2[10] = "";
itoa(2*score+score1, c2, 10);
char c3[10] = "";
itoa(score+score1, c3, 10);//输1倍分数
strcat(c1,c2);
strcat(c1,"分,玩家2输");
strcat(c1,c3);
strcat(c1,"分");
MessageBox(TEXT(c1),"胜负已分");
player1score+=2*score+score1;
player2score-=score+score1;
flag2=2;
}
else if(flag1==2) //红农民黑地主
{
char c1[100] = "黑方胜!玩家1赢";
char c2[10] = "";
itoa(score+score1, c2, 10);
char c3[10] = "";
itoa(2*score+score1, c3, 10);//输1倍分数
strcat(c1,c2);
strcat(c1,"分,玩家2输");
strcat(c1,c3);
strcat(c1,"分");
MessageBox(TEXT(c1),"胜负已分");
player1score+=score+score1;
player2score-=2*score+score1;
}
gameover = true;
flag2=2;
}
/* else
{
//return true;
}*/
if(flag2==2)
{
c.write();
//OnInitDialog();
// c.read1();
//c.Onstart() ;
flag2=0;
}
}
void CMyDlg::DoGaveUp()
{ switch (cout1/5+1)
{
case 1: score1=600;
break;
case 2: score1=300;
break;
case 3: score1=200;
break;
case 4: score1=150;
break;
case 5: score1=120;
break;
case 6: score1=100;
break;
case 7: score1=80;
break;
case 8: score1= 70 ;
break;
case 9: score1=60;
break;
case 10: score1=50;
break;
case 11:case 12: case 13: case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:
case 26: case 27:case 28:case 29:case 30:
score1=(30-cout1/5)*2;
break;
case 31: score1=0;
break;
default: break;
}
if(Pstatus)
{
//MessageBox(TEXT("黑方认输!"),"投降啦!");
if(flag1==2) //红地主 黑农民
{
char c1[100] = "黑方认输!玩家1输";
char c2[10] = "";
itoa(2*score+score1, c2, 10);//地主胜2倍分数
char c3[10] = "";
itoa(score+score1, c3, 10);//输1倍分数
strcat(c1,c3);
strcat(c1,"分,玩家2赢");
strcat(c1,c2);
strcat(c1,"分");
MessageBox(TEXT(c1),"投降啦!");
player1score-=score+score1;
player2score+=2*score+score1;
}
else if(flag1==3) //红农民黑地主
{
char c1[100] = "黑方认输!玩家1输";
char c2[10] = "";
itoa(score+score1, c2, 10);//地主胜2倍分数
char c3[10] = "";
itoa(2*score+score1, c3, 10);//输1倍分数
strcat(c1,c3);
strcat(c1,"分,玩家2赢");
strcat(c1,c2);
strcat(c1,"分");
MessageBox(TEXT(c1),"投降啦!");
player1score-=2*score+score1;
player2score+=score+score1;
}
gameover = true;
}
else
{
//MessageBox(TEXT("红方认输!"),"投降啦!");
if(flag1==3)
// MessageBox(TEXT("黑方胜!"),"胜负已分");
{
char c1[100] = "红方认输!玩家1赢";
char c2[10] = "";
itoa(2*score+score1, c2, 10);
char c3[10] = "";
itoa(score+score1, c3, 10);//输1倍分数
strcat(c1,c2);
strcat(c1,"分,玩家2输");
strcat(c1,c3);
strcat(c1,"分");
MessageBox(TEXT(c1),"投降啦!");
player1score+=2*score+score1;
player2score-=score+score1;
printf("%d\n",player1score);
}
else if(flag1==2) //红农民黑地主
{
char c1[100] = "红方认输!玩家1赢";
char c2[10] = "";
itoa(score+score1, c2, 10);
char c3[10] = "";
itoa(2*score+score1, c3, 10);//输1倍分数
strcat(c1,c2);
strcat(c1,"分,玩家2输");
strcat(c1,c3);
strcat(c1,"分");
MessageBox(TEXT(c1),"投降啦!");
player1score=player1score+score+score1;
player2score=player2score-2*score-score1;
printf("%d\n",player1score);
}
gameover = true;
write();
read1();
}
ButtonColor();
}
void CMyDlg::DoTie()
{
if(IDYES == AfxMessageBox("对方请求和棋,是否同意?",MB_YESNO))
{
MessageBox(TEXT("双方和棋!红黑两方均不得分"),"结果");
gameover = true;
GetDlgItem(ID_START)->EnableWindow(true);
// GetDlgItem(IDC_BUTTONC)->EnableWindow(true);
}
else
{
MessageBox(TEXT("对方不同意和棋!"),"结果");
}
ButtonColor();
}
void CMyDlg::DoUndo()
{
if(IDYES == AfxMessageBox("对方请求悔棋,是否同意?",MB_YESNO))
{
for(i = 0; i < 9; i++)
for(j = 0; j <10; j ++)
{
Checkerboard[i][j] = TemCheckerboard[i][j];
}
CDC thmem7 ;
CClientDC dc(this);
thmem7.CreateCompatibleDC(&dc);
thmem7.SelectObject(m_board);
dc.BitBlt(0,0,460,525,&thmem7,0,0,SRCCOPY);
DoDraw();
GetDlgItem(IDC_HUIQI)->EnableWindow(false);
Pstatus = !Pstatus;
}
else
{
MessageBox(TEXT("对方不同意悔棋!"),"结果");
}
}
void CMyDlg::ButtonColor()
{
if(gameover)
{
GetDlgItem(IDC_RENSHU)->EnableWindow(false);
GetDlgItem(IDC_HUIQI)->EnableWindow(false);
GetDlgItem(IDC_QIUHE)->EnableWindow(false);
}
}
void CMyDlg::OnOK()
{
// TODO: Add extra validation here
exit(0);
}
void CMyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
CChange changedlg;
changedlg.DoModal();
}
void CMyDlg::OnOK22() //背景音乐函数
{
/*
这个也可以
CString str;
//capture.release();
//CFileDialog *File;
MCI_OPEN_PARMS mciopenparms;//打开
MCI_PLAY_PARMS mciplayparms;//播放
//FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi)|*.avi")); //生成一个对话框
str="./music/music.wav";
//while(1)
//{
mciopenparms.lpstrElementName=str;//播放路径,文件为mid格式
mciopenparms.lpstrDeviceType=NULL;//文件类型
MCIERROR ret = mciSendCommand(0,MCI_OPEN,MCI_DEVTYPE_WAVEFORM_AUDIO,
(DWORD)(LPVOID)&mciopenparms);//向MCI设备发送命令消息
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
m_count=mciopenparms.wDeviceID;
mciplayparms.dwCallback=(DWORD)GetSafeHwnd();
mciplayparms.dwFrom=0;
ret = mciSendCommand(m_count,MCI_PLAY,MCI_FROM| MCI_NOTIFY ,(DWORD)(LPVOID)& mciplayparms);
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
//mciSendCommand (m_DeviceID, MCI_CLOSE, NULL, NULL);
*/
/*
//可以的
HWND hMCI;
CString choose = _T("./music/music.wav"); //音乐文件的路径
hMCI = MCIWndCreate(NULL, NULL,WS_POPUP|MCIWNDF_NOPLAYBAR|MCIWNDF_NOMENU,choose);
MCIWndPlay(hMCI); //播放音乐*/
PlaySound("./music/music.wav",NULL,SND_FILENAME|SND_ASYNC |SND_LOOP); //方法3可以
}
/*
void CMyDlg::OnOK2() //背景音乐按钮
{// TODO: Add your control notification handler code here
//CDlg::OnBnClickedButton6();
//MCIDEVICEID m_count;
//CString strFile;
////capture.release();
//CFileDialog *FileDlg;
////FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi)|*.avi")); //生成一个对话框
//FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi,*.mp4,*.rmvb,*.*)|*.avi;*.AVI;*.mp4;*.MP4;*.rmvb;*.RMVB;*.*||")); //生成一个对话框
//if (FileDlg->DoModal() != IDOK)
// return;
//strFile = FileDlg->GetPathName();
//PlaySound(strFile, NULL, SND_FILENAME | SND_ASYNC);// TODO: 在此添加控件通知处理程序代码 成功版
//成功二版
if(flag3%2==1)
{
CString str;
//capture.release();
//CFileDialog *File;
MCI_OPEN_PARMS mciopenparms;//打开
MCI_PLAY_PARMS mciplayparms;//播放
//FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi)|*.avi")); //生成一个对话框
str="./music/music.wav";
//while(1)
//{
mciopenparms.lpstrElementName=str;//播放路径,文件为mid格式
mciopenparms.lpstrDeviceType=NULL;//文件类型
MCIERROR ret = mciSendCommand(0,MCI_OPEN,MCI_DEVTYPE_WAVEFORM_AUDIO,
(DWORD)(LPVOID)&mciopenparms);//向MCI设备发送命令消息
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
m_count=mciopenparms.wDeviceID;
mciplayparms.dwCallback=(DWORD)GetSafeHwnd();
mciplayparms.dwFrom=0;
ret = mciSendCommand(m_count,MCI_PLAY,MCI_FROM| MCI_NOTIFY ,(DWORD)(LPVOID)& mciplayparms);
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
//mciSendCommand (m_DeviceID, MCI_CLOSE, NULL, NULL);
flag3++;
}
else
{
mciSendCommand(m_count,MCI_CLOSE,0,NULL);
flag3++;
//同时也是关闭播放设备,所有声音都会停止// TODO: 在此添加控件通知处理程序代码
}
}*/
void CMyDlg::Onzouqi() //走棋音
{
// TODO: Add your control notification handler code here
if(flag4%2==1)
{
/*
CString str;
//capture.release();
//CFileDialog *File;
MCI_OPEN_PARMS mciopenparms;//打开
MCI_PLAY_PARMS mciplayparms;//播放
//FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi)|*.avi")); //生成一个对话框
str="./sound/yidong.wav";
//while(1)
//{
mciopenparms.lpstrElementName=str;//播放路径,文件为mid格式
mciopenparms.lpstrDeviceType=NULL;//文件类型
MCIERROR ret = mciSendCommand(0,MCI_OPEN,MCI_DEVTYPE_WAVEFORM_AUDIO,
(DWORD)(LPVOID)&mciopenparms);//向MCI设备发送命令消息
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
m_count=mciopenparms.wDeviceID;
mciplayparms.dwCallback=(DWORD)GetSafeHwnd();
mciplayparms.dwFrom=0;
ret = mciSendCommand(m_count,MCI_PLAY,MCI_FROM| MCI_NOTIFY ,(DWORD)(LPVOID)& mciplayparms);
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
//mciSendCommand (m_DeviceID, MCI_CLOSE, NULL, NULL);
*/
flag4++;
}
else
{
mciSendCommand(m_count,MCI_CLOSE,0,NULL);
flag4++;
//同时也是关闭播放设备,所有声音都会停止// TODO: 在此添加控件通知处理程序代码
}
}
void CMyDlg::Onzouqi1() //走棋音函数
{
// PlaySound("./music/music1.wav",NULL,SND_FILENAME|SND_ASYNC |SND_LOOP);
CString str;
//capture.release();
//CFileDialog *File;
MCI_OPEN_PARMS mciopenparms;//打开
MCI_PLAY_PARMS mciplayparms;//播放
//FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi)|*.avi")); //生成一个对话框
str="./sound/yidong.wav";
//while(1)
//{
mciopenparms.lpstrElementName=str;//播放路径,文件为mid格式
mciopenparms.lpstrDeviceType=NULL;//文件类型
MCIERROR ret = mciSendCommand(0,MCI_OPEN,MCI_DEVTYPE_WAVEFORM_AUDIO,
(DWORD)(LPVOID)&mciopenparms);//向MCI设备发送命令消息
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
m_count=mciopenparms.wDeviceID;
mciplayparms.dwCallback=(DWORD)GetSafeHwnd();
mciplayparms.dwFrom=0;
ret = mciSendCommand(m_count,MCI_PLAY,MCI_FROM| MCI_NOTIFY ,(DWORD)(LPVOID)& mciplayparms);
if(ret != 0)
{
WORD err = LOWORD(ret);
char strText[1024] = {0};
mciGetErrorString(err,strText,sizeof(strText));
MessageBox(strText);
}
//mciSendCommand (m_DeviceID, MCI_CLOSE, NULL, NULL);
}
void CMyDlg::OnOK2() //开音乐
{// TODO: Add your control notification handler code here
//CDlg::OnBnClickedButton6();
//MCIDEVICEID m_count;
//CString strFile;
////capture.release();
//CFileDialog *FileDlg;
////FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi)|*.avi")); //生成一个对话框
//FileDlg = new CFileDialog(TRUE,_T(" "),_T(" "), OFN_FILEMUSTEXIST |OFN_HIDEREADONLY, _T("FileType(*.avi,*.mp4,*.rmvb,*.*)|*.avi;*.AVI;*.mp4;*.MP4;*.rmvb;*.RMVB;*.*||")); //生成一个对话框
//if (FileDlg->DoModal() != IDOK)
// return;
//strFile = FileDlg->GetPathName();
//PlaySound(strFile, NULL, SND_FILENAME | SND_ASYNC);// TODO: 在此添加控件通知处理程序代码 成功版
//成功二版
if(flag3%2==1)
{
PlaySound("./music/music.wav",NULL,SND_FILENAME|SND_ASYNC |SND_LOOP);/*
可以的
HWND hMCI;
CString choose = _T("./music/music.wav"); //音乐文件的路径
hMCI = MCIWndCreate(NULL, NULL,WS_POPUP|MCIWNDF_NOPLAYBAR|MCIWNDF_NOMENU,choose);
MCIWndPlay(hMCI); //播放音乐
flag3++;*/
flag3++;
}
else
{ PlaySound(NULL,NULL,SND_FILENAME|SND_ASYNC |SND_LOOP);
flag3++;
/*
可以的
mciSendCommand(m_count,MCI_CLOSE,0,NULL);
flag3++;
//同时也是关闭播放设备,所有声音都会停止// TODO: 在此添加控件通知处理程序代码
*/
}
}
/*void CMyDlg::Onzouqi1() //走棋音函数
{
}
void CMyDlg::Onzouqi() //走棋音函数
{}*/
void CMyDlg::zouqi() //走棋音函数
{//一套 每次走棋调用一次
mciSendCommand(m_count,MCI_CLOSE,0,NULL);
if(flag4%2==0)
Onzouqi1();
}