中国象棋游戏源代码Word格式.docx

上传人:b****3 文档编号:8205490 上传时间:2023-05-10 格式:DOCX 页数:18 大小:17.16KB
下载 相关 举报
中国象棋游戏源代码Word格式.docx_第1页
第1页 / 共18页
中国象棋游戏源代码Word格式.docx_第2页
第2页 / 共18页
中国象棋游戏源代码Word格式.docx_第3页
第3页 / 共18页
中国象棋游戏源代码Word格式.docx_第4页
第4页 / 共18页
中国象棋游戏源代码Word格式.docx_第5页
第5页 / 共18页
中国象棋游戏源代码Word格式.docx_第6页
第6页 / 共18页
中国象棋游戏源代码Word格式.docx_第7页
第7页 / 共18页
中国象棋游戏源代码Word格式.docx_第8页
第8页 / 共18页
中国象棋游戏源代码Word格式.docx_第9页
第9页 / 共18页
中国象棋游戏源代码Word格式.docx_第10页
第10页 / 共18页
中国象棋游戏源代码Word格式.docx_第11页
第11页 / 共18页
中国象棋游戏源代码Word格式.docx_第12页
第12页 / 共18页
中国象棋游戏源代码Word格式.docx_第13页
第13页 / 共18页
中国象棋游戏源代码Word格式.docx_第14页
第14页 / 共18页
中国象棋游戏源代码Word格式.docx_第15页
第15页 / 共18页
中国象棋游戏源代码Word格式.docx_第16页
第16页 / 共18页
中国象棋游戏源代码Word格式.docx_第17页
第17页 / 共18页
中国象棋游戏源代码Word格式.docx_第18页
第18页 / 共18页
亲,该文档总共18页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

中国象棋游戏源代码Word格式.docx

《中国象棋游戏源代码Word格式.docx》由会员分享,可在线阅读,更多相关《中国象棋游戏源代码Word格式.docx(18页珍藏版)》请在冰点文库上搜索。

中国象棋游戏源代码Word格式.docx

structblock

publicPictureBoxcontainer;

publicchessitem;

publicpartialclassForm1:

Form

publicForm1()

InitializeComponent();

pictureboxlist=newList<

PictureBox>

(81);

Matrix=newblock[10][];

inti,j;

for(i=0;

i<

10;

i++)

Matrix[i]=newblock[9];

}

for(i=0;

i<

10;

i++)

for(j=0;

j<

9;

j++)

Control[]col=this.Controls.Find("

pictureBox"

+(i*9+j+1),false);

Matrix[i][j].container=col[0]asPictureBox;

Matrix[i][j].container.Location=newPoint(60*j,60*i);

}

redcoll=newcollecter();

bluecool=newcollecter();

for(i=91;

107;

+i,false);

bluecool.add(col[0]asPictureBox);

for(i=107;

123;

redcoll.add(col[0]asPictureBox);

resetground();

List<

pictureboxlist;

block[][]Matrix;

collecterredcoll;

collecterbluecool;

intchozenX;

intchozenY;

playercurrentside;

boolbeenchozen;

boolclickswitch;

privatevoidclick1(objectsender,EventArgse)

if(!

clickswitch)

return;

stringname=(senderasPictureBox).Name;

stringnumber=name.Substring(10);

intindex=Convert.ToInt32(number);

boolflag=false;

i=(index-1)/9;

j=(index-1)%9;

if(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)

if(Matrix[chozenX][chozenY].item.side!

=player.blank)

if(Matrix[i][j].item.type==chesstype.jiang)

flag=true;

movechess(i,j))

if(flag)

if(currentside==player.red)

MessageBox.Show("

红方胜利!

点击任意处重新开局"

);

else

蓝方胜利!

clickswitch=false;

currentside=player.blue;

label1.Text="

蓝方"

;

label1.ForeColor=Color.Blue;

currentside=player.red;

红方"

label1.ForeColor=Color.Red;

