看看这个
http://www.ega-cn.com/bbs/game/xiangqi.asp

解决方案 »

  1.   

    那个是java做的啦! 
     你要那样做只能把图片放在层里,判断图片能移动的位置 ,或者每走一步向服务器
      发送一次信息 ,还是用java好吧
      

  2.   

    是的现在一般都用java做,我是刚刚开始学习编程,打听好了说C#有java的功能,而且特别优秀好学,我才开始学C#
    这是第一个真正的问题,请大家指教。
      

  3.   

    我原来也做过初步的东西,遇到太多问题了,如果用asp.net来做性能肯定不好的,最好能用socket或用directx9来做,但是客户端还的装.net,不爽。
    后来考虑用flashmx做,简单多了,并且性能也好,只是手头有事就放下了。
      

  4.   

    flashMX?
    可以做成http://www.chesshome.net/soft/xqstudio.exe这个样子吗?
    有没有相关的教程?谢谢指教
      

  5.   

    我决定先用C#做一个Windows应用程序请问pictureBox控件可以做数组吗?
    我在做棋子的时候有32个,红方我用pictureBox1、pictureBox3、pictureBox5这样的单数表示,黑方则用pictureBox2、pictureBox4这样的双数表示,
    在程序中我需要检测控件,请大侠指教pictureBox控件如何创建数组,如果调用:)期待
      

  6.   

    PictureBox[] mypics=new PictureBox[20];
    for(int i=0;i<20;i++)
    {
      mypics[i]=new PictureBox();
      mypics[i].Image=.....//这儿你自己写吧
    }
    引用的时候
    mypics[i] 就是你要调用的控件
      

  7.   

    “flashMX?
    可以做成http://www.chesshome.net/soft/xqstudio.exe这个样子吗?“呵呵,flash知道把,全是画的东西,什么样的界面都能做出来阿。建议前台用flashmx后台用flashcom。去macromedia.com他们公司网站看看,资料很全。
      

  8.   

    谢谢jcaomao(草帽) ,不过我还是使用得不当,下面是我用麻烦的方法写的,怎样应用您提供非方法简化呀?请指教···http://www.chesshome.net/bak/qp.exe
      

  9.   

    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;
    //TCHAR szHello[MAX_LOADSTRING];
    // LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); switch (message) 
    {   
          case WM_CREATE : 
      hWnd_pan=hWnd;
      int i,j;
      for(i=0;i<10;i++)
      for(j=0;j<9;j++)
                       Location_QiZi[i][j]=-1;
      // give the tuning value to the array
      for(i=0;i<10;i++)
      for(j=0;j<9;j++)
      {
                        position_tunx[i][3]=4;
                        position_tunx[i][4]=8;  
    position_tunx[i][5]=10;
                        position_tunx[i][6]=12;
    position_tunx[i][7]=18;
                        position_tunx[i][8]=18;
    if(i>=5)
    position_tuny[i][j]=14;
      }
    //initialize the "qi-pan"
                 Location_QiZi[0][0]=0;
                 Location_QiZi[0][1]=1;
     Location_QiZi[0][2]=2;
     Location_QiZi[0][3]=3;
     Location_QiZi[0][4]=4;
     Location_QiZi[0][5]=3;
     Location_QiZi[0][6]=2;
     Location_QiZi[0][7]=1;
     Location_QiZi[0][8]=0;
     Location_QiZi[9][0]=7;
                 Location_QiZi[9][1]=8;
     Location_QiZi[9][2]=9;
     Location_QiZi[9][3]=10;
     Location_QiZi[9][4]=11;
     Location_QiZi[9][5]=10;
     Location_QiZi[9][6]=9;
     Location_QiZi[9][7]=8;
     Location_QiZi[9][8]=7;
                 Location_QiZi[2][1]=5;
     Location_QiZi[2][7]=5;
     Location_QiZi[7][1]=12;
     Location_QiZi[7][7]=12;
     Location_QiZi[3][0]=6;
     Location_QiZi[3][2]=6;
     Location_QiZi[3][4]=6;
     Location_QiZi[3][6]=6;
     Location_QiZi[3][8]=6;
     Location_QiZi[6][0]=13;
     Location_QiZi[6][2]=13;
     Location_QiZi[6][4]=13;
     Location_QiZi[6][6]=13;
                Location_QiZi[6][8]=13;
      //load the "QIZI"
      qizi[0]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_RED_JU));            
      qizi[1]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_RED_MA));
      qizi[2]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_RED_XIANG));            
      qizi[3]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_RED_SHI));
      qizi[4]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_RED_SHUAI));
      qizi[5]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_RED_PAO));
      qizi[6]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_RED_BING));
      qizi[7]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BLACK_JU));
      qizi[8]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BLACK_MA));
      qizi[9]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BLACK_XIANG));
      qizi[10]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BLACK_SHI));
      qizi[11]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BLACK_JIANG));
      qizi[12]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BLACK_PAO));
      qizi[13]=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BLACK_ZHU));
      mask=LoadBitmap(hInst,MAKEINTRESOURCE(IDB_mask));
      
     break;
            case WM_LBUTTONUP:
    //看看鼠标是否把旗子拖到了某个格子中
            if(CanGo==1)
    {
                 transfer=0;    
                if(currentx<=400+11 && currenty<=435+11 && move_qizi==1)
     {
     RECT rect_in;          
     POINT current_point[9];
                 current_point[0].x=currentx+6;          //top left
         current_point[0].y=currenty+6;
     current_point[1].x=currentx+25;        //right top
         current_point[1].y=currenty+6;         
     current_point[2].x=currentx+6;        //left bottom
         current_point[2].y=currenty+29;
     current_point[3].x=currentx+24;       //right bottom
         current_point[3].y=currenty+29;
     current_point[4].x=currentx+16;       //center
         current_point[4].y=currenty+17;
     current_point[5].x=currentx+15;      //upper center
         current_point[5].y=currenty+5;
     current_point[6].x=currentx+2;       //left center
         current_point[6].y=currenty+17;
     current_point[7].x=currentx+31;       //right center
         current_point[7].y=currenty+17;
       current_point[8].x=currentx+15;       //center bottom
         current_point[8].y=currenty+28;                                   
      

  10.   

     
     BOOL Judge;//判断旗子的四个角,中心是否在某个格子中                            
     int ii=(currenty+17-11)/43;
     int jj=(currentx+16-11)/44;
                         rect_in.left=44*jj+11+position_tunx[ii][jj];
     rect_in.top=43*ii+11+position_tuny[ii][jj];
     rect_in.right=rect_in.left+31;
     rect_in.bottom=rect_in.top+34;
    Judge=PtInRect(&rect_in,current_point[0])||PtInRect(&rect_in,current_point[1])||PtInRect(&rect_in,current_point[2])||PtInRect(&rect_in,current_point[3])||PtInRect(&rect_in,current_point[4])||PtInRect(&rect_in,current_point[5])||PtInRect(&rect_in,current_point[6])||PtInRect(&rect_in,current_point[7])||PtInRect(&rect_in,current_point[8]) ;
     if(Judge && move_qizi==1)
     {//在某个格子中
                   Location_QiZi[ii][jj]=qi_zi;
       if(ii!=source_posiy  || jj !=source_posix)
          Location_QiZi[source_posiy][source_posix]=-1;
                   RECT rect_inva; 
       rect_inva.left=11+source_posix*44+position_tunx[source_posiy][source_posix];
       rect_inva.top=11+source_posiy*43+position_tuny[source_posiy][source_posix];
       rect_inva.right=rect_inva.left+31;
       rect_inva.bottom=rect_inva.top+34;
      InvalidateRect(hWnd,&rect_inva,TRUE);//落子完毕
      //负值,发送:
      if(ii!=source_posiy  || jj !=source_posix)
      {
      GoTrans[0]=source_posix;
      GoTrans[1]=source_posiy;
      GoTrans[2]=qi_zi;
      GoTrans[3]=jj;
      GoTrans[4]=ii;
                  transfer=1;  
      CanGo=0;
      }
       //SendMessage(hWnd,WM_PAINT,0,0);
       HBITMAP oldbit;
         HDC hdc1;
    HDC ClietDc;    //get client area DC
                ClietDc=GetDC(hWnd);
     hdc1=CreateCompatibleDC(NULL);
          oldbit=(HBITMAP)SelectObject(hdc1,mask);
             StretchBlt(ClietDc,currentx,currenty,31,34,hdc1,0,0,31,34,SRCCOPY);
                    SelectObject(hdc1,qizi[qi_zi]);
    StretchBlt(ClietDc,rect_in.left,rect_in.top,31,34,hdc1,0,0,31,34,SRCCOPY);                        
        SelectObject(hdc1,oldbit);
     DeleteDC(hdc1);
     ReleaseDC(hWnd,ClietDc);
     }
     else
     {
     //remove the “旗子”
              HBITMAP oldbit;
         HDC hdc1;
    HDC ClietDc;    //get client area DC
                ClietDc=GetDC(hWnd);
     hdc1=CreateCompatibleDC(NULL);
          oldbit=(HBITMAP)SelectObject(hdc1,mask);
             StretchBlt(ClietDc,currentx,currenty,31,34,hdc1,0,0,31,34,SRCCOPY);
        SelectObject(hdc1,oldbit);
     DeleteDC(hdc1);
     ReleaseDC(hWnd,ClietDc);
     }
     }
                move_qizi=0;
    qi_zi=-1;
    }
    break;
            case WM_LBUTTONDOWN:
           if(CanGo==1)
    {
                 transfer=0;      
     currentx=GET_X_LPARAM(lParam); 
                 currenty=GET_Y_LPARAM(lParam); 
     old_m_x=currentx;
         old_m_y=currenty;
     //judge is the point OF THE MOUSE in one "ge-zi"
     if(currentx<=400+11 && currenty<=435+11)
     {
     RECT rect_in;          
     POINT current_point;
                 current_point.x=currentx;
         current_point.y=currenty;
                               
     int ii=(currenty-11)/43;
     int jj=(currentx-11)/44;
                         rect_in.left=44*jj+11+position_tunx[ii][jj];
     rect_in.top=43*ii+11+position_tuny[ii][jj];
     rect_in.right=rect_in.left+31;
     rect_in.bottom=rect_in.top+34;
     if(PtInRect(&rect_in,current_point))
                 { //在某个格子中
                 //save the background to the mask;
    source_posix=jj;
    source_posiy=ii;
     if(Location_QiZi[ii][jj]!=-1)
                    {
     qi_zi=Location_QiZi[ii][jj];
        move_qizi=1;       //鼠标是在旗子上
    currentx=rect_in.left;
            currenty=rect_in.top;
                    HDC hdc_mask;
            hdc_mask=CreateCompatibleDC(NULL);
            HBITMAP old;
            HDC ClietDc;    //get client area DC
            ClietDc=GetDC(hWnd);
            old=(HBITMAP)SelectObject(hdc_mask,mask);
                    StretchBlt(hdc_mask,0,0,31,34,ClietDc,currentx,currenty,31,34,SRCCOPY);
                ReleaseDC(hWnd,ClietDc);
               SelectObject(hdc_mask,old);
            DeleteDC(hdc_mask);
     }
                 }
     }
       }     
      break;
      case WM_COMMAND:
    wmId    = LOWORD(wParam); 
    wmEvent = HIWORD(wParam); 
    // Parse the menu selections:
    switch (wmId)
    {
    case IDM_ABOUT:
       DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
       break;
    case IDM_LISTEN:
    HMENU current_menu;
        current_menu=GetMenu(hWnd);
    EnableMenuItem(current_menu,IDM_CONNECT,MF_DISABLED|MF_GRAYED);
    EnableMenuItem(current_menu,IDM_LISTEN,MF_DISABLED|MF_GRAYED);
    CreateThread(NULL,0,(LPTHREAD_START_ROUTINE) ThreadFunc_Lis,(LPVOID)hWnd,0,&NewThreadId1);
    // EnableMenuItem(current_menu,IDM_CONNECT,MF_ENABLED);
    break;
    case IDM_CONNECT:
       DialogBox(hInst, (LPCTSTR)IDD_CONNECT, hWnd, (DLGPROC)ConnectBox);
       
           //MessageBox(NULL,"failure-setItem", "ERROR", MB_OK); 
    break;
    case IDM_EXIT:
       DestroyWindow(hWnd);
       break;
    default:
       return DefWindowProc(hWnd, message, wParam, lParam);
    }
    break;

       case WM_MOUSEMOVE:
       if(CanGo==1)
    {
                 transfer=0;
                     if(wParam==MK_LBUTTON && move_qizi==1)
     {  
                             //load bitmap resource
        
    // if(che==NULL)
                         HBITMAP oldbit;
         HDC hdc1;
     hdc1=CreateCompatibleDC(NULL);
          oldbit=(HBITMAP)SelectObject(hdc1,mask);
     HDC ClietDc;    //get client area DC
     ClietDc=GetDC(hWnd);
     int currentx1=GET_X_LPARAM(lParam); 
                         int currenty1=GET_Y_LPARAM(lParam); 
     move_px=currentx1-old_m_x;           
      

  11.   

    move_py=currenty1-old_m_y;
     //restore the old background in the place passed
         StretchBlt(ClietDc,currentx,currenty,31,34,hdc1,0,0,31,34,SRCCOPY);
                     
       currentx+=move_px; 
                           currenty+=move_py;
       //save the background of the place will draw
       StretchBlt(hdc1,0,0,31,34,ClietDc,currentx,currenty,31,34,SRCCOPY);            
       SelectObject(hdc1,qizi[qi_zi]);
     StretchBlt(ClietDc,currentx,currenty,31,34,hdc1,0,0,31,34,MERGECOPY);
     ReleaseDC(hWnd,ClietDc);
       SelectObject(hdc1,oldbit);
    DeleteDC(hdc1);
    old_m_x=currentx1;
                old_m_y=currenty1;
     }
       }
    break;

    case WM_PAINT:

    hdc = BeginPaint(hWnd, &ps);
     //TODO: Add any drawing code here...
            // transfer=0;  //Can't transfer
               HDC hdc1;
       HBITMAP oldbit;
       hdc1=CreateCompatibleDC(NULL);
       HDC ClietDc_paint; 
       ClietDc_paint=GetDC(hWnd);
    for(i=0;i<10;i++)
      for(j=0;j<9;j++)        //display the "qi_zi" in the "pan"
      {
                       if(Location_QiZi[i][j]!=-1)
       {
     int qizi_number=Location_QiZi[i][j];
          oldbit=(HBITMAP)SelectObject(hdc1,qizi[qizi_number]);
        //get client area DC
     int pos_x=11+j*44+position_tunx[i][j]; 
                         int pos_y=11+i*43+position_tuny[i][j]; 
     //when you use this sentence twice,the bitmap you draw disappeared
         StretchBlt(ClietDc_paint,pos_x,pos_y,31,34,hdc1,0,0,31,34,SRCPAINT);
     SelectObject(hdc1,oldbit);
       }
      }
           ReleaseDC(hWnd,ClietDc_paint);
      DeleteDC(hdc1);  
    EndPaint(hWnd, &ps);

    break;

    case WM_DESTROY:
    DeleteObject(qizi[0]);
    DeleteObject(qizi[1]);
    DeleteObject(qizi[2]);
    DeleteObject(qizi[3]);
    DeleteObject(qizi[4]);
    DeleteObject(qizi[5]);
    DeleteObject(qizi[6]);
    DeleteObject(qizi[7]);
    DeleteObject(qizi[8]);
    DeleteObject(qizi[9]);
    DeleteObject(qizi[10]);
    DeleteObject(qizi[11]);
    DeleteObject(qizi[12]);
    DeleteObject(qizi[13]);
    DeleteObject(mask);
    PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hWnd, message, wParam, lParam);
       }
       return 0;
    }
      

  12.   

    不能运行,出了点错。
            case WM_LBUTTONUP:
    //看看鼠标是否把旗子拖到了某个格子中
            if(CanGo==1)
    {
                 transfer=0;    
                if(currentx<=400+11 && currenty<=435+11 && move_qizi==1)
     {
     RECT rect_in;          
     POINT current_point [9];"["语法错误,错误的数组声明符。若要声明托管数组,秩说明符应位于变量标识符之前。
      

  13.   

    留个Email 发给你 ,这个是网络版的,代码太长 没帖完
      

  14.   

    www.chesshome.net/bak/qp.exe我从新修改了一部分,添加了吃子和评断红还是黑走棋的功能。还是不能解决控件的数组问题,所以程序很罗嗦。
    请高手指点:)