问题标题: 走迷宫

0
0
已解决
宋谦玉
宋谦玉
中级守护
中级守护
#include<iostream>
using namespace std;
int x,y,x1=9,y2=24;
int a[11][26]= {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
    {0,1,1,1,4,1,1,1,1,4,1,1,1,4,1,1,5,4,1,4,1,1,1,4,4,1},
    {0,1,3,4,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
    {0,1,0,5,4,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
    {0,1,0,1,1,1,4,1,1,1,1,4,1,1,1,0,5,1,1,1,1,5,1,1,0,1},
    {0,1,5,5,4,4,4,4,0,0,0,5,0,0,1,0,0,0,0,0,0,0,4,0,0,1},
    {0,1,5,0,0,1,0,5,0,0,0,5,0,0,1,0,1,0,1,0,1,0,1,1,0,1},
    {0,1,0,5,0,0,0,5,0,0,0,5,0,0,1,4,1,5,1,4,1,3,0,1,0,1},
    {0,1,4,0,0,1,0,5,0,0,0,4,0,0,0,0,0,0,0,0,0,4,0,1,0,1},
    {0,1,0,4,0,0,0,4,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,1,2,1},
    {0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,4,1,1,1,1,1,1,1,1},
};
int main() {
    cout<<"游戏玩法:wasd,▉:墙,←:终点,▓岩浆(有些岩浆是假的)"<<endl;
    system("pause");
    for(int i=1; i<=10; i++) {
        for(int j=1; j<=20; j++) {
            if(a[i][j]==0) {
                cout<<"  ";
            }
            if(a[i][j]==1) {
                cout<<"▉";
            }
            if(a[i][j]==2) {
                cout<<"♀";
                x=i;
                y=j;
                x1=i;
                y2=j;
            }
            if(a[i][j]==3) {
                cout<<"←";
            }
            if(a[i][j]==4) {
                cout<<"▓";
            }
            if(a[i][j]==5) {
                cout<<"▓";
            }
        }
        cout<<endl;
    }
    system("cls");
    while(1) {
        a[4][21]=5;
        a[1][16]=5;
        a[4][16]=5;
        a[3][3]=5;
        a[2][8]=5;
        a[3][8]=5;
        a[6][11]=5;
        a[7][7]=5;
        a[7][3]=5;
        a[7][17]=5;
        for(int i=1; i<=10; i++) {
            for(int j=1; j<=25; j++) {
                if(a[i][j]==0) {
                    cout<<"  ";
                }
                if(a[i][j]==1) {
                    cout<<"▉";
                }
                if(a[i][j]==2) {
                    cout<<"♀";
                    x=i;
                    y=j;
                }
                if(a[i][j]==3) {
                    cout<<"←";
                }
                if(a[i][j]==4) {
                    cout<<"▓";
                }
                if(a[i][j]==5) {
                    cout<<"▓";
                }
            }
            cout<<endl;
        }
        char c;
        cin>>c;
        if(c=='w') {
            if(a[x-1][y]==0||a[x-1][y]==5) {
                a[x][y]=0;
                a[--x][y]=2;
            } else if(a[x-1][y]==3) {
                cout<<"you win"<<(char)1<<(char)1<<(char)1;
                return 0;
            }
            if(a[x-1][y]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x][y+1]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x][y-1]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x+1][y]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
        }
        if(c=='a') {
            if(a[x][y-1]==0||a[x][y-1]==5) {
                a[x][y]=0;
                a[x][--y]=2;
            } else if(a[x][y-1]==3) {
                cout<<"you win"<<(char)1<<(char)1<<(char)1;
                return 0;
            }
            if(a[x-1][y]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x][y+1]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x][y-1]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x+1][y]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
        }
        if(c=='s') {
            if(a[x+1][y]==0||a[x+1][y]==5) {
                a[x][y]=0;
                a[++x][y]=2;
            } else if(a[x+1][y]==3) {
                cout<<"you win"<<(char)1<<(char)1<<(char)1;
                return 0;
            }
            if(a[x-1][y]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x][y+1]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x][y-1]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x+1][y]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
        }
        if(c=='d') {
            if(a[x][y+1]==0||a[x][y+1]==5) {
                a[x][y]=0;
                a[x][++y]=2;
            } else if(a[x][y+1]==3) {
                cout<<"you win"<<(char)1<<(char)1<<(char)1;
                return 0;
            }
            if(a[x-1][y]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x][y+1]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x][y-1]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
            if(a[x+1][y]==4) {
                a[x][y]=0;
                a[x1][y2]=2;
                x=x1;
                y=y2;
            }
        }
        system("cls");
    }
}

 


0
0
0
宋谦玉
宋谦玉
中级守护
中级守护

可以投稿地图,正在更新关卡版……

0
0
0
0
我要回答