elseif(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;

privatevoidresetground()

inti,j;

Matrix[i][j].container.Image=null;

Matrix[i][j].item.side=player.blank;

Matrix[i][j].item.type=chesstype.blank;

clickswitch=true;

redcoll.clear();

bluecool.clear();

Matrix[0][0].container.Image=global:

:

象棋.Properties.Resources.蓝车;

Matrix[0][1].container.Image=global:

象棋.Properties.Resources.蓝马;

Matrix[0][2].container.Image=global:

象棋.Properties.Resources.蓝象;

Matrix[0][3].container.Image=global:

象棋.Properties.Resources.蓝士;

Matrix[0][4].container.Image=global:

象棋.Properties.Resources.蓝将;

Matrix[0][5].container.Image=global:

Matrix[0][6].container.Image=global:

Matrix[0][7].container.Image=global:

Matrix[0][8].container.Image=global:

Matrix[2][1].container.Image=global:

象棋.Properties.Resources.蓝炮;

Matrix[2][7].container.Image=global:

Matrix[3][0].container.Image=global:

象棋.Properties.Resources.蓝卒;

Matrix[3][2].container.Image=global:

Matrix[3][4].container.Image=global:

Matrix[3][6].container.Image=global:

Matrix[3][8].container.Image=global:

Matrix[6][0].container.Image=global:

象棋.Properties.Resources.红卒;

Matrix[6][2].container.Image=global:

Matrix[6][4].container.Image=global:

Matrix[6][6].container.Image=global:

Matrix[6][8].container.Image=global:

Matrix[7][1].container.Image=global:

象棋.Properties.Resources.红炮;

Matrix[7][7].container.Image=global:

Matrix[9][0].container.Image=global:

象棋.Properties.Resources.红车;

Matrix[9][1].container.Image=global:

象棋.Properties.Resources.红马;

Matrix[9][2].container.Image=global:

象棋.Properties.Resources.红象;

Matrix[9][3].container.Image=global:

象棋.Properties.Resources.红士;

Matrix[9][4].container.Image=global:

象棋.Properties.Resources.红将;

Matrix[9][5].container.Image=global:

Matrix[9][6].container.Image=global:

Matrix[9][7].container.Image=global:

Matrix[9][8].container.Image=global:

Matrix[0][0].item.side=player.blue;

Matrix[0][1].item.side=player.blue;

Matrix[0][2].item.side=player.blue;

Matrix[0][3].item.side=player.blue;

Matrix[0][4].item.side=player.blue;

Matrix[0][5].item.side=player.blue;

Matrix[0][6].item.side=player.blue;

Matrix[0][7].item.side=player.blue;

Matrix[0][8].item.side=player.blue;

Matrix[2][1].item.side=player.blue;

Matrix[2][7].item.side=player.blue;

Matrix[3][0].item.side=player.blue;

Matrix[3][2].item.side=player.blue;

Matrix[3][4].item.side=player.blue;

Matrix[3][6].item.side=player.blue;

Matrix[3][8].item.side=player.blue;

Matrix[6][0].item.side=player.red;

Matrix[6][2].item.side=player.red;

Matrix[6][4].item.side=player.red;

Matrix[6][6].item.side=player.red;

Matrix[6][8].item.side=player.red;

Matrix[7][1].item.side=player.red;

Matrix[7][7].item.side=player.red;

Matrix[9][0].item.side=player.red;

Matrix[9][1].item.side=player.red;

Matrix[9][2].item.side=player.red;

Matrix[9][3].item.side=player.red;

Matrix[9][4].item.side=player.red;

Matrix[9][5].item.side=player.red;

Matrix[9][6].item.side=player.red;

Matrix[9][7].item.side=player.red;

Matrix[9][8].item.side=player.red;

Matrix[0][0].item.type=chesstype.che;

Matrix[0][1].item.type=chesstype.ma;

Matrix[0][2].item.type=chesstype.xiang;

Matrix[0][3].item.type=chesstype.shi;

Matrix[0][4].item.type=chesstype.jiang;

Matrix[0][5].item.type=chesstype.shi;

Matrix[0][6].item.type=chesstype.xiang;

Matrix[0][7].item.type=chesstype.ma;

Matrix[0][8].item.type=chesstype.che;

Matrix[2][1].item.type=chesstype.pao;

Matrix[2][7].item.type=chesstype.pao;

Matrix[3][0].item.type=chesstype.zu;

Matrix[3][2].item.type=chesstype.zu;

Matrix[3][4].item.type=chesstype.zu;

Matrix[3][6].item.type=chesstype.zu;

Matrix[3][8].item.type=chesstype.zu;

Matrix[6][0].item.type=chesstype.zu;

Matrix[6][2].item.type=chesstype.zu;

Matrix[6][4].item.type=chesstype.zu;

Matrix[6][6].item.type=chesstype.zu;

Matrix[6][8].item.type=chesstype.zu;

Matrix[7][1].item.type=chesstype.pao;

Matrix[7][7].item.type=chesstype.pao;

Matrix[9][0].item.type=chesstype.che;

Matrix[9][1].item.type=chesstype.ma;

Matrix[9][2].item.type=chesstype.xiang;

Matrix[9][3].item.type=chesstype.shi;

Matrix[9][4].item.type=chesstype.jiang;

Matrix[9][5].item.type=chesstype.shi;

Matrix[9][6].item.type=chesstype.xiang;

Matrix[9][7].item.type=chesstype.ma;

Matrix[9][8].item.type=chesstype.che;

privateboolmovechess(intX,intY)

inti,j,k,n=0;

switch(Matrix[chozenX][chozenY].item.type)

casechesstype.che:

if(chozenX==X)

i=chozenY<

Y?

chozenY:

Y;

j=chozenY>

for(k=i+1;

k<

j;

k++)

if(Matrix[X][k].item.side!

returnfalse;

if(chozenY==Y)

i=chozenX<

X?

chozenX:

X;

j=chozenX>

for(k=i+1;

k<

j;

k++)

if(Matrix[k][Y].item.side!

setmove(X,Y);

returntrue;

casechesstype.jiang:

if(Matrix[X][Y].item.type==chesstype.jiang&

&

chozenY==Y)

if(Matrix[chozenX][chozenY].item.side==player.blue)

{

if(Y<

3||Y>

5||X>

2)

5||X<

7)

if((chozenX-X)*(chozenX-X)+(chozenY-Y)*(chozenY-Y)!

=1)

casechesstype.ma:

if(Math.Abs(chozenX-X)==1&

Math.Abs(chozenY-Y)==2)

if(Matrix[chozenX][chozenY+(Y-chozenY)/Math.Abs(Y-chozenY)].item.side!

elseif(Math.Abs(chozenX-X)==2&

Math.Abs(chozenY-Y)==1)

if(Matrix[chozenX+(X-chozenX)/Math.Abs(X-chozenX)][chozenY].item.side!

casechesstype.pao:

n=0;

n++;

if(n>

1

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 党团工作 > 入党转正申请

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2