|
|
|
@ -0,0 +1,116 @@
|
|
|
|
|
#include<windows.h>
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
|
|
|
|
|
void DrawCheckerBoard();
|
|
|
|
|
void DrawStartMenu();
|
|
|
|
|
void ClearPanel();
|
|
|
|
|
void goto_xy(int x,int y);
|
|
|
|
|
void Write(int x,int y,const char* str);
|
|
|
|
|
|
|
|
|
|
#define WIDTH 100
|
|
|
|
|
#define HEIGHT 60
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
|
|
int input=-1;
|
|
|
|
|
//char input='9';
|
|
|
|
|
char a;
|
|
|
|
|
system("mode con:cols=100 lines=60"); //设置窗口为100列,60行大小
|
|
|
|
|
SetConsoleOutputCP(437);
|
|
|
|
|
|
|
|
|
|
DrawStartMenu();
|
|
|
|
|
|
|
|
|
|
while(input!=0){
|
|
|
|
|
//cin>>input; //获取输入
|
|
|
|
|
|
|
|
|
|
scanf("%d",&a);
|
|
|
|
|
getchar();
|
|
|
|
|
input=(int)a;
|
|
|
|
|
|
|
|
|
|
if(input>2||input<0){
|
|
|
|
|
printf("The input is wrong,please enter again.");
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else if(input==1)
|
|
|
|
|
DrawCheckerBoard();
|
|
|
|
|
else if(input==2)
|
|
|
|
|
DrawStartMenu();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//绘制开始菜单
|
|
|
|
|
void DrawStartMenu(){
|
|
|
|
|
|
|
|
|
|
ClearPanel();
|
|
|
|
|
printf(" ************************\n");
|
|
|
|
|
printf(" chinese chess\n");
|
|
|
|
|
printf(" ************************");
|
|
|
|
|
|
|
|
|
|
Write(40,11,"0-Exit Game");
|
|
|
|
|
Write(40,12,"1-Start Game");
|
|
|
|
|
Write(40,13,"2-StartMenu");
|
|
|
|
|
Write(30,15,"Please press 0 OR 1 to select:");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//绘制棋盘
|
|
|
|
|
void DrawCheckerBoard(){
|
|
|
|
|
ClearPanel();
|
|
|
|
|
|
|
|
|
|
{int r=0;
|
|
|
|
|
int c=0;
|
|
|
|
|
int star_one=10;
|
|
|
|
|
for(r=0;r<=star_one*9;r+=2)
|
|
|
|
|
{ for(c=0;c<=star_one*8;c+=2)
|
|
|
|
|
{if((r%star_one==0 || c%star_one==0)&&c%2==0 && (r<=star_one*4 || r>=star_one*4+star_one) || (r>=star_one*4 && r<=star_one*4+star_one && (c==0 || c==star_one*8))
|
|
|
|
|
||((r==2||r==18||r==88||r==72)&&(c==32||c==48))
|
|
|
|
|
||((r==4||r==16||r==86||r==74)&&(c==34||c==46))
|
|
|
|
|
||((r==6||r==14||r==84||r==76)&&(c==36||c==44))
|
|
|
|
|
||((r==8||r==12||r==82||r==78)&&(c==38||c==42)))
|
|
|
|
|
{printf("%c",'*');}
|
|
|
|
|
else
|
|
|
|
|
{printf("%c",' ');}
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//清理屏幕
|
|
|
|
|
void ClearPanel(){
|
|
|
|
|
for(int i=0;i<HEIGHT;i++){
|
|
|
|
|
for(int j=0;j<WIDTH;j++){
|
|
|
|
|
goto_xy(j,i);
|
|
|
|
|
printf("%c",0x00);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
goto_xy(0,0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//string* Registered(){
|
|
|
|
|
// string* str[2];
|
|
|
|
|
// string userName;
|
|
|
|
|
// string passWord;
|
|
|
|
|
// printf("Please press UserName");
|
|
|
|
|
// cin>>userName;
|
|
|
|
|
// printf("Please press PassWord");
|
|
|
|
|
// cin>>passWord;
|
|
|
|
|
//
|
|
|
|
|
// str[0]=userName;
|
|
|
|
|
// str[1]=passWord;
|
|
|
|
|
// return str;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void goto_xy(int x,int y){ //定位光标位置到指定坐标
|
|
|
|
|
HANDLE hOut;
|
|
|
|
|
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
|
|
|
COORD pos={x,y};
|
|
|
|
|
SetConsoleCursorPosition(hOut,pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//从指定位置开始绘制文字
|
|
|
|
|
void Write(int x,int y,const char* str){
|
|
|
|
|
goto_xy(x,y);
|
|
|
|
|
printf(str);
|
|
|
|
|
}
|
|
|
|
|
|