• / 21
  • 下载费用:10 金币  

中国象棋游戏源代码.doc

关 键 词:
中国象棋游戏源代码.doc
资源描述:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace 象棋{enum player{blank,red,blue, };enum chesstype{blank,jiang,che,ma,pao,xiang,zu,shi };struct chess{public player side;public chesstype type;};//下载于www.mycodes.netstruct block{public PictureBox container;public chess item;};public partial class Form1 : Form{public Form1(){InitializeComponent();pictureboxlist = new List(81);Matrix=new block[10][];int i,j;for (i = 0; i pictureboxlist;block[][] Matrix;collecter redcoll;collecter bluecool;int chozenX;int chozenY;player currentside;bool beenchozen;bool clickswitch;private void click1(object sender, EventArgs e){if(!clickswitch){resetground();return;}string name = (sender as PictureBox).Name;string number = name.Substring(10);int index = Convert.ToInt32(number);int i,j;bool flag = false;i=(index-1)/9;j=(index-1)%9;//下载于www.mycodes.netif (beenchozen){Matrix[chozenX][chozenY].container.BorderStyle = BorderStyle.None;Matrix[chozenX][chozenY].container.BackColor = Color.Transparent;beenchozen = false;if(Matrix[chozenX][chozenY].item.side==Matrix[i][j].item.side){return;}if (Matrix[chozenX][chozenY].item.side != player.blank){if(Matrix[i][j].item.type== chesstype.jiang){flag=true;}if(!movechess(i, j)){return;}if(flag){if (currentside == player.red){MessageBox.Show(“红方胜利!点击任意处重新开局“);}else{MessageBox.Show(“蓝方胜利!点击任意处重新开局“);}clickswitch = false;}}if (currentside == player.red){currentside = player.blue;label1.Text = “蓝方“;label1.ForeColor = Color.Blue;}else{currentside = player.red;label1.Text = “红方“;label1.ForeColor = Color.Red;}}else if(Matrix[i][j].item.side== currentside){Matrix[i][j].container.BorderStyle = BorderStyle.FixedSingle;Matrix[i][j].container.BackColor = Color.Brown;chozenX = i;chozenY = j;beenchozen = true; }}private void resetground(){int i, j;for (i = 0; i Y ? chozenY : Y;for(k=i+1;k X ? chozenX : X;for (k = i + 1; k X ? choze
展开阅读全文
  微传网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
0条评论

还可以输入200字符

暂无评论,赶快抢占沙发吧。

关于本文
本文标题:中国象棋游戏源代码.doc
链接地址:https://www.weizhuannet.com/p-9832029.html
微传网是一个办公文档、学习资料下载的在线文档分享平台!

微传网博客

网站资源均来自网络,如有侵权,请联系客服删除!

 网站客服QQ:80879498  会员QQ群:727456886

copyright@ 2018-2028 微传网络工作室版权所有

     经营许可证编号:冀ICP备18006529号-1 ,公安局备案号:13028102000124

收起
展开