wuziqi.rar

  • PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 574KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 1
    下载次数
  • 2007-09-06 04:56
    上传日期
五子棋可2人,大家喜欢的话可以来侃侃,多支持下在
wuziqi.rar
  • 五子棋(支持单机和网络)
  • www.cnzz.cn
  • res
  • wuziqi.ico
    1.1KB
  • 5++.ico
    766B
  • wuziqiDoc.ico
    1.1KB
  • Toolbar.bmp
    1.1KB
  • wuziqi.rc2
    398B
  • Debug
  • Blocksock.h
    3.6KB
  • connectto.cpp
    944B
  • wuziqiView.plg
    5.3KB
  • wuziqi.clw
    3.4KB
  • Overall.h
    778B
  • wuziqi.cpp
    4KB
  • askconnect.h
    1.2KB
  • wuziqi.h
    1.3KB
  • wuziqiView.opt
    47.5KB
  • wuziqi.dsp
    5.3KB
  • wuziqiDoc.cpp
    1.7KB
  • connectto.h
    1.2KB
  • wuziqi.ncb
    169KB
  • Overall.cpp
    9.7KB
  • wuziqiView.cpp
    26.2KB
  • chess.cpp
    901B
  • Blocksock.cpp
    9KB
  • help.htm
    12.8KB
  • wuziqiView.dsw
    545B
  • chess.h
    745B
  • wuziqi.opt
    54.5KB
  • StdAfx.cpp
    208B
  • MainFrm.cpp
    5.5KB
  • resource.h
    1.7KB
  • wuziqiView.dsp
    3.4KB
  • wuziqi.aps
    30.4KB
  • wuziqi.plg
    246B
  • MainFrm.h
    1.8KB
  • resultwin.cpp
    942B
  • wuziqiDoc.h
    1.4KB
  • StdAfx.h
    1.1KB
  • wuziqiView.ncb
    33KB
  • resultwin.h
    1.2KB
  • wuziqi.rc
    12.6KB
  • askconnect.cpp
    998B
  • wuziqi.dsw
    535B
  • wuziqiView.h
    2.6KB
  • 使用说明.CHM
    48.9KB
  • www.pudn.com.txt
    218B
