捉迷藏-公开内测

· · 闲话

闲话 勿举报

#include <bits/stdc++.h>
#include <unistd.h>
#include <windows.h>
#include <iostream>
#include <vector>
#include <string>
#include <iterator>
#include <fstream>
#include <ctime>
int mp[10][10];
using namespace std;
void mak()
{
    int w=0,g=0;
    srand(rand()+time(0));
    w=rand()%30;
    g=100-w;
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<10;j++)
        {
            cout<<"生成地图 x:"<<i<<" y:"<<j<<" "<<10*i+j<<"%"<<endl;
            srand(rand()+time(0));
            mp[i][j]=(rand()%3==0?1:0);
            if(mp[i][j]&&!w) mp[i][j]=1;
            else if(!mp[i][j]&&!g) mp[i][j]=0;
            if(mp[i][j]==0) w--;
            else g--;
            Sleep(rand()%3);
        }
    }
}
int ax,ay,bx,by;
int main()
{
    cout<<"捉迷藏-内测版本\n请勿外传 外传者举报-GuiHua"<<endl;
    Sleep(2000); 
    mak();
    Sleep(200);
    cout<<"生成地图 x:nan y:nan 100%"<<endl;
    Sleep(1000);
    do
    {
        srand(rand()+time(0));
        ax=rand()%10;
        srand(rand()+time(0));
        ay=rand()%10;
    }while(mp[ax][ay]!=1);
    int at=30;
    while(at)
    {
        bool y=0;
        system("cls");
        cout<<"藏-剩余"<<at<<"步"<<endl;
        cout<<"- 0 1 2 3 4 5 6 7 8 9"<<endl;
        for(int i=0;i<10;i++)
        {
            cout<<i<<' ';
            for(int j=0;j<10;j++)
            {
                if(i==ax&&j==ay) cout<<"H ";
                else
                {
                    switch(mp[i][j])
                    {
                        case 0:
                            cout<<"* ";
                            break;
                        case 1:
                            cout<<"# ";
                            break;
                        case 2:
                            cout<<"  ";
                            break;
                    }
                }
            }
            cout<<endl;
        }
        while(1)
        {
            char m=getchar();
            if(m=='w'||m=='W')
            {
                if(ax-1<0) cout<<"输入错误"<<endl;
                else if(mp[ax-1][ay]==1) cout<<"前方有墙"<<endl;
                else
                {
                    ax--;
                    at--;
                    break;
                }
            }
            else if(m=='s'||m=='S')
            {
                if(ax+1>9) cout<<"输入错误"<<endl;
                else if(mp[ax+1][ay]==1) cout<<"前方有墙"<<endl;
                else
                {
                    ax++;
                    at--;
                    break;
                } 
            }
            else if(m=='a'||m=='A')
            {
                if(ay-1<0) cout<<"输入错误"<<endl;
                else if(mp[ax][ay-1]==1) cout<<"前方有墙"<<endl;
                else
                {
                    ay--;
                    at--;
                    break;
                } 
            }
            else if(m=='d'||m=='D')
            {
                if(ay+1>9) cout<<"输入错误"<<endl;
                else if(mp[ax][ay+1]==1) cout<<"前方有墙"<<endl;
                else
                {
                    ay++;
                    at--;
                    break;
                } 
            }
            else if(m=='t'||m=='T')
            {
                at--;
                srand(rand()+time(0));
                if(rand()%5==0)
                {
                    at+=5;
                    cout<<"获得奖励"<<endl;
                }
                else cout<<"未获得奖励"<<endl;
                break;
            }
            else if(m=='h'||m=='H')
            {
                y=1;
                break;
            }
        }
        if(y) break;
    }
    system("cls");
    bool yes=0;
    int bt=30;
    while(bt)
    {
        bool y=0;
        system("cls");
        cout<<"捉-剩余"<<at<<"步"<<endl;
        cout<<"- 0 1 2 3 4 5 6 7 8 9"<<endl;
        for(int i=0;i<10;i++)
        {
            cout<<i<<' ';
            for(int j=0;j<10;j++)
            {
                if(i==bx&&j==by) cout<<"F ";
                else
                {
                    switch(mp[i][j])
                    {
                        case 0:
                            cout<<"* ";
                            break;
                        case 1:
                            cout<<"# ";
                            break;
                        case 2:
                            cout<<"  ";
                            break;
                    }
                }
            }
            cout<<endl;
        }
        while(1)
        {
            char m=getchar();
            if(m=='w'||m=='W')
            {
                if(bx-1<0) cout<<"输入错误"<<endl;
                else if(mp[bx-1][by]==1) cout<<"前方有墙"<<endl;
                else
                {
                    bx--;
                    bt--;
                    break;
                }
            }
            else if(m=='s'||m=='S')
            {
                if(bx+1>9) cout<<"输入错误"<<endl;
                else if(mp[bx+1][by]==1) cout<<"前方有墙"<<endl;
                else
                {
                    bx++;
                    bt--;
                    break;
                } 
            }
            else if(m=='a'||m=='A')
            {
                if(by-1<0) cout<<"输入错误"<<endl;
                else if(mp[bx][by-1]==1) cout<<"前方有墙"<<endl;
                else
                {
                    by--;
                    bt--;
                    break;
                } 
            }
            else if(m=='d'||m=='D')
            {
                if(by+1>9) cout<<"输入错误"<<endl;
                else if(mp[bx][by+1]==1) cout<<"前方有墙"<<endl;
                else
                {
                    by++;
                    bt--;
                    break;
                } 
            }
            else if(m=='t'||m=='T')
            {
                bt--;
                srand(rand()+time(0));
                if(rand()%5==0)
                {
                    bt+=5;
                    cout<<"获得奖励"<<endl;
                }
                else cout<<"未获得奖励"<<endl;
                break;
            }
            else if(m=='f'||m=='F')
            {
                bt--;
                if(ax==bx&&by==ay)
                {
                    cout<<"抓到了"<<endl;
                    yes=1;
                }
                else cout<<"未抓到"<<endl;
                break;
            }
        }
        if(yes) break;
    }
    system("cls");
    if(yes) cout<<"-抓者胜利-"<<endl;
    else cout<<"-被抓者胜利-"<<endl;
    Sleep(1000);
    return 0;
}