资源描述:
《黑白棋游戏课程设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、黑白棋程序源代码:#include"graphics.h"#include"stdio.h"#include"stdlib.h"#include"conio.h"#include"dos.h"#include"math.h"#defineLEFT0x4b00#defineRIGHT0x4d00#defineDOWN0x5000#defineUP0x4800#defineESC0x011b#defineENTER0x1c0d#defineF10x3b00#defineF20x3c00#defineF
2、30x3d00#defineF40x3e00inta[8][8]={0},key,score1,score2;/*具体分数以及按键与存放棋子的变量*/charplayone[3],playtwo[3];/*两个人的得分转换成字符串输出*/voidplaytoplay(void);/*人人对战函数*/voidDrawQp1(void);voidDrawQp2(void);voidDrawQp(void);/*画棋盘函数*/voidSetPlayColor(intx);/*设置棋子第一次的颜色*/vo
3、idMoveColor(intx,inty);/*恢复原来棋盘状态*/intQpChange(intx,inty,intz);/*判断棋盘的变化*/voidDoScore(void);/*处理分数*/voidPrintScore(intn);/*输出成绩*/19intk=1;inty=1;/******主函数*********/voidmain(void){intgd=0,gr,i,j;initgraph(&gd,&gr,"D:\TCPP30E\BGI");/*初始化图形系统*/while(y
4、){for(i=0;i<8;i++)for(j=0;j<8;j++)a[i][j]=0;DrawQp1();if(k==1)break;if(k==0){DrawQp();/*画棋盘*/playtoplay();/*人人对战*/}}closegraph();}voidDrawQp()/*画棋盘*/{inti,j;score1=score2=0;/*棋手一开始得分都为0*/setbkcolor(BLUE);setcolor(4);setlinestyle(0,0,3);outtextxy(200,5
5、0,"*HELP(F1)");outtextxy(200,70,"*PAUSE(F2)");19outtextxy(200,90,"*MUSIC(F4)");setcolor(4);setlinestyle(SOLID_LINE,0,3);for(i=100;i<=420;i+=40){line(100,i,420,i);/*画水平线*/line(i,100,i,420);/*画垂直线*/}setcolor(0);/*取消圆周围的一圈东西*/setfillstyle(SOLID_FILL,15);
6、/*白色实体填充模式*/fillellipse(20,30,15,15);/*在显示得分的位置画棋*/setfillstyle(SOLID_FILL,8);/*黑色实体填充模式*/fillellipse(20,80,15,15);a[3][3]=a[4][4]=1;/*初始两个黑棋*/a[3][4]=a[4][3]=2;/*初始两个白棋*/setfillstyle(SOLID_FILL,WHITE);fillellipse(120+3*40,120+3*40,15,15);fillellipse(
7、120+4*40,120+4*40,15,15);setfillstyle(SOLID_FILL,8);fillellipse(120+3*40,120+4*40,15,15);fillellipse(120+4*40,120+3*40,15,15);score1=score2=2;/*有棋后改变分数*/DoScore();/*输出开始分数*/}voidplaytoplay()/*人人对战*/{intx,y,t=1,i,j,m,u=0,now,k,d,d1,r=1,cc=0;chartimeone
8、[10];structtimecurtime;unsignedsing[]={442,100,334,100,320,100,422,100,442,100,334,100,320,100,422,100,19222,100,239,100,232,150,342,100,239,100,232,150,342,75,345,75,342,75,349,75,230,100,162,100,342,75,345,75,352,75,349,75,230,100,162,1