#include<bits/stdc++.h> #include<winsock.h> using namespace std; //基本函数 string ; bool S(){cin>>;return [0]==‘r’?0:1;} int ToInt(string ){return ([0]-‘0’)*10+[1]-‘0’;} int read(){cin>>;return ToInt();} //游戏主体部分 char mp[60][200]= { ”█████ █████ █████ █████ █████”, ”█ █━━━━██ ██━━━━█ █━━━━██ ██━━━━█ █”, ”█████ █████ █████ █████ █████”, ” ┃ ┃ ┃ ┃ ┃ ”, ”█████ █████ █████ █████ █████”, ”█ █══════█ █══════█ █══════█ █══════█ █”, ”█████ █████ █████ █████ █████”, ” ║ ▔\▁ ┃ ▁/▔ ┃ ▔\▁ ┃ ▁/▔ ║ ”, ”█████ \███/ █████ \███/ █████”, ”█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █”, ”█████ /███\ █████ /███\ █████”, ” ║ ▁/▔ ┃ ▔\▁ ┃ ▁/▔ ┃ ▔\▁ ║ ”, ”█████ █████ \███/ █████ █████”, ”█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █”, ”█████ █████ /███\ █████ █████”, ” ║ ▔\▁ ┃ ▁/▔ ┃ ▔\▁ ┃ ▁/▔ ║ ”, ”█████ \███/ █████ \███/ █████”, ”█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █”, ”█████ /███\ █████ /███\ █████”, ” ║ ▁/▔ ┃ ▔\▁ ┃ ▁/▔ ┃ ▔\▁ ║ ”, ”█████ █████ █████ █████ █████”, ”█ █══════█ █══════█ █══════█ █══════█ █”, ”█████ █████ █████ █████ █████”, ” ║ ║ ║ ”, ”█████ █████ █████”, ”█ █ █ █ █ █”, ”█████ █████ █████”, ” ║ ║ ║ ”, ”█████ █████ █████ █████ █████”, ”█ █══════█ █══════█ █══════█ █══════█ █”, ”█████ █████ █████ █████ █████”, ” ║ ▔\▁ ┃ ▁/▔ ┃ ▔\▁ ┃ ▁/▔ ║ ”, ”█████ \███/ █████ \███/ █████”, ”█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █”, ”█████ /███\ █████ /███\ █████”, ” ║ ▁/▔ ┃ ▔\▁ ┃ ▁/▔ ┃ ▔\▁ ║ ”, ”█████ █████ \███/ █████ █████”, ”█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █”, ”█████ █████ /███\ █████ █████”, ” ║ ▔\▁ ┃ ▁/▔ ┃ ▔\▁ ┃ ▁/▔ ║ ”, ”█████ \███/ █████ \███/ █████”, ”█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █━━━━━━█ █”, ”█████ /███\ █████ /███\ █████”, ” ║ ▁/▔ ┃ ▔\▁ ┃ ▁/▔ ┃ ▔\▁ ║ ”, ”█████ █████ █████ █████ █████”, ”█ █══════█ █══════█ █══════█ █══════█ █”, ”█████ █████ █████ █████ █████”, ” ┃ ┃ ┃ ┃ ┃ ”, ”█████ █████ █████ █████ █████”, ”█ █━━━━██ ██━━━━█ █━━━━██ ██━━━━█ █”, ”█████ █████ █████ █████ █████”, }; int is[70];//0:普通 1:大本营 2:行营 3:山界 vector<int> e[70][3]; #define gotoxy(x,y) SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),(COORD){(short)(x),(short)(y)}) #define KD(VK_NONAME) ((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0) #define color(COLOR) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),COLOR); void hide_cursor() { HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO CursorInfo; GetConsoleCursorInfo(handle,&CursorInfo); CursorInfo.bVisible=false; SetConsoleCursorInfo(handle,&CursorInfo); } bool painted;//是否已经绘制了棋盘 bool turn;//谁先走 void printchess(){painted=true;for(int i=0;i<=50;++i){for(int j=0;j<=100;++j){color(mp[i][j]==”█“[0]||mp[i][j]==”█“[1]?0x77:0xf7);putchar(mp[i][j]);}puts("");}} int a[70],b[70];//a:棋子类型 b:0(平常) 1(选中) 2(光标) int win;//赢没有 void prompt(string s) { if(!painted){puts(s.c_str());return;} color(0x70); gotoxy(0,52); printf(“%s”,s.c_str()); for(int i=s.size()+1;i<=75;++i)putchar(’ ’); } void init_num() { hide_cursor(); is[1]=is[3]=is[61]=is[63]=1; is[11]=is[13]=is[17]=is[21]=is[23]=is[41]=is[43]=is[47]=is[51]=is[53]=2; is[31]=is[33]=3; color(0xf7); gotoxy(0,51); for(int =1;<=75;++)putchar(’ ’); color(0x70); gotoxy(0,52); for(int =1;<=75;++)putchar(’ ’); gotoxy(0,0); } char ch[20][10]={” ”,” 炸弹 ”,” 司令 ”,” 军长 ”,” 师长 ”,” 旅长 ”,” 团长 ”,” 营长 ”,” 连长 ”,” 排长 ”,” 工兵 ”,” 地雷 ”,” 军旗 ”,”▓▓▓”}; void upd1(int x,int y=114514)//修改旗子 { int X=x%516,Y=x/54;if(y!=114514)a[x]=y; if(a[x]<0)color(0xfc); if(a[x]>0)color(0xf9); if(a[x]==0)color(0xff); gotoxy(X+2,Y+1); printf(ch[abs(a[x])]); gotoxy(0,51); color(0x70); } void upd2(int x,int y=114514)//修改光标 { int X=x%516,Y=x/54;if(y!=114514)b[x]=y; if(b[x]==0)color(0x77); if(b[x]==1)color(0xee); if(b[x]==2)color(0xbb); gotoxy(X+(is[x]==2)*2,Y);for(int i=X+(is[x]==2)*2;i<=X+9-(is[x]==2)*2;++i)putchar(mp[Y][i]); gotoxy(X+(is[x]==2)*2,Y+2);for(int i=X+(is[x]==2)*2;i<=X+9-(is[x]==2)*2;++i)putchar(mp[Y+2][i]); gotoxy(X,Y+1);printf(”█”);gotoxy(X+8,Y+1);printf(”█”); if(is[x]==1)gotoxy(X-2,Y+1),printf(”█”),gotoxy(X+10,Y+1),printf(”█”); gotoxy(0,51);color(0x70); } void init_game() { for(int i=0;i<8;++i)S(); for(int i=64;i>=35;i—)S(),upd1(i,read()); for(int i=0;i<=29;i++)S(),upd1(i,-read()); turn=S()^read(); Sleep(2000); } int compare(int x,int y) { int xx=abs(x),yy=abs(y); if(x==12||y==12)win=-1; if(x==-12||y==-12)win=1; if(xx==1||yy==1)return 0; if(xx==11)return yy==10?y:0; if(yy==11)return xx==10?x:0; return xx==yy?0:(xx<yy?x:y); } void eat(int p,int x,int y) { upd2(p,1); upd1(p,x);Sleep(400); upd1(p,y);Sleep(400); upd1(p,x);Sleep(400); upd1(p,y);Sleep(400); upd1(p,x);Sleep(400); upd1(p,y);Sleep(400); upd1(p,compare(x,y)); upd2(p,0); } vector<int> path; void move(vector<int> &path) { int x=a[path[0]],y=a[*path.rbegin()]; for(int i:path) { upd2(i,1);upd1(i,x); Sleep(path.size()==2?500:200); upd2(i,0);if(i!=*path.rbegin())upd1(i,0); } if(y)eat(*path.rbegin(),x,y); Sleep(500);//如果觉得快可以把这里调大点 } void game() { init_game(); int x,y; while(!win) { if(turn) { S();x=read();path.clear(); while(x—)S(),y=read(),path.push_back(y); move(path);turn^=1; } if(win)break; if(!turn) { S();x=read();path.clear(); while(x—)S(),y=64-read(),path.push_back(y); move(path);turn^=1; } } prompt(win==1?”游戏结束,你获得了胜利!”:“游戏结束,你输了!”); system(“pause>nul”); } char [101]; int main() { puts(“请输入存档文件名:”); scanf(“%s”,); system(“mode con cols=75 lines=53”); system(“color f7”); freopen(__,“r”,stdin); SetWindowLong(GetConsoleWindow(),GWL_STYLE,GetWindowLong(GetConsoleWindow(),GWL_STYLE)&~WS_SIZEBOX); init_num(); printchess(); game(); }
剪贴板
剪贴板 15fcvekz
剪贴板信息
剪贴板信息
- 收录
- 更新