|
|
|
@ -1,21 +1,32 @@
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <conio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#define MAXIMUS 19
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<conio.h>
|
|
|
|
|
#include<string.h>
|
|
|
|
|
#define MAXIMUS 19 //定义棋盘大小
|
|
|
|
|
#define W 0x1177
|
|
|
|
|
#define S 0x1f73
|
|
|
|
|
#define A 0x1e61
|
|
|
|
|
#define D 0x2064
|
|
|
|
|
int p[MAXIMUS][MAXIMUS];
|
|
|
|
|
char buff[MAXIMUS*2+1][MAXIMUS*4+3];
|
|
|
|
|
int Cx,Cy;
|
|
|
|
|
int Now;
|
|
|
|
|
int wl,wp;
|
|
|
|
|
char* showText;
|
|
|
|
|
int count;
|
|
|
|
|
int bye();
|
|
|
|
|
int DoWin(int v);
|
|
|
|
|
#define D 0x2064//定义WSAD的键码
|
|
|
|
|
int p[MAXIMUS][MAXIMUS];//存储对局信息
|
|
|
|
|
char buff[MAXIMUS*2+1][MAXIMUS*4+3];//输出缓冲器
|
|
|
|
|
int Cx,Cy;//当前光标位置
|
|
|
|
|
int Now;//当前走子的玩家,1代表黑,2代表白
|
|
|
|
|
int wl,wp;//当前写入缓冲器的列数和行数位置
|
|
|
|
|
char* showText;//在棋盘中央显示的文字信息
|
|
|
|
|
int count;//回合数
|
|
|
|
|
int RunGame();
|
|
|
|
|
void welcome();
|
|
|
|
|
void help();
|
|
|
|
|
void bye();
|
|
|
|
|
void DoWin(int v);
|
|
|
|
|
int ch,dh,del,n=0,m=0;/*文件操作计分变量*/
|
|
|
|
|
void Point();/*整合所有文件操作的模块*/
|
|
|
|
|
void p1_point_input();/*1p计分文件读取*/
|
|
|
|
|
void p1_point_input2();/*1p计分文件写入*/
|
|
|
|
|
void p1_point_output();/*1p计分文件输出*/
|
|
|
|
|
void p2_point_input();/*2p计分文件读取*/
|
|
|
|
|
void p2_point_input2();/*2p计分文件写入*/
|
|
|
|
|
void p2_point_output();/*2p计分文件输出*/
|
|
|
|
|
char* Copy(char* strDest,const char* strSrc)
|
|
|
|
|
{
|
|
|
|
|
char* strDestCopy = strDest;
|
|
|
|
@ -40,7 +51,47 @@ p[i][j]=0;
|
|
|
|
|
Cx=Cy=MAXIMUS/2;
|
|
|
|
|
Now=1;
|
|
|
|
|
}
|
|
|
|
|
welcome() /*»¶Ó½çÃæ*/
|
|
|
|
|
char* getStyle(int i,int j)//获得棋盘中指定坐标交点位置的字符,通过制表符拼成棋盘
|
|
|
|
|
{
|
|
|
|
|
if(p[i][j]==1)//1为黑子
|
|
|
|
|
return "●";
|
|
|
|
|
else if(p[i][j]==2)//2为白子
|
|
|
|
|
return "○";
|
|
|
|
|
else if(i==0&&j==0)//以下为边缘棋盘样式
|
|
|
|
|
return "┏";
|
|
|
|
|
else if(i==0&&j==MAXIMUS-1)
|
|
|
|
|
return "┗";
|
|
|
|
|
else if(i==MAXIMUS-1&&j==0)
|
|
|
|
|
return "┓";
|
|
|
|
|
else if(i==MAXIMUS-1&&j==MAXIMUS-1)
|
|
|
|
|
return "┛";
|
|
|
|
|
else if(i==0)
|
|
|
|
|
return "┣";
|
|
|
|
|
else if(i==MAXIMUS-1)
|
|
|
|
|
return "┫";
|
|
|
|
|
else if(j==0)
|
|
|
|
|
return "┳";
|
|
|
|
|
else if(j==MAXIMUS-1)
|
|
|
|
|
return "┻";
|
|
|
|
|
return "╋";//中间的空位
|
|
|
|
|
}
|
|
|
|
|
char* getCurse(int i,int j){//获得指定坐标交点位置左上格的样式,通过制表符来模拟光标的显示
|
|
|
|
|
if(i==Cx){
|
|
|
|
|
if(j==Cy)
|
|
|
|
|
return "┏";
|
|
|
|
|
else if (j==Cy+1)
|
|
|
|
|
return "┗";
|
|
|
|
|
}
|
|
|
|
|
else if(i==Cx+1)
|
|
|
|
|
{
|
|
|
|
|
if(j==Cy)
|
|
|
|
|
return "┓";
|
|
|
|
|
else if (j==Cy+1)
|
|
|
|
|
return "┛";
|
|
|
|
|
}
|
|
|
|
|
return " ";//如果不在光标附近则为空
|
|
|
|
|
}
|
|
|
|
|
void welcome() /*欢迎界面*/
|
|
|
|
|
{ Initialize(); /*初始化*/
|
|
|
|
|
system("cls"); /*清屏*/
|
|
|
|
|
system("color 2"); /*设置颜色*/
|
|
|
|
@ -74,7 +125,7 @@ printf("\t
|
|
|
|
|
printf("\t╚══════════════════╝\n");
|
|
|
|
|
getch();
|
|
|
|
|
}
|
|
|
|
|
DoWin(int v)
|
|
|
|
|
void DoWin(int v)
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
Initialize();
|
|
|
|
@ -108,11 +159,11 @@ scanf("%d",&n);
|
|
|
|
|
if(n==1)
|
|
|
|
|
printf("请按任意键继续");
|
|
|
|
|
if(n==2)
|
|
|
|
|
bye();
|
|
|
|
|
void bye();
|
|
|
|
|
}
|
|
|
|
|
int main()//主函数
|
|
|
|
|
{welcome();
|
|
|
|
|
help();
|
|
|
|
|
void help();
|
|
|
|
|
system("title C语言五子棋游戏课程设计 ——湖工大通一李得龙,黄智");//设置标题
|
|
|
|
|
system("mode con cols=504 lines=512");//设置窗口大小
|
|
|
|
|
system("color F0");//设置颜色
|