在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#游戏开发 → C#版中国象棋游戏源代码 完整实例下载

C#版中国象棋游戏源代码 完整实例下载

C#游戏开发

下载此实例
  • 开发语言:C#
  • 实例大小:1.90M
  • 下载次数:101
  • 浏览次数:1354
  • 发布时间:2013-01-09
  • 实例类别:C#游戏开发
  • 发 布 人:chaogu
  • 文件格式:.rar
  • 所需积分:2
 相关标签: 游戏 象棋

实例介绍

【实例简介】

C# 中国象棋游戏,仅供学习交流使用,请勿用于商业用途
【实例截图】


【核心代码】

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
public void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {//方法功能:画旗盘
            Graphics g=e.Graphics;
            int startLeft,startTop;
            if(this.displaySize==15)
            {
                startLeft=48;startTop=32;//左上角点  800*600
            }
            else
            {
                startLeft=60;startTop=35;//左上角点 1024*768
            }
            int Index=0; //记录点的索引          
            width=panel1.Width;
            height=panel1.Height;
            width=width/9;  height=height/10;  //确定每个方格的宽和高
            width-=4; height-=3;           
            Pen pen1=new Pen(Color.DarkBlue,3);
            Pen pen2=new Pen(Color.Black,2);
            int startX=startLeft,startY=startTop;
            for(int i=0;i<2;i  )
            {
                for(int j=0;j<4;j  )
                {
                    for(int k=0;k<8;k  )
                    {//以下括号内所有语句为画一行方格                     
                        g.DrawRectangle(pen1,startX,startY,width,height);                      
                        point[Index]=new Point(startX,startY);
                        Index  ;
                        startX =width;
                    }                  
                    point[Index]=new Point(point[Index-1].X width,point[Index-1].Y);
                    Index  ;
                     
                    startY =height;  //往下移动动坐标,画下一行方格
                    startX=startLeft;
                }              
                //记录上面忘下的九个点
                for(int ii=Index-9,j=0;j<9;ii  ,j  )
                {                  
                    point[Index]=new Point(point[ii].X,point[ii].Y height);
                    Index  ;
                }
                int paoX,paoY;  //声明画炮点的漂亮图案坐标
                int x,y,temp;   //画将/帅的辅助变量
                if(i==0)
                {
                    paoX=startLeft width;
                    paoY=startTop 2*height;                        
                    x=startLeft 3*width;
                    y=startTop 2*height;
                    temp=0;                
                }
                else
                {
                    paoX=startLeft width;
                    paoY=startTop 7*height height/2;                   
                    x=startLeft 3*width;
                    y=startLeft 9*height 2;
                    temp=7*height height/2 2;
                }              
                 
                //画横向的两个炮的漂亮图案
                DrawAllSitePoint(sender,e,paoX,paoY,width);    
                paoX=startLeft 7*width;
                DrawAllSitePoint(sender,e,paoX,paoY,width);
                 
                //画将/帅家                
                float[] dashValues={3,1,3,1,3,1};
                pen2.DashPattern=dashValues;
                g.DrawLine(pen2,x,startTop temp,x 2*width,y);
                x=startLeft 5*width;
                g.DrawLine(pen2,x,startTop temp,x-2*width,y);
 
                //画中间的河            
                Font font=new Font("华文行楷", 42F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));                             
                Brush brush=new SolidBrush(Color.Purple);
                PointF tempPoint=new PointF(startLeft,startTop 4*height 10);
                string tempStr;
                if(this.displaySize==15)
                {
                    tempStr="  楚   河       汉   界     "; /************适于800*600 分辩率**************/
                }
                else
                {
                    tempStr="      楚    河           汉    界     ";   /************适于1024*768分辩率**************/
                    tempPoint.Y=tempPoint.Y 8;
                }
                g.DrawString(tempStr,font,brush,tempPoint);
 
                startX=startLeft;
                startY=startTop 5*height height/2;  //移动坐标,画下方旗盘           
            }          
            for(int i=29;i<=33;i =2)
                DrawAllSitePoint(sender,e,this.point[i].X,this.point[i].Y,width);
            for(int i=56;i<=60;i =2)
                DrawAllSitePoint(sender,e,this.point[i].X,this.point[i].Y,width);
            this.DrawLeftHalfSitePoint(sender,e,this.point[27].X,this.point[27].Y,width);
            this.DrawRightHalfSitePoint(sender,e,this.point[35].X,this.point[35].Y,width);
            this.DrawLeftHalfSitePoint(sender,e,this.point[54].X,this.point[54].Y,width);
            this.DrawRightHalfSitePoint(sender,e,this.point[62].X,this.point[62].Y,width);
 
            pen1.Dispose();
            g.Dispose();   
            MyInitializeComponent();
             
        }
 
        private void Form1_Load(object sender, System.EventArgs e)
        {
            this.panel1.Cursor = new Cursor(@"..\..\cursor\greenflag.cur");
            this.label7.Cursor = new Cursor(@"..\..\cursor\greenflag.cur");
            this.label8.Cursor = new Cursor(@"..\..\cursor\greenflag.cur");
            this.pictureBox1.Cursor=new Cursor(@"..\..\cursor\heart.cur");
            this.pictureBox3.Cursor=new Cursor(@"..\..\cursor\heart.cur");
            this.pictureBox4.Cursor=new Cursor(@"..\..\cursor\heart.cur");
            this.pictureBox5.Cursor=new Cursor(@"..\..\cursor\heart.cur"); 
            MyInitializeComponent();
 
            //布置
            this.panel1.Width=this.Width-this.panel2.Width;
            this.panel1.Height=this.Height-this.statusBar1.Height-52;
            this.panel2.Left=this.Left this.panel1.Width;
            this.panel2.Height=this.panel1.Height;
            this.panel2.Width=this.Width-this.panel1.Width;
         
            login=new Form3();
            /*if(login.ShowDialog()==DialogResult.OK)
            {
                label1.Text=login.textBox1.Text.ToString() " VS " login.textBox2.Text.ToString();                              
                if(login.radioButton1.Checked)
                    this.computerAuto=true;
                login.Close();
            }
            else
                login.Close(); 
         
            playName[1]="女孩"; playName[2]="男孩";
            playName[3]=login.textBox1.Text.ToString();
            playName[4]=login.textBox2.Text.ToString();                 */
        }
 
        private void panel1_Resize(object sender, System.EventArgs e)
        {          
            MyInitializeComponent();
        }
 
        private void label1_DoubleClick(object sender, System.EventArgs e)
        {          
            string tempStr;
            tempStr=playName[1];
            playName[1]=playName[3];
            playName[3]=tempStr;
            tempStr=playName[2];
            playName[2]=playName[4];
            playName[4]=tempStr;
 
            label1.Text=playName[3];
            label1.Text =" VS " playName[4];
            login.textBox1.Text=playName[3];
            login.textBox2.Text=playName[4];
             
            //this.blueZhanJi=0;
            //this.redZhanJi=0;
            //this.statusBarPanel2.Text="红方: 0";
            //this.statusBarPanel3.Text="蓝方: 0";
        }

标签: 游戏 象棋

实例下载地址

C#版中国象棋游戏源代码 完整实例下载

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

第 1 楼 rqpanny 发表于: 2023-04-04 16:08 54
功能不完整,象棋规则有误。

支持(0) 盖楼(回复)

发表评论

(您的评论需要经过审核才能显示)

查看所有1条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警