中国象棋游戏源代码

上传人:博****1 文档编号:491947370 上传时间:2023-08-19 格式:DOC 页数:22 大小:58KB
返回 下载 相关 举报
中国象棋游戏源代码_第1页
第1页 / 共22页
中国象棋游戏源代码_第2页
第2页 / 共22页
中国象棋游戏源代码_第3页
第3页 / 共22页
中国象棋游戏源代码_第4页
第4页 / 共22页
中国象棋游戏源代码_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《中国象棋游戏源代码》由会员分享,可在线阅读,更多相关《中国象棋游戏源代码(22页珍藏版)》请在金锄头文库上搜索。

1、-using System;using System.Collections.Generic;using System.ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Te*t;using System.Windows.Forms;namespace 象棋enumplayer blank, red, blue, ;enumchesstype blank, jiang, che, ma, pao, *iang, zu, shi ;structchess public player

2、side;public chesstype type; ;/下载于structblock public PictureBo* container;public chess item; ;publicpartialclassForm1 : Form public Form1() Initializeponent(); picturebo*list = newList(81); Matri*=new block10;int i,j;for (i = 0; i 10;i+ ) Matri*i = new block9; for(i=0;i10;i+) for(j=0;j9;j+) Control c

3、ol = this.Controls.Find(pictureBo* + (i*9+j+1), false); Matri*ij.container=col0 as PictureBo*; Matri*ij.container.Location = new Point(60 * j, 60 * i); redcoll = new collecter(); bluecool = new collecter();for (i = 91; i 107;i+ ) Control col = this.Controls.Find(pictureBo* + i, false); bluecool.add(

4、col0 as PictureBo*); for (i = 107; i 123;i+ ) Control col = this.Controls.Find(pictureBo* + i, false); redcoll.add(col0 as PictureBo*); resetground(); List picturebo*list; block Matri*; collecter redcoll; collecter bluecool;int chozen*;int chozenY; player currentside;bool beenchozen;bool clickswitch

5、;privatevoid click1(object sender, EventArgs e) if(!clickswitch) resetground();return; string name = (sender as PictureBo*).Name;string number = name.Substring(10);int inde* = Convert.ToInt32(number);int i,j;bool flag = false; i=(inde*-1)/9; j=(inde*-1)%9;/下载于if (beenchozen) Matri*chozen*chozenY.con

6、tainer.BorderStyle = BorderStyle.None; Matri*chozen*chozenY.container.BackColor = Color.Transparent; beenchozen = false;if(Matri*chozen*chozenY.item.side=Matri*ij.item.side) return; if (Matri*chozen*chozenY.item.side != player.blank) if(Matri*ij.item.type= chesstype.jiang) flag=true; if(!movechess(i

7、, j) return; if(flag) if (currentside = player.red) MessageBo*.Show(红方胜利!点击任意处重新开局); else MessageBo*.Show(蓝方胜利!点击任意处重新开局); clickswitch = false; if (currentside = player.red) currentside = player.blue; label1.Te*t = 蓝方; label1.ForeColor = Color.Blue; else currentside = player.red; label1.Te*t = 红方; l

8、abel1.ForeColor = Color.Red; elseif(Matri*ij.item.side= currentside) Matri*ij.container.BorderStyle = BorderStyle.Fi*edSingle; Matri*ij.container.BackColor = Color.Brown; chozen* = i; chozenY = j; beenchozen = true; privatevoid resetground() int i, j;for (i = 0; i 10;i+ ) for(j=0;j9;j+) Matri*ij.con

9、tainer.Image = null; Matri*ij.item.side = player.blank; Matri*ij.item.type = chesstype.blank; beenchozen = false; clickswitch = true; currentside = player.red; label1.Te*t = 红方; label1.ForeColor = Color.Red; redcoll.clear(); bluecool.clear(); Matri*00.container.Image = global:象棋.Properties.Resources.蓝车; Matri*01.container.Image = global:象棋.Properties.Resources.蓝马; Matri*02.container.Image = global:象棋.Properties.Resources.蓝象; Matri*03.container.Image = global:象棋.Properties.Resourc

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号