基本信息
源码名称:C#版中国象棋游戏源代码 完整实例下载
源码大小:1.90M
文件格式:.rar
开发语言:C#
更新时间:2013-01-09
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
C# 中国象棋游戏,仅供学习交流使用,请勿用于商业用途
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"; }