chinese 以前版本

发布时间 2023-07-24 19:44:40作者: Gao_l
/*
0.0.0
梦开始的地方
*/
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
int px=10,py=5,ma=0;
string jie[100005]={"这是墙壁,你不能通过","这是地面,上面似乎布满了灰尘"};
string dui[100005]={"墙","地","人"};
int home[5][15][15]={{
{},
{1,0,0,0,0,0,0,0,0,0},
{1,0,1,1,1,1,1,1,1,1,0},
{1,0,1,1,1,1,1,1,1,1,0},
{1,0,1,1,1,1,1,1,1,1,0},
{1,0,1,1,1,1,1,1,1,1,0},
{1,0,1,1,1,1,1,1,1,1,0},
{1,0,1,1,1,1,1,1,1,1,0},
{1,0,1,1,1,1,1,1,1,1,0},
{1,0,1,1,1,1,1,1,1,1,0},
{1,1,1,1,1,1,1,1,1,1,1},
}};
void print(){
    for(int i=1;i<=10;i++){
        for(int j=1;j<=10;j++){
            if(i==px&&j==py){
                cout << dui[2];
                continue;
            }
            cout << dui[home[ma][i][j]];
        }
        cout << "\n";
    }
    return ;
}
void step(){
    char c;
    if(c=getch()){
        if(c=='q'){
            cout << "请输入上下左右来查看旁边的情况\n";
            char f;
            f=getch();
            if(f=='w'){
                cout << jie[home[ma][px-1][py]];
            }else if(f=='s'){
                cout << jie[home[ma][px+1][py]];
            }else if(f=='a'){
                cout << jie[home[ma][px][py-1]];
            }else if(f=='d'){
                cout << jie[home[ma][px][py+1]];
            }
            cout << "\n输入任意键继续";
            f=getch();
        }
        else if(c=='w'&&px-1>0&&home[ma][px-1][py]!=0)px--;
        else if(c=='s'&&px+1<=10&&home[ma][px+1][py]!=0)px++;
        else if(c=='a'&&py-1>0&&home[ma][px][py-1]!=0)py--;
        else if(c=='d'&&py+1<=10&&home[ma][px][py+1]!=0 )py++;
        system("cls");
    }
    return ;
}

int main(){
    while(1){
        print();
        step();
    }
}