c++做走迷宫游戏

这是我第一次用MD编辑器,感觉有种用野生编辑器写html的感觉
但是一些html的标签还是用不了
本来认为这就是一种类似于html的写法,后来一搜才发现...是我想少了
随便一搜,好家伙,直接出来十几万字的教程
此刻,我终于明白了那些时间复杂度类似于nn这样的东西是怎么打出来的了
hhhhh
直接进入正题!这个代码是别人给我让我改的,然后我就给这个代码基本重新写了一遍...
不得不说,这bug是真多呀。。。虽然原作者给了我发原创的权利,但是还是附上原文地址,有兴趣可以比较一下代码,改的地方还是挺多的
[原文](https://blog.csdn.net/klaudius/article/details/123015248?spm=1001.2014.3001.5501) 代码:
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
long long s=1,shengming=20,bushu=0,leiren,lx1,ly1,lx,ly;
const long long n=59,jg=25,dengji=0;
bool yaoshi=0,leiren2;
string p=" M!|=.123456789%&_~£Win";
long long r=1;
char f='y';
void color(int a)//打印颜色
{
    
    
/*亮白*/    if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
/*蓝色*/    if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
/*绿色*/    if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
/*紫色*/    if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
/*红色*/    if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
/*黄色*/    if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
/*深蓝色*/    if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
/*土黄色or金黄色*/    if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN);
/*灰色接近白*/    if(a==8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
}/*
void lrmove(int yyy) {
    if (lx>x&&lx-1!='#'&&lx-1!='^'&&lx-1!='V'&&lx-1!='<'&&lx-1!='>'&&lx-1!='*'&&lx-1!='0'&&lx-1!='+'&&lx-1!='-'&&lx-1!='Z'&&lx-1!='D') {
        lx-=1;
    }
    if (lx<x&&lx+1!='#'&&lx+1!='^'&&lx+1!='V'&&lx+1!='<'&&lx+1!='>'&&lx+1!='*'&&lx+1!='0'&&lx+1!='+'&&lx+1!='-'&&lx+1!='Z'&&lx+1!='D') {
        lx+=1;
    }
    if (ly<y&&ly+1!='#'&&ly+1!='^'&&ly+1!='V'&&ly+1!='<'&&ly+1!='>'&&ly+1!='*'&&ly+1!='0'&&ly+1!='+'&&ly+1!='-'&&ly+1!='Z'&&ly+1!='D') {
        lx+=1;
    }
    if (ly<y&&ly-1!='#'&&ly-1!='^'&&ly-1!='V'&&ly+1!='<'&&ly-1!='>'&&ly-1!='*'&&ly-1!='0'&&ly-1!='+'&&ly-1!='-'&&ly-1!='Z'&&ly-1!='D') {
        if()
        lx-=1;
    }*/
long long numberaio(string n){
    
    
    for (int i = 0; i < 100000; i++) {
    
    
        if(n[i]=='\0')
        {
    
    
            return i;
        }
    }
}
void coutAIO(string b,int truefalse0 = 1,bool truefalse1 = 0){
    
    
    int i=0,s=0;
    long long a=numberaio(b);
    while(a!=0){
    
    
        s=rand()%9;
        if(a!=0&&s==0)
        {
    
    
            color(0);
            cout << b[i];
            a--;
            i++;
        }
        if(a!=0&&s==1)
        {
    
    
            color(1);
            cout << b[i];
            a--;
            i++;
        }
        if(a!=0&&s==2)
        {
    
    
            color(2);
            cout << b[i];
            a--;
            i++;
        }
        if(a!=0&&s==3)
        {
    
    
            color(3);
            cout << b[i];
            a--;
            i++;
            if(truefalse0!=false){
    
    
                Sleep(20);
            }
        }
        if(a!=0&&s==4)
        {
    
    
            color(4);
            cout << b[i];
            a--;
            i++;
        }
        if(a!=0&&s==5)
        {
    
    
            color(5);
            cout << b[i];
            a--;
            i++;
        }
        if(a!=0&&s==6)
        {
    
    
            color(6);
            cout << b[i];
            a--;
            i++;
        }
        if(a!=0&&s==7)
        {
    
    
            color(7);
            cout << b[i];
            a--;
            i++;
        }
        if(a!=0&&s==8)
        {
    
    
            color(8);
            cout << b[i];
            a--;
            i++;
        }
        if(truefalse0 ==1){
    
    
            Sleep(10);
        }
        if(truefalse0 ==2){
    
    
            Sleep(20);
        }
        if(truefalse0 ==3){
    
    
            Sleep(40);
        }
        if(truefalse0 ==4){
    
    
            Sleep(100);
        }
        if(truefalse0 ==5){
    
    
            Sleep(300);
        }
        if(truefalse0 ==6){
    
    
            Sleep(1000);
        }
    }
    if(truefalse1!=false){
    
    
        getch();
        system("cls");
    }
    cout << endl;
}
void ksjm()
{
    
    
    system("color f0");
    cout<<"按任意键开始游戏...";
    getch();
    system("cls");
    for(long long i=1;i<=3;i++)
    {
    
    
        system("color 07");
        system("color 10");
        system("color 20");
        system("color 30");
        system("color 40");
        system("color 50");
        system("color 60");
        system("color 70");
        system("color 80");
        system("color 90");
        system("color a0");
        system("color b0");
        system("color c0");
        system("color d0");
        system("color e0");
        system("color f0");
    }
    cout<<"\n\n\n\n\n\n\n\n\n\n\n                                                      ";
    coutAIO("走迷宫",2);
    cout<<"\n";
    cout<<"                                                   ";
    coutAIO("出品:饼干,修改:努力的AIO bug修复及优化:YR_T",5);
    Sleep(1500);
}
void start(int n)
{
    
    
    system("cls");
    cout<<"加载中请稍等";
    Sleep(1000);
    system("cls");
    for (int i=1;i<=n; i++)
    {
    
    
        cout<<"加载中."<<endl;
        cout<<"▏";
        Sleep(20);
        system("cls");
        cout<<"加载中.."<<endl;
        cout<<"▎";
        Sleep(20);
        system("cls");
        cout<<"加载中..."<<endl;
        cout<<"▍";
        Sleep(20);
        system("cls");
        cout<<"加载中."<<endl;
        cout<<"▋";
        Sleep(20);
        system("cls");
        cout<<"加载中.."<<endl;
        cout<<"▊";
        Sleep(20);
        system("cls");
        cout<<"加载中..."<<endl;
        cout<<"▉";
        Sleep(20);
        system("cls");
        cout<<"加载中."<<endl;
        cout<<"▉▏";
        Sleep(20);
        system("cls");
        cout<<"加载中.."<<endl;
        cout<<"▉▎";
        Sleep(20);
        system("cls");
        cout<<"加载中..."<<endl;
        cout<<"▉▍";
        Sleep(20);
        system("cls");
        cout<<"加载中."<<endl;
        cout<<"▉▌";
        Sleep(20);
        system("cls");
        cout<<"加载中.."<<endl;
        cout<<"▉▋";
        Sleep(20);
        system("cls");
        cout<<"加载中..."<<endl;
        cout<<"▉▊";
        Sleep(20);
        system("cls");
        cout<<"加载中."<<endl;
        cout<<"▉▉";
        Sleep(20);
        system("cls");
        cout<<"加载中.."<<endl;
        cout<<"▉▉▏";
        Sleep(20);
        system("cls");
        cout<<"加载中..."<<endl;
        cout<<"▉▉▎";
        Sleep(20);
        system("cls");
        cout<<"加载中."<<endl;
        cout<<"▉▉▍";
        Sleep(20);
        system("cls");
        cout<<"加载中.."<<endl;
        cout<<"▉▉▌";
        Sleep(20);
        system("cls");
        cout<<"加载中..."<<endl;
        cout<<"▉▉▋";
        Sleep(20);
        system("cls");
        cout<<"加载中."<<endl;
        cout<<"▉▉▊";
        Sleep(20);
        system("cls");
        cout<<"加载中.."<<endl;
        cout<<"▉▉▉▏";
        Sleep(20);
        system("cls");
        cout<<"加载中..."<<endl;
        cout<<"▉▉▉▎";
        Sleep(20);
        system("cls");
        cout<<"加载中."<<endl;
        cout<<"▉▉▉▍";
        Sleep(20);
        system("cls");
        cout<<"加载中.."<<endl;
        cout<<"▉▉▉▌";
        Sleep(20);
        system("cls");
        cout<<"加载中..."<<endl;
        cout<<"▉▉▉▋";
        Sleep(20);
        system("cls");
        cout<<"加载中."<<endl;
        cout<<"▉▉▉▋";
        Sleep(20);
        system("cls");
        cout<<"加载中.."<<endl;
        cout<<"▉▉▉▊";
        Sleep(20);
        system("cls");
        cout<<"加载中..."<<endl;
        cout<<"▉▉▉▉";
        Sleep(20);
        system("cls");
    }
    coutAIO("加载完成!Please wait!...collecting deta...",4);
    Sleep(2000);
    system("cls");
    Sleep(8000);
    ksjm();
}
//void print(string a[n])//输出迷宫
//{
    
    
//    system("cls");
//    for(long long i=0;i<8;i++)
//    {
    
    
//    	cout<<i<<" ";
//    	cout<<a[i]<<endl;
//	}
//    //cout<<a[i]<<endl;
//}
void tc()//关闭界面
{
    
    
    system("cls");
    cout<<"\n\n\n\n\n                    欢迎下次再玩,拜拜!!!\n";
    cout<<"                    原作:饼干,改编:VIC bug修复及优化:YR_T\n";
    cout<<"                  (按空格结束)";
    long long ok='\0';
    while(ok=getch(),ok!=' ');
    system("cls");
    MessageBox(NULL,("退出"),("点击确定退出"),MB_OK); 
    return ;
}
void hf()//皮肤
{
    
    
    char t='\0';
    while(t!=' ')
    {
    
    
        system("cls");
        cout<<"\n\n\n\n                           A D键换皮肤    空格确定\n\n";
        cout<<"\n\n\n\n                          "<<p[r]<<"\n";
        t=getch();
        if(t=='a')r--;
        else
        if(t=='d')r++;
        if(r<1)r=jg;
        if(r>jg)r=1;
    }
    system("cls");
    return ;
}
void sm()//说明
{
    
    
    system("cls");
    cout<<"\n\n        游戏说明:\n\n\n";
    cout<<"                    按空格开始游戏后\n";
    cout<<"                      W\n";
    cout<<"                    A S D\n";
    cout<<"                    移动\n";
    cout<<"                    M是你\n";
    cout<<"                       按R键返回起点\n";
    cout<<"                       按P键返回主界面\n";
    cout<<"                       按Q键设立传送点\n";
    cout<<"                       按E键返回传送点\n";
    cout<<"                       Z处为终点\n";
    cout<<"                       -号处为左右穿刺,可到另一头,但减血5滴\n";
    cout<<"                       *号处为炸药\n";
    cout<<"                       #号处为障碍物\n";
    cout<<"                       ?号处为可清理障碍物\n";
    cout<<"                       V处为下刺\n";
    cout<<"                       <处为左刺\n";
    cout<<"                       >处为右刺\n";
    cout<<"                       ^处为上刺\n";
    cout<<"                       @处为钥匙\n";
    cout<<"                       +号处为加血\n";
    cout<<"                       0处为死地(不可复活且每个普通关只有一个,BOSS关有五个,超级BOSS关有10个以上)\n";
    cout<<"            新手指导说明:\n";
    cout<<"                       目前猎人正在测试,可能不稳定,敬请谅解\n\n\n";
    cout<<"            按空格继续···";
    long long ok='\0';
    while(ok=getch(),ok!=' ');
    system("cls");
    return ;
}
void full_screen()
{
    
       
    HWND hwnd = GetForegroundWindow();
    int cx = GetSystemMetrics(SM_CXSCREEN);            /* 屏幕宽度 像素 */
    int cy = GetSystemMetrics(SM_CYSCREEN);            /* 屏幕高度 像素 */

    LONG l_WinStyle = GetWindowLong(hwnd,GWL_STYLE);   /* 获取窗口信息 */
    /* 设置窗口信息 最大化 取消标题栏及边框 */
    SetWindowLong(hwnd,GWL_STYLE,(l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME & ~WS_BORDER);

    SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
}
void hys()//背景
{
    
    
    system("cls");
    cout<<"\n\n\n\n\n\n\n\n\n      按1【日间色】\n";
    cout<<"      按2【夜间色】\n";
    cout<<"      按3【黑客】\n";
    cout<<"      按4【科幻】\n";
    cout<<"      按5【紫水晶】\n";
    cout<<"		 按6【简约色】\n";
    cout<<"      按7【深邃蓝】\n";
    char s;
    s=getch();
    while(s!='1'&&s!='2'&&s!='3'&&s!='4'&&s!='5'&&s!='6'&&s!='7')s=getch();
    switch(s-'0')
    {
    
    
        case 1:
            system("color f0");
            break;
        case 2:
            system("color 0f");
            break;
        case 3:
            system("color 0a");
            break;
        case 4:
            system("color 09");
            break;
        case 5:
            system("color 01");
            break;
        case 6:
        	system("color 8f");
        	break;
        case 7:
        	system("color 12");
        	break;
    }
    system("cls");
    return ;
}
void xsjc()//新手教程 
{
    
    
	char xxx[100][100]={
    
    
		"#############",
		"#M          #",
		"#           #",
		"#    O      #",
		"#           #",
		"#%          #",
		"#           #",
		"#############"
	};
	for(int i=0;i<=10;i++)
		puts(xxx[i]);
	coutAIO("新手引导:试着移动!",3);
	coutAIO("(O是炸弹,%是猎人)",3);
	cout<<endl;
	coutAIO("找到移动的规律,让炸弹炸掉猎人!(注意自己不要碰到炸弹)",3); 
	char chxx;
	int hang_lr=5,lie_lr=1,hang_player=1,lie_player=1;
	while(1){
    
    
		chxx=_getch();
		if(chxx=='d'){
    
    
			if(xxx[hang_player][lie_player+1]!='#'&&xxx[hang_lr][lie_lr+1]!='#'){
    
    
				xxx[hang_player][lie_player]=' ';
				lie_player++;
				xxx[hang_player][lie_player]='M';
				xxx[hang_lr][lie_lr]=' ';
				lie_lr++;
				xxx[hang_lr][lie_lr]='%';
			}
			if(xxx[hang_player][lie_player+1]==' '&&xxx[hang_lr][lie_lr+1]=='#'){
    
    
				xxx[hang_player][lie_player]=' ';
				lie_player++;
				xxx[hang_player][lie_player]='M';
			}
			if(xxx[hang_player][lie_player+1]=='#'&&xxx[hang_lr][lie_lr+1]==' '){
    
    
				xxx[hang_lr][lie_lr]=' ';
				lie_lr++;
				xxx[hang_lr][lie_lr]='%';
			}
		}
		if(chxx=='a'){
    
    
			if(xxx[hang_player][lie_player-1]!='#'&&xxx[hang_lr][lie_lr-1]!='#'){
    
    
				xxx[hang_player][lie_player]=' ';
				lie_player--;
				xxx[hang_player][lie_player]='M';
				xxx[hang_lr][lie_lr]=' ';
				lie_lr--;
				xxx[hang_lr][lie_lr]='%';
			}
			if(xxx[hang_player][lie_player-1]==' '&&xxx[hang_lr][lie_lr-1]=='#'){
    
    
				xxx[hang_player][lie_player]=' ';
				lie_player--;
				xxx[hang_player][lie_player]='M';
			}
			if(xxx[hang_player][lie_player-1]=='#'&&xxx[hang_lr][lie_lr-1]==' '){
    
    
				xxx[hang_lr][lie_lr]=' ';
				lie_lr--;
				xxx[hang_lr][lie_lr]='%';
			}
		}		
		if(chxx=='w'){
    
    
			if(xxx[hang_player-1][lie_player]!='#'&&xxx[hang_lr-1][lie_lr]!='#'){
    
    
				xxx[hang_player][lie_player]=' ';
				hang_player--;
				xxx[hang_player][lie_player]='M';
				xxx[hang_lr][lie_lr]=' ';
				hang_lr--;
				xxx[hang_lr][lie_lr]='%';
			}
			if(xxx[hang_player-1][lie_player]==' '&&xxx[hang_lr-1][lie_lr]=='#'){
    
    
				xxx[hang_player][lie_player]=' ';
				hang_player--;
				xxx[hang_player][lie_player]='M';
			}
			if(xxx[hang_player-1][lie_player]=='#'&&xxx[hang_lr-1][lie_lr]==' '){
    
    
				xxx[hang_lr][lie_lr]=' ';
				hang_lr--;
				xxx[hang_lr][lie_lr]='%';
			}
		}
		if(chxx=='s'){
    
    
			if(xxx[hang_player+1][lie_player]!='#'&&xxx[hang_lr+1][lie_lr]!='#'){
    
    
				xxx[hang_player][lie_player]=' ';
				hang_player++;
				xxx[hang_player][lie_player]='M';
				xxx[hang_lr][lie_lr]=' ';
				hang_lr++;
				xxx[hang_lr][lie_lr]='%';
			}
			if(xxx[hang_player+1][lie_player]==' '&&xxx[hang_lr+1][lie_lr]=='#'){
    
    
				xxx[hang_player][lie_player]=' ';
				hang_player++;
				xxx[hang_player][lie_player]='M';
			}
			if(xxx[hang_player+1][lie_player]=='#'&&xxx[hang_lr+1][lie_lr]==' '){
    
    
				xxx[hang_lr][lie_lr]=' ';
				hang_lr++;
				xxx[hang_lr][lie_lr]='%';
			}
		}
		if (hang_lr==3&&lie_lr==5)
		{
    
    
			Sleep(100);
			coutAIO("干得好!你已经学会了基本操作,祝你好运!",3);
			Sleep(2000);
			break; 
		}
		if (hang_player==3&&lie_player==5)
		{
    
    
			Sleep(100);
			coutAIO("你被炸死了!!!!!!!!!",3);
			Sleep(2000);
			exit(0);
		}
		system("cls");
		for(int i=0;i<=10;i++)
			puts(xxx[i]);
	}
}
int main()
{
    
    
	coutAIO("要不要全屏(推荐全屏)?输入要或不要");
	string ytytyty;
	cin>>ytytyty;
	if (ytytyty=="要") {
    
    
		full_screen();
	}
    system("color f0");
    coutAIO("你眼里作者们帅不帅?",3);
    string a;
    cin >> a;
    if(a=="太帅了"||a=="帅"||a=="帅死了"||a=="帅!"||a=="帅!"){
    
    
        coutAIO("哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈……");
        Sleep(1000);
        system("cls");
        coutAIO("哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈……");
        Sleep(1000);
        system("cls");
        coutAIO("游戏正式开始!!!!!",5);
    }
    else{
    
    
        coutAIO("不会代码一边去!!!!!!!!!!!!!!");
        goto dad;
    }
    start(4);
    while(1)
    {
    
    
        long long xx=1,yy=1;
        system("cls");
        f='y';
        cout<<"\n\n\n\n\n\n\n\n\n\n\n";
        cout<<"                                                      迷宫游戏,注意全屏\n";
        cout<<"                                                   按空格开始游戏\n";
        cout<<"                                                    按0退出游戏\n";
        cout<<"                                                    按1换皮肤\n";
        cout<<"                                                    按2游戏说明\n";
        cout<<"                                                    按3换颜色\n";
        cout<<"\n";
        cout<<"                                                     原创:饼干 改编:努力的AIO bug修复及优化:YR_T";
        long long ok=getch();
        while(ok!='0'&&ok!='1'&&ok!='2'&&ok!=' '&&ok!='3')ok=getch();
        switch(ok)
        {
    
    
            case ' ':
                break;
            case '0':
                tc();
                return 0;
                break;
            case '1':
                hf();
                f='n';
                break;
            case '2':
                sm();
                f='n';
                break;
            case '3':
                hys();
                f='n';
                break;
        }
        while(f=='y')
        {
    
    
            system("cls");
            string a[n];
            long long x,y,qx,qy;
            long long ch;
            srand(time(0));
            int oplen=0;
            switch(s) 
            {
    
    
                case 1:
                	xsjc();
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=1;
                    qy=1;
                    a[0]="###########";
                    a[1]="#   *   #@#";
                    a[2]="# #   #   #";
                    a[3]="# ##0## ###";
                    a[4]="# #???###Z#";
                    a[5]="#???#?????#";
                    a[6]="###########";
                    a[7]="##障碍之地#";
                    a[8]="###########";
                    oplen=8;
                    break;
                case 2:
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=8;
                    qy=12;
                    a[0]="####################";
                    a[1]="#Z   #       #     #";
                    a[2]="# ##   #### ###  # #";
                    a[3]="#  ####      ##### #";
                    a[4]="###   # # ##       #";
                    a[5]="##### #######V##@# #";
                    a[6]="#     ## ###   <#  #";
                    a[7]="## ##^   <## 0 ## ##";
                    a[8]="#      <     #     #";
                    a[9]="####################";
                   a[10]="######黑暗森林######";
                   a[11]="####################";
                   oplen=11;
                    break;
                case 3:
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=1;
                    qy=1;
                    a[0]="###V###V#V#V###0###";
                    a[1]="# #   #   #   #   #";
                    a[2]="# # # # # # # # # #";
                    a[3]="# # # # # # # # # #";
                    a[4]="# # # # # # # # # #";
                    a[5]="# - - - - - - - - #";
                    a[6]="# # # # # # # # # #";
                    a[7]="# # # # # # # # # #";
                    a[8]="# # # # < # # # # #";
                    a[9]="# # # # # # # # # #";
                   a[10]="#   #   # @ #   #Z#";
                   a[11]="#^#^#^#^#^#^#^#^###";
                   a[11]="#^#^#^#^小心1^#^###";
                   a[11]="#^#^#^#^#^#^#^#^###";
                   oplen=11;
                    break;
                case 4:
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=1;
                    qy=1;
                    a[0]="#####################V################V#";
                    a[1]="#                                      #";
                    a[2]="# ###*###################*############ #";
                    a[3]="# #                                  # #";
                    a[4]="# # #####0########*####### ##### ####V*#";
                    a[5]="# # #Z        #     #    # ##*         #";
                    a[6]="# # # # # ##*###### # #### ##  #### ## #";
                    a[7]="# # # # # ##        #      ## ##  #  # #";
                    a[8]="# # # ### ## # # ########### ##  ##  # #";
                    a[9]="# # # # #    # # # #       @#    #   # #";
                   a[10]="# # ### ###### ### # ######## ##### ## #";
                   a[11]="# # * #        -   #              #  # #";
                   a[12]="# # # ######## ############## #####  # #";
                   a[13]="# # >                                # #";
                   a[14]="# # ######*########################### #";
                   a[15]="# #                                  # #";
                   a[16]="# #############V########*#######^##### #";
                   a[17]="#                                      *";
                   a[18]="#*#######################*##############";
                   a[19]="#*###########小心2#######*##############";
                   a[20]="#*#######################*##############";
                   oplen=20;
                    break;
                case 5:
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=1;
                    qy=1;
                    a[0]="########################################";
                    a[1]="#                      #               #";
                    a[2]="# <########## ################# ###### #";
                    a[3]="#           # #               # ##   # #";
                    a[4]="# # # #### ## # ## # #### ##### ## # # #";
                    a[5]="# # # #       #  # #    #        # # # #";
                    a[6]="# # #  #### ###### ############### #   #";
                    a[7]="# # ##    #      # >               # # #";
                    a[8]="# #  #### ######## <^^^^^^^####### # # #";
                    a[9]="# ##    #      0 # < BOSS关VVVV>   # # #";
                   a[10]="#    ######### #   < 危险  >     ### # #";
                   a[11]="#*#     #        # < 地带 1> ##### # # #";
                   a[12]="#   <#############VVVVVVVVV> #     # # #";
                   a[13]="# # #                        # ## #  ###";
                   a[14]="# ### #### ######>  <#######^# #### 0# #";
                   a[15]="#     #    #                      #   Z#";
                   a[16]="##################00###############0####";
                   oplen=16;
                    break;
                case 6:
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=1;
                    qy=1;
                    a[0]="##########################";
                    a[1]="#                        #";
                    a[2]="# ###################### #";
                    a[3]="# #*   *   *   *   *   * #";
                    a[4]="# #  *   *   *   *   *   #";
                    a[5]="### #####################";
                    a[6]="#                        #";
                    a[7]="# ###################### #";
                    a[8]="# >               *   *# #";
                    a[9]="#@# ####*####*  *   *    #";
                   a[10]="##           Z############";
                   a[11]="##0##*####################";
                   a[12]="##^##*######地雷阵1#######";
                   a[13]="##^##*####################";
                   oplen=13;
                    break;
                case 7:
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=1;
                    qy=1;
                    a[0]="#############################################################";
                    a[1]="# ###+#                                                   #+#";
                    a[2]="# #  ###### ##############################################  #";
                    a[3]="# # # #   # #                                             ###";
                    a[4]="# # # # # #   # ########################################### #";
                    a[5]="# # # # # ##### #                                           #";
                    a[6]="# # # # #       # ######################################### #";
                    a[7]="# # # # #########                                         # #";
                    a[8]="# # # # ################################################  # #";
                    a[9]="# # # # #***********************************************#*# #";
                   a[10]="# # # # #ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ # #";
                   a[11]="# # # # #***********************************************# # #";
                   a[12]="# # # # ################################### ############# # #";
                   a[13]="# # # # #                                  #           ## # #";
                   a[14]="# # # # # ##### ###############0# ####################    # #";
                   a[15]="# # # # # #  ## #               # #   *   *   *   *   *## # #";
                   a[16]="# # # # # #+#   # ############# # # *   *   *   *   *     * #";
                   a[17]="# # # # # #######  #   #   #  # # # ####################### #";
                   a[18]="# # #+# #            #   #  #+# #      #################### #";
                   a[19]="# # ### ####################### ########################### #";
                   a[20]="#                                                           #";
                   a[21]="#^###########################################################";
                   a[21]="#^########################地雷阵2######注意生命大于十三######";
                   a[21]="#^###########################################################";
                   oplen=21;
                   break;
                case 8:
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=1;
                    qy=1;
                    a[0]="#############################################################";
                    a[1]="# ###                                                     #@#";
                    a[2]="# #   ##### ##############################################  #";
                    a[3]="# # # #   # #                                              0#";
                    a[4]="# # # # # #   # ##########################################  #";
                    a[5]="# # # # # ##### #                                           #";
                    a[6]="# # # # #       - ######################################### #";
                    a[7]="# # # # #########                                         # #";
                    a[8]="# # # # ################################################  # #";
                    a[9]="# # # # #+++++++++++++++++++++_______+++++++++++++++++++### #";
                   a[10]="# # # # #+++++++++++++++++++++|死|地|++++++++++++++++++** # #";
                   a[11]="# # # # #+++++++++++++++++++++|__|__|+++++++++++++++++++# # #";
                   a[12]="# # # # ######################VVVVVVV#############V###### # #";
                   a[13]="# # # # #                                              ## # #";
                   a[14]="# # # # # #####V######################################    # #";
                   a[15]="# < < < < #  ##                   <   <   <   <   <   *## # #";
                   a[16]="# # # # # #+#   # ############# <   <   <   <   <   < Z>    #";
                   a[17]="# # # # # ##### <VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV^#";
                   a[18]="#   #   # ####*                                            V#";
                   a[19]="#^#^#^#^# VVVV^^VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV>  #";
                   a[20]="#########                                                   *";
                   a[21]="#############################################################";
                   a[22]="############################### 刺刀阵 ######################";
                   a[23]="#############################################################";
                   oplen=23;
                    break;
                case 9:
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=1;
                    qy=1;
                    a[0]="##########################";
                    a[1]="#                        #";
                    a[2]="# ###################### #";
                    a[3]="# #Z   #+#        #   #  #";
                    a[4]="#  #   # #   #       #   #";
                    a[5]="##### ###   #V###### ## ##";
                    a[6]="#     #   ###      #    ##";
                    a[7]="# ######V#V## *### ## ####";
                    a[8]="#     #  #    #    ##    #";
                    a[9]="## ##### # #### ######## #";
                    a[10]="##         ####         @#";
                    a[11]="########0#################";
                    oplen=11;
                    break;
                case 10:
                    if(shengming!=20)
                    {
    
    
                        shengming++;
                    }
                    qx=1;
                    qy=1;
                    a[0]="#################################################################################################V################";
                    a[1]="#     ?                          ?                               ?      ?              ?                ?        #";
                    a[2]="# # 0#######################V#################################^################################################# #";
                    a[3]="# #  ###       #############             ?                   ?             ?          ?               ###     ?  #";
                    a[4]="# ##  ## ^^^^^^           +# ##*#####*#####*#########################0################################ # # #V# # #";
                    a[5]="# ###  # ################### # # # # #                        ?                                      < # # #   # #";
                    a[6]="# ####           -       ? ?     <##################^^^^^^^^^*?????################################# # #   # # # #";
                    a[7]="# ##########################^##########         ############V#####                               ##  # ##### # # #";
                    a[8]="# *#####     ?                          < #####   #########>       + ########################### ## ##       < # #";
                    a[9]="# #      0######## ##################### #     ##          # ####################>     ############  #^####### # #";
                   a[10]="# # ##### ?      # ######       #危险!  # #######  #*###### #                     ###                       # # #";
                   a[11]="# #     # ###### # ####   ##### ##########       #@#         # ##### #######*######   <##################### # ###";
                   a[12]="# ##### # *   ## # *### ##            #    ##### ############# #######              <     #                  # #Z#";
                   a[13]="# #   # #   # ## # ##   #  #0#####*#### ## #   # #        #            ^^^^^^^^^^^^^ ^##### ################ # # #";
                   a[14]="# # # # ##### ## # ## ##  #   #   #   # ##   # # # ###### # ######### #  危险地带超级boss#############  ###  ### #";
                   a[15]="#?# # # ?     ## # #  #     #   #   #   #####  #       #  # #         <###******####>>>>>*********#            # #";
                   a[16]="# ### ########## # #?########0###########V#####V######### # ################**###################  ############# #";
                   a[17]="# #              #       ##                               0           ????                    0###            - O#";
                   a[18]="> # ###V####*#####^######## #####*####*#####*##############0#0##############*#########^###### <################# #";
                   a[19]="0             ?     ?      #  #                 ?                      ?   ?        -           -     ?   -      # ";
                   a[20]="######################^###################################################0########0##########0###################";
                   oplen=20;
				   break;
                case 11:
                    shengming=20;
                    qx=3;
                    qy=3;
                    a[0]="####################################V####|||######V###############################################################";
                    a[1]="#  ?  ?  ?    ?  ?????      *#######    <=V=>#####                      ##########################################";
                    a[2]="#?######################### ######## ## ##V####### ####################  #########################################";
                    a[3]="#    ##V################### ###V  <# ## ##V####### #                 <#  ########################################";
                    a[4]="#0##>   ################### ### # #V ## ##V####### # ###############  @##  #######################################";
                    a[5]=">     # ###>                ### # #  <# ##V####### # ##################### #######################################";
                    a[6]="# ###^# #### #V#########V##^### # # ### V######### >D                      #######################################";
                    a[7]="# ####*      #    ?  <##        < # ### V##V######*###############################################################";
                    a[8]="# ##########^# ##### ### ########   <## 0#########             ? ? ?##############################################";
                    a[9]="#        ?   0 0     ### ###V####^##### V##V###### ################ ##############################################";
                   a[10]="#^#######0#0 # # ###^#V>     ####     # V##        <####   #    #   ##############################################";
                   a[11]=">         ## * # ####>?  ?<# ########## ##V ###### ####  # # ## # ###########################Z              ######";
                   a[12]="# ###V### ##   #     < ##    <>         ##V V##### ###  ## # ##   ######################################### ######";
                   a[13]="# ###   < ##^#^#^### # ##^#V### #######0### V##### ##  ##    ############################################## ######";
                   a[14]="# ### # # >          0    ? ###           < V##### #  # ################################################### ######";
                   a[15]="# ### #?# # #V######^V##### ###^########V V ###### # #     ################################################ ######";
                   a[16]="#     < # # #      <#    0# ############V   <##### #   ### <###################                             ######";
                   a[17]="#^##### >   # #### ## ## ## #############^######## ###>    >                    ##################################";
                   a[18]=">       ###^# #### ## ## ## ###########V##V####### #    ##^##V################# ##################################";
                   a[19]="# #####^##### #### ## ## ## ############V##V###### #                            #                               <#";
                   a[20]="# ???? ???  ? <###    <#    0############V######## #^^^^##########################################################";
                   a[21]="#^################^#####^#########################??           <######<########<######<####<####<####<######/|####";
                   a[23]="<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<^?<<<<?<<<<<<<<<<<<<<<<<<<<<<V<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|####";
                   a[24]="F                -   -        -       -     -           ^               -     ??????????  D        ########关|####";
                   a[25]="#####*# ######## # ### # ###### # ### # ##*   ##V##### ##################V##### ################## #######BOSS####";
                   a[26]="#>    # ####V##*   ##*   #####*   ### # #V######    <  # #  #######>            *###################### 超级无敌 #";
                   a[27]="## ## #    <    <#*V####^#####V##^##>   #        <# # #V ###########V#### #############################不错,菜鸡#";
                   a[28]="## ## #^## # ###V##          <    <####^# #######>  V##              <### #############################你如果这关#";
                   a[29]="## #>      >     ## V####### # ##         <        ^    <####V###### #### #########小心D有时地刺呦#####赢了,你就#";
                   a[30]="## ######V^####>     >       # ##^#######>  V#####^  <# ####>        <### ###########D是陷阱!##########晋级为一级#";
                   a[31]="## ######       <### # #####^# >           ^        >   ##### ######^#### #################################了#####";
                   a[32]="##        <####      <         < #########^  <####### #^####>             <###############################!  !####";
                   a[33]="##^############^######^#########            <########        *##########^################################/####/###";
                   a[34]="################################^####################^####################################################----####";
                   oplen=34;
				case 12:
                    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE);
                    cout << "你赢了!!!!!!!!!!!!!!!!!!!" << endl;
         			MessageBox(NULL,("退出"),("点击确定退出"),MB_OK); 
                    return 0;
            }
            xx=x=qx,yy=y=qy;
            a[x][y]=p[r];
            system("cls");
		    for(long long i=0;i<=oplen;i++)
		    {
    
    
		    	//cout<<i<<" ";
		    	cout<<a[i]<<endl;
			}
            while(true)
            {
    
    
                cout << "生命:" << shengming /*<< endl*/<<" ";
                cout << "步数:" << bushu /*<< endl*/<<" ";
                cout << "等级:" << dengji /*<< endl*/<<" ";
                ch=getch();
                if((ch=='a'&&a[x][y-1]=='?')||(ch=='d'&&a[x][y+1]=='?')||(ch=='s'&&a[x+1][y]=='?')||(ch=='w'&&a[x-1][y]=='?'))
                {
    
    
                    if(ch=='a'&&a[x][y-1]=='?')
                    {
    
    
                        a[x][y-1]=' ';
                    }
                    if(ch=='d'&&a[x][y+1]=='?')
                    {
    
    
                        a[x][y+1]=' ';
                    }
                    if(ch=='s'&&a[x+1][y]=='?')
                    {
    
    
                        a[x+1][y]=' ';
                    }
                    if(ch=='w'&&a[x-1][y]=='?')
                    {
    
    
                        a[x-1][y]=' ';
                    }
                }
                bushu++;
                if(ch=='q')
                {
    
    
                    xx=x;
                    yy=y;
                }
                if(ch=='e')
                {
    
    
                    a[x][y]=' ';
                    a[xx][yy]=p[r];
                    x=xx;
                    y=yy;
                }
                if(ch=='r')
                {
    
    
                    a[x][y]=' ';
                    a[qx][qy]=p[r];
                    x=qx;
                    y=qy;
                }
                if(shengming<=0)
                {
    
    
                    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED);
                    cout <<"你死了!!!!!!!!!!!!!!!!!"<< endl;
                    return 0;
                }
                
                if(ch=='p')
                {
    
    
                    f='n';
                    break;
                }
                if((ch=='a'&&a[x][y-1]=='Z'&&yaoshi==true)||(ch=='d'&&a[x][y+1]=='Z'&&yaoshi==true)||(ch=='s'&&a[x+1][y]=='Z'&&yaoshi==true)||(ch=='w'&&a[x-1][y]=='Z'&&yaoshi==true))
                {
    
    
                    break;
                }
                if(ch=='w'&&a[x-1][y]=='V')
                {
    
    
                    coutAIO("你被刺扎了,扣血4滴");
                    shengming-=4;
                    system("pause");
                }
                if(ch=='a'&&a[x][y-1]=='<')
                {
    
    
                    coutAIO("你被刺扎了,扣血4滴");
                    shengming-=4;
                    system("pause");
                }
                if(ch=='d'&&a[x][y+1]=='>')
                {
    
    
                    coutAIO("你被刺扎了,扣血4滴");
                    shengming-=4;
                    system("pause");
                }
                if(ch=='s'&&a[x+1][y]=='^')
                {
    
    
                    coutAIO("你被刺扎了,扣血4滴");
                    shengming-=4;
                    system("pause");
                }
                if((ch=='a'&&a[x][y-1]=='+')||(ch=='d'&&a[x][y+1]=='+')||(ch=='s'&&a[x+1][y]=='+')||(ch=='w'&&a[x-1][y]=='+'))
                {
    
    
                    if(shengming>=20)
                    {
    
    
                        coutAIO("你加不了血!");
                        goto flag;
                    }
                    coutAIO("你加了血!你加了一滴血!");
                    shengming+=1;
                    if(ch=='a'&&a[x][y-1]=='+')
                    {
    
    
                        a[x][y-1]=' ';
                    }
                    if(ch=='d'&&a[x][y+1]=='+')
                    {
    
    
                        a[x][y+1]=' ';
                    }
                    if(ch=='s'&&a[x+1][y]=='+')
                    {
    
    
                        a[x+1][y]=' ';
                    }
                    if(ch=='w'&&a[x-1][y]=='+')
                    {
    
    
                        a[x-1][y]=' ';
                    }
                    system("pause");
                }
                flag:
                if((ch=='a'&&a[x][y-1]=='@')||(ch=='d'&&a[x][y+1]=='@')||(ch=='s'&&a[x+1][y]=='@')||(ch=='w'&&a[x-1][y]=='@'))
                {
    
    
                    system("cls");
                    coutAIO("你得到了钥匙!!");
                    yaoshi=true;
                    if(ch=='a'&&a[x][y-1]=='@')
                    {
    
    
                        a[x][y-1]=' ';
                    }
                    if(ch=='d'&&a[x][y+1]=='@')
                    {
    
    
                        a[x][y+1]=' ';
                    }
                    if(ch=='s'&&a[x+1][y]=='@')
                    {
    
    
                        a[x+1][y]=' ';
                    }
                    if(ch=='w'&&a[x-1][y]=='@')
                    {
    
    
                        a[x-1][y]=' ';
                    }
                    system("pause");
                }
                int d=rand()%100;
                bool s=false;
                if((d<=30&&ch=='a'&&a[x][y-1]=='D')||(d<=20&&ch=='d'&&a[x][y+1]=='D')||(d>=50&&ch=='s'&&a[x+1][y]=='D')||(d>=70&&ch=='w'&&a[x-1][y]=='D')||(d<=50&&a[x][y]=='D'))
                {
    
    
                    s=true;
                }
                if(s){
    
    
                    shengming--;
                }
                if((ch=='a'&&a[x][y-1]=='+')||(ch=='d'&&a[x][y+1]=='+')||(ch=='s'&&a[x+1][y]=='+')||(ch=='w'&&a[x-1][y]=='+'))
                {
    
    
                    coutAIO("你加了血!你加了一滴血!");
                    shengming+=1;
                    if(ch=='a'&&a[x][y-1]=='+')
                    {
    
    
                        a[x][y-1]=' ';
                    }
                    if(ch=='d'&&a[x][y+1]=='+')
                    {
    
    
                        a[x][y+1]=' ';
                    }
                    if(ch=='s'&&a[x+1][y]=='+')
                    {
    
    
                        a[x+1][y]=' ';
                    }
                    if(ch=='w'&&a[x-1][y]=='+')
                    {
    
    
                        a[x-1][y]=' ';
                    }
                    system("pause");
                }
                if((ch=='a'&&a[x][y-1]=='*')||(ch=='d'&&a[x][y+1]=='*')||(ch=='s'&&a[x+1][y]=='*')||(ch=='w'&&a[x-1][y]=='*'))
                {
    
    
                    coutAIO("你触发了炸药!你被炸药炸到了,扣血10滴");
                    shengming-=10;
                    if(ch=='a'&&a[x][y-1]=='*')
                    {
    
    
                        a[x][y-1]=' ';
                    }
                    if(ch=='d'&&a[x][y+1]=='*')
                    {
    
    
                        a[x][y+1]=' ';
                    }
                    if(ch=='s'&&a[x+1][y]=='*')
                    {
    
    
                        a[x+1][y]=' ';
                    }
                    if(ch=='w'&&a[x-1][y]=='*')
                    {
    
    
                        a[x-1][y]=' ';
                    }
                    system("pause");
                }
                if((ch=='a'&&a[x][y-1]=='-')||(ch=='d'&&a[x][y+1]=='-'))
                {
    
    
                    a[x][y]=' ';
                    coutAIO("你被刺穿了,扣血5滴,但穿越了");
                    shengming-=5;
                    system("pause");
                    if(ch=='a'&&a[x][y-1]=='-')
                    {
    
    
                        a[x][y-=2];
                    }
                    if(ch=='d'&&a[x][y+1]=='-')
                    {
    
    
                        a[x][y+=2];
                    }
                }
                if((ch=='a'&&a[x][y-1]=='0')||(ch=='d'&&a[x][y+1]=='0')||(ch=='s'&&a[x+1][y]=='0')||(ch=='w'&&a[x-1][y]=='0'))
                {
    
    
                    system("cls");
                    coutAIO("你在下一回合会死去!!");
                    shengming=0;
                    if(ch=='a'&&a[x][y-1]=='0')
                    {
    
    
                        a[x][y-1]=' ';
                    }
                    if(ch=='d'&&a[x][y+1]=='0')
                    {
    
    
                        a[x][y+1]=' ';
                    }
                    if(ch=='s'&&a[x+1][y]=='0')
                    {
    
    
                        a[x+1][y]=' ';
                    }
                    if(ch=='w'&&a[x-1][y]=='0')
                    {
    
    
                        a[x-1][y]=' ';
                    }
                    system("pause");
                }
                if(ch==27)break;
                if(ch==97&&a[x][y-1]==' '||a[x][y-1]=='D')
                {
    
    
                    a[x][y]=' ';
                    y--;
                    a[x][y]=p[r];
                }
                if(ch==100&&a[x][y+1]==' '||a[x][y-1]=='D')
                {
    
    
                    a[x][y]=' ';
                    y++;
                    a[x][y]=p[r];
                }
                if(ch==115&&a[x+1][y]==' '||a[x][y-1]=='D')
                {
    
    
                    a[x][y]=' ';
                    x++;
                    a[x][y]=p[r];
                }
                if(ch==119&&a[x-1][y]==' '||a[x][y-1]=='D')
                {
    
    
                    a[x][y]=' ';
                    x--;
                    a[x][y]=p[r];
                }
                system("cls");
                for(long long i=0;i<=oplen;i++)
			    {
    
    
			    	//cout<<i<<" ";
			    	cout<<a[i]<<endl;
				}
            }
            system("cls");
            if(f=='n')break;
            cout<<"you win!!!"<<endl;
            bushu=0;
            cout<<"按空格继续···";
            s++;
            yaoshi=false;
            ok='\0';
            while(ok=getch(),ok!=' ');
            system("cls");
            cout<<"是否继续(y/n)";
            while(f=getch(),f!='y'&&f!='n');
        }
    }
    dad:
    return 0;
}

一共1200多行代码,看似很多,实际还行
不知不觉字数就两万五了。。。
完结

猜你喜欢

转载自blog.csdn.net/m0_64036070/article/details/123154302