/*定义全局变量*/
int status[N][N]; /*定义的数组,保存状态*/
int step_x,step_y;/*行走的坐标*/
int key ; /*获取按下的键盘的键*/
int flag; /*玩家标志*/
/*自定义函数原型*/
void DrawBoard();
void DrawCircle(int x,int y,int color);
void Alternation();
void JudgePlayer(int x,int y);
void Done();
int ResultCheck(int x,int y);
void WelcomeInfo();
void ShowMessage();
/*定义函数*/
/*显示欢迎信息函数*/
void WelcomeInfo()
{
char ch ;
/*移动光标到指定位置*/
gotoxy(12,4);
/*显示欢迎信息*/
printf("Welcome you to gobang word!");
gotoxy(12,6);
printf("1.You can use the up,down,left and right key to move the chessman,");
gotoxy(12,8);
printf(" and you can press Space key to enter after you move it !");
gotoxy(12,10);
printf("2.You can use Esc key to exit the game too !");
gotoxy(12,12);
printf("3.Don not move the pieces out of the chessboard !");
gotoxy(12,14);
printf("DO you want to continue ?(Y/N)");
ch=getchar();
/*判断程序是否要继续进行*/
if(ch=='n'||ch=='N')
/*如果不继续进行,则推出程序*/
exit(0);
}
/*画棋盘函数*/
void DrawBoard()
{
int x1,x2;
int y1,y2;
/*设置背景色*/
setbkcolor(2);
/*设置线条颜色*/
setcolor(1);
/*设置线条风格、宽度*/
setlinestyle(DOTTED_LINE,1,1);
/*按照预设的偏移量开始画棋盘*/
for(x1=1,y1=1,y2=18;x1<=18;x1++)
line((x1+OFFSET_x)*OFFSET,(y1+OFFSET_y)*OFFSET,(x1+OFFSET_x)*OFFSET,(y2+OFFSET_y)*OFFSET);
for(x1=1,y1=1,x2=18;y1<=18;y1++)
line((x1+OFFSET_x)*OFFSET,(y1+OFFSET_y)*OFFSET,(x2+OFFSET_x)*OFFSET,(y1+OFFSET_y)*OFFSET);
/*将各个点的状态设置为0*/
for(x1=1;x1<=18;x1++)
for(y1=1;y1<=18;y1++)
status[x1][y1]=0;
/*显示帮助信息*/论文网http://www.youerw.com/
setcolor(14);
/*设置字体、大小*/
settextstyle(1,0,1);
outtextxy((19+OFFSET_x)*OFFSET,(2+OFFSET_y)*OFFSET,"Player key:");
setcolor(9);
settextstyle(3,0,1);
outtextxy((19+OFFSET_x)*OFFSET,(4+OFFSET_y)*OFFSET,"UP--up ");
outtextxy((19+OFFSET_x)*OFFSET,(6+OFFSET_y)*OFFSET,"DOWN--down ");
outtextxy((19+OFFSET_x)*OFFSET,(8+OFFSET_y)*OFFSET,"LEFT--left");
outtextxy((19+OFFSET_x)*OFFSET,(10+OFFSET_y)*OFFSET,"RIGHT--right");
outtextxy((19+OFFSET_x)*OFFSET,(12+OFFSET_y)*OFFSET,"ENTER--space");