内容介绍
// wuziqiView.cpp : implementation of the CWuziqiView class // #include "stdafx.h" #include "wuziqi.h" #include "MainFrm.h" #include "wuziqiDoc.h" #include "wuziqiView.h" #include "chess.h" #include "blocksock.h" #include "connectto.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CWuziqiView IMPLEMENT_DYNCREATE(CWuziqiView, CView) BEGIN_MESSAGE_MAP(CWuziqiView, CView) //{{AFX_MSG_MAP(CWuziqiView) ON_WM_LBUTTONDOWN() ON_COMMAND(ID_BACK_BLACK, OnBackBlack) ON_UPDATE_COMMAND_UI(ID_BACK_BLACK, OnUpdateBackBlack) ON_COMMAND(ID_BACK_WHITE, OnBackWhite) ON_UPDATE_COMMAND_UI(ID_BACK_WHITE, OnUpdateBackWhite) ON_COMMAND(ID_RULE_CHANGE, OnRuleChange) ON_UPDATE_COMMAND_UI(ID_RULE_CHANGE, OnUpdateRuleChange) ON_WM_RBUTTONDOWN() ON_WM_RBUTTONDBLCLK() ON_COMMAND(ID_RULE_3344, OnRule3344) ON_COMMAND(ID_RULE_CLEAN, OnRuleClean) ON_COMMAND(ID_CONNECT, OnConnect) ON_COMMAND(ID_STARTSERVER, OnStartserver) ON_UPDATE_COMMAND_UI(ID_STARTSERVER, OnUpdateStartserver) ON_COMMAND(ID_DISCONNECT, OnDisconnect) ON_UPDATE_COMMAND_UI(ID_DISCONNECT, OnUpdateDisconnect) ON_UPDATE_COMMAND_UI(ID_RULE_RESTART, OnUpdateRuleRestart) ON_COMMAND(ID_FILE_OPEN, OnFileOpen) ON_COMMAND(ID_FILE_SAVE, OnFileSave) ON_COMMAND(ID_RULE_RESTART, OnRuleRestart) ON_WM_DESTROY() //}}AFX_MSG_MAP ON_MESSAGE(WM_CONNECT,OnConnect)//得到对方网络数据发送的消息 END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWuziqiView construction/destruction CBlockingSocket g_sListen;//链接对象实例 UINT ServerThreadProc(LPVOID pParam);//服务器端进程 UINT ClientSocketThreadProc(LPVOID pParam);//发送数据进程 char ACCEPT[64],SEND[64];//接受,发送,数据类型 CString CONADDR,SERVER;//ip,计算机名 CSockAddr saClient;//ip地址 CWuziqiView::CWuziqiView() { who=whotemp=whohasjinshou=1;//初始化先首是黑棋 connect=youcansendmessage=connect=startserver=0;//初始化没有连接 WSADATA wsd;//初始化连接数据 VERIFY(WSAStartup(0x0101, &wsd) == 0); TRACE("WSAStartup -- min version = %x\n", wsd.wVersion); } CWuziqiView::~CWuziqiView() { } ///////////////////////////////////////////////////////////////////////////// // CWuziqiView drawing void CWuziqiView::OnDraw(CDC* pDC) { int nline,drawx,drawy,nCount; CString str,out; char number[3]; number[2]=number[1]='\0';number[0]='0'; CRect rectClient; nCount=0; GetClientRect(rectClient); pDC->SetMapMode(MM_ANISOTROPIC); pDC->SetWindowExt(64,64); pDC->SetViewportExt(rectClient.right,rectClient.bottom); //把试图分为64*64,没4格划一条线 for(nline=0;nline<=64;nline+=4) {//划线和打印数字 pDC->MoveTo(nline,0); pDC->LineTo(nline,64); pDC->SetTextColor(RGB(255,0,0)); pDC->TextOut(nline,0,number); pDC->SetTextColor(RGB(0,0,255)); pDC->TextOut(0,nline,number); if(number[1]!='\0')number[1]++; else { number[0]++; if(number[0]>='9'+1) { number[0]='1'; number[1]='0'; } } } for(nline=0;nline<=64;nline+=4) { pDC->MoveTo(0,nline); pDC->LineTo(64,nline); } //棋盘绘制完毕,开始收缩棋盘数据画棋子,0为没有,1为黑棋,-1为白旗 for(drawx=0;drawx<=17;drawx++) for(drawy=0;drawy<=17;drawy++) { if(all.allqipan[drawx][drawy]==1) { nCount++; out.Format("%d",nCount); CRect drawrect(drawx*4-1,drawy*4-1,drawx*4+1,drawy*4+1); CBrush brushHatch(RGB(34,108,243)); pDC->SelectObject(&brushHatch); pDC->Ellipse(drawrect); } if(all.qipantemp[drawx][drawy]==1) { CRect drawrect(drawx*4-1,drawy*4-1,drawx*4+1,drawy*4+1); CBrush brushHatch(RGB(180,231,180)); pDC->SelectObject(&brushHatch); pDC->Ellipse(drawrect); } if(all.allqipan[drawx][drawy]==-1) { CRect drawrect(drawx*4-1,drawy*4-1,drawx*4+1,drawy*4+1); CBrush brushHatch(RGB(78,229,78)); pDC->SelectObject(&brushHatch); pDC->Ellipse(drawrect); } if(all.qipantemp[drawx][drawy]==-1) { CRect drawrect(drawx*4-1,drawy*4-1,drawx*4+1,drawy*4+1); CBrush brushHatch(RGB(165,191,239)); pDC->SelectObject(&brushHatch); pDC->Ellipse(drawrect); } } //设置状态栏 CMainFrame* pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd; CStatusBar* pStatus=&pFrame->m_wndStatusBar; if(pStatus) { if(connect==0) { if(who==1) { str.Format("black down %d,white down %d,black's turn!",black.nCountkey,white.nCountkey); } else { str.Format("black down %d,white down %d,white's turn!",black.nCountkey,white.nCountkey); } } if(connect==1) { if(youcansendmessage==1) { int out1,out2; if(black.nCountkey>=white.nCountkey) { out1=black.nCountkey; out2=white.nCountkey; } else { out1=white.nCountkey; out2=black.nCountkey; } str.Format("you down %d,her down %d,your turn!",out2,out1); } else { int out1,out2; if(black.nCountkey>=white.nCountkey) { out1=black.nCountkey; out2=white.nCountkey; } else { out1=white.nCountkey; out2=black.nCountkey; } str.Format("you down %d,her down %d,her turn!",out1,out2); } } pStatus->SetPaneText(0,str); } //自动考试服务器监听 // OnStartserver(); // TODO: add draw code for native data here } ///////////////////////////////////////////////////////////////////////////// // CWuziqiView diagnostics #ifdef _DEBUG void CWuziqiView::AssertValid() const { CView::AssertValid(); } void CWuziqiView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CWuziqiDoc* CWuziqiView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWuziqiDoc))); return (CWuziqiDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CWuziqiView message handlers void CWuziqiView::OnLButtonDown(UINT nFlags, CPoint point) { float temp;int com; int x,y; CRect rectClient; GetClientRect(rectClient); temp=point.x*16; temp=temp/rectClient.right; com=temp; if(temp-com>0.5)x=temp+1; else x=temp; temp=point.y*16; temp=temp/rectClient.bottom; com=temp; if(temp-com>0.5)y=temp+1; else y=temp; //精确定位棋子位置 //判断可不可以下棋 if(connect==0) {//没有连接,直接更新数据 if(all.allqipan[x][y]==0) { MessageBeep(MB_OK); if(who==1) { black.keydown(x,y,who); all.allqipan[x][y]=1; if(all.shuangsi(x,y)==1&&whohasjinshou==1) { Invalidate(); resultwin lost; lost.m_Who.Format("black lost!double 4!"); lost.DoModal(); OnRuleRestart(); return; } int win=all.winchanglian(x,y); if(win==1) { Invalidate(); resultwin win; win.m_Who.Format("black win!"); win.DoModal(); OnRuleRestart(); return; } if(win==0&&whohasjinshou==1) { Invalidate(); resultwin lost; lost.m_Who.Format("black lost!long!"); lost.DoModal(); OnRuleRestart(); return; } if(all.shuangsan(x,y)==1&&whohasjinshou==1) { Invalidate(); resultwin fail; fail.m_Who.Format("Black lost!double 3!"); fail.DoModal(); OnRuleRestart(); return; } } else { white.keydown(x,y,who); all.allqipan[x][y]=-1; if(all.shuangsi(x,y)==1&&whohasjinshou==-1) { Invalidate(); resultwin lost; lost.m_Who.Format("white lost!double 4!"); lost.DoModal(); OnRuleRestart(); return; } int win=all.winchanglian(x,y); if(win==1) { Invalidate(); resultwin win; win.m_Who.Format("White w
评论
    相关推荐
    • wuzi.rar
      在linux中的利用C++和QT编写的五子棋代码,主要是qt的画图功能和鼠标的事件处理
    • wuzi.rar
      五子棋游戏,html写的,至少循环九次,别个写的,拿过来分享下
    • WUZI.rar
      使用VC++开发的五子棋游戏,支持两人对战和人机对战。
    • wuzi.rar
      五子棋游戏,一个简单的五子棋游戏代码,用J2ME编写,基本功能都已经满足
    • wuzi.rar
      基于Linux和X_Window的五子棋游戏,能够完成玩家落子,系统自动落子,判断输赢等
    • wuzi.rar
      五子棋 禁手判断 4,4禁手 3,3禁手
    • WuZi.rar
      本程序是五子棋游戏,可以实现红、蓝双方的对抗,使用VC编写,可作为参考。
    • wuzi.rar
      五子棋源代码,专为初学者,使用。非常好用,欢迎大家下载使用。
    • wuzi.rar
      主要功能 物资管理是企业管理非常重要的一环,它对企业的发展起着非常举足轻重的作用。由于物资的种类繁多,在各部门进出频繁,使得物资管理变得十分复杂。开发一套完善的物资管理系统不但可以使物资的管理者,能够...
    • tom_wuzi
      NULL 博文链接:https://kaka100.iteye.com/blog/733362