好文档 - 专业文书写作范文服务资料分享网站

中国象棋源代码-C语言知识学习小程序

天下 分享 时间: 加入收藏 我要投稿 点赞

* *

board[3][0]=BLACK_BIN; board[3][2]=BLACK_BIN; board[3][4]=BLACK_BIN; board[3][6]=BLACK_BIN; board[3][8]=BLACK_BIN;

board[9][0]=RED_JU; board[9][1]=RED_MA; board[9][2]=RED_XIANG; board[9][3]=RED_SHI; board[9][4]=RED_JIANG; board[9][5]=RED_SHI; board[9][6]=RED_XIANG; board[9][7]=RED_MA; board[9][8]=RED_JU; board[7][1]=RED_PAO; board[7][7]=RED_PAO; board[6][0]=RED_BIN; board[6][2]=RED_BIN; board[6][4]=RED_BIN; board[6][6]=RED_BIN; board[6][8]=RED_BIN;

* *

}

initdrawchess() { int i,j;;

for(i=0;i<10;i++) for(j=0;j<9;j++) {

if(board[i][j])

drawbmp(position[i][j].x,position[i][j].y,chessfile[board[i][j]]); } }

drawcursor(struct pos p) {

int i,j,n,m,x,y; long thisposition; x=position[p.x][p.y].x+20; y=position[p.x][p.y].y+25; for(j=13-1+x,m=13;j>=x;j--,m--) {

for(i=y,n=0;i<13+y;i++,n++) {

* *

thisposition=j*640l+i; /*计算要显示点的显存位置*/ page_new=thisposition/65536; /*计算显示页*/

if(page_new!=page_old) /*当显示页不同时更换页面,提高一定的输出速度*/ {selectpage(page_new);page_old=page_new;} if(cursor[m][n]!=1) if(cursor[m][n]==0)

pokeb(0xa000,thispositione536,0); else

if(turn==RED)

pokeb(0xa000,thispositione536,153); else

pokeb(0xa000,thispositione536,255); } } }

drawselecursor(struct pos p) {

int i,j,n,m,x,y; long thisposition; x=position[p.x][p.y].x+20; y=position[p.x][p.y].y+25;

* *

for(j=13-1+x,m=13;j>=x;j--,m--) {

for(i=y,n=0;i<13+y;i++,n++) {

thisposition=j*640l+i; /*计算要显示点的显存位置*/ page_new=thisposition/65536; /*计算显示页*/

if(page_new!=page_old) /*当显示页不同时更换页面,提高一定的输出速度*/ {selectpage(page_new);page_old=page_new;} if(cursor[m][n]!=1)

pokeb(0xa000,thispositione536,0); } } }

/*----------------------------------------------------*/ int getkey() { int press;

while(bioskey(1) == 0); press=bioskey(0); press=press&0xff00; return(press);

* *

}

/*--------------------红方操作--------------------*/ int redcanselect() { int x,y; x=redcurpos.x; y=redcurpos.y;

if(board[x][y]>=RED_JU&&board[x][y]<=RED_BIN) return 1; else return 0; }

int redcanmove() {

int i,j,min,max,oldx,oldy,x,y; oldx=redoldpos.x; oldy=redoldpos.y; x=redcurpos.x; y=redcurpos.y;

/*case1 目标位置是否是自己人*/

if(board[x][y]>=RED_JU&&board[x][y]<=RED_BIN) return 0;

中国象棋源代码-C语言知识学习小程序

**board[3][0]=BLACK_BIN;board[3][2]=BLACK_BIN;board[3][4]=BLACK_BIN;board[3][6]=BLACK_BIN;board[3][8]=BLACK_BIN;board[9][0]=RED_JU;board[9][1]=RED_MA;board[9][2]=RED_XIANG;
推荐度:
点击下载文档文档为doc格式
4088b0ygob0wk4t3v4f03ibqw7s1q700th2
领取福利

微信扫码领取福利

微信扫码分享