1.1[潜心创作]冒险游戏(MineCraft)不喜勿喷

已经很久没有发布博客了,好多人问我是不是都是死了?(当然我回复了他们)其实是在备战考试,最近也没怎么写程序,不过筹备了一款,不过当然没有其他人做的好。(当然原版MineCraft作者好像也是用c++做的哈,做的真的好好好!致敬。)

上代码

#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h>
#define x Sleep(200);
using namespace std;
string arrow=">>";
int initial_choose=1;
int mi=147,mj=50;
int level=1,exe=0;
string bag[100]={""};
int ge[100];
int g,cave;
int temp;
int oo=0;
char pifu[100]={'0','1','2','3','4','5','6','7','8','9','~','!','@','#','$','%','^','&','*','(',')','-','_','=','+','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','[',']','|','{','}',';',':','<','>','?'};
char random_map[500][500]={
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ", 
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ", 
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ", 
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ", 
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ", 
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ", 
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ", 
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "                                                                                                    ",
    "----------------------------------------------------------------------------------------------------",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "|                                                                                                  |",
    "----------------------------------------------------------------------------------------------------",
};
void To_continue()
{
    string tcontinue;
    tcontinue=getch();
    system("cls");
}
void i_choose(int arr)
{
    cout<<"           ";
    if(initial_choose==arr)
    {
        cout<<arrow;
    }
    else
    {
        cout<<"  ";
    }
}
void Print_initial()
{
    cout<<endl;
    cout<<"                         冒 险 游 戏"<<endl<<endl;
    cout<<"===================================================================="<<endl;
    cout<<"                W  S 选择    K 确定"<<endl;
    cout<<"===================================================================="<<endl<<endl<<endl<<endl;
    i_choose(1);
    cout<<"  1.开始游戏"<<endl<<endl;
    i_choose(2);
    cout<<"  2.游戏说明"<<endl<<endl;
    i_choose(3);
    cout<<"  3.换皮肤"<<endl<<endl;
    i_choose(4);
    cout<<"  4.退出游戏"<<endl<<endl;
    cout<<"===================================================================="<<endl;
    cout<<"                制作:Magnolia_tree"<<endl;
    cout<<"===================================================================="<<endl;
}
void set_tree()
{
    cout<<"系统生成树";
    cout<<"·";
    x;
    cout<<"·";
    x;
    cout<<"·";
    x;
    cout<<"·";
    x;
    cout<<"·";
    x;
    cout<<"·";
    cout<<endl;
    srand(time(0));
    while(g<100)
    {
        int treei=rand()%200+96,treej=rand()%98+1;
        if(treei==mi&&treej==mj)
        {
            continue;
        }
        g++;
        random_map[treei][treej]='T';
    }
    
}
void set_cave()
{
    cout<<"系统生成矿洞";
    cout<<"·";
    x;
    cout<<"·";
    x; 
    cout<<"·";
    x; 
    cout<<"·";
    x; 
    cout<<"·";
    x; 
    cout<<"·";
    x;
    cout<<endl;
    srand(time(0));
    while(cave<5)
    {
        int cavei=rand()%200+96,cavej=rand()%98+1;
        if(cavei==mi&&cavej==mj)
        {
            continue;
        }
        cave++;
        random_map[cavei][cavej]='C';
    }
}
void Play()
{
    system("cls");
    cout<<"系统生成随机种子";
    cout<<"·";
    x;
    cout<<"·";
    x;
    cout<<"·";
    x;
    cout<<"·";
    x;
    cout<<"·";
    x;
    cout<<"·";
    cout<<endl;
    set_tree();
    set_cave();
    system("cls");
    random_map[mi][mj]=pifu[oo];
    while(1)
    {
        int range=level*2+1;
        for(int i=mi-range;i<=mi+range;i++)
        {
            for(int j=mj-range;j<=mj+range;j++)
            {
                cout<<random_map[i][j];
            }
            cout<<endl;
        }
        cout<<"可视范围:"<<range<<"×"<<range<<endl;
        cout<<"等级:"<<level<<endl;
        cout<<"经验:"<<exe<<endl;
        cout<<"当前坐标位置:("<<mi-97<<","<<mj<<")"<<endl;
        string ope;
        ope=getch();
        if(ope=="w"&&random_map[mi-1][mj]!='-')
        {
            random_map[mi][mj]=' ';
            mi--;
            random_map[mi][mj]=pifu[oo];
        }
        if(ope=="a"&&random_map[mi][mj-1]!='|')
        {
            random_map[mi][mj]=' ';
            mj--;
            random_map[mi][mj]=pifu[oo];
        }
        if(ope=="s"&&random_map[mi+1][mj]!='-')
        {
            random_map[mi][mj]=' ';
            mi++;
            random_map[mi][mj]=pifu[oo];
        }
        if(ope=="d"&&random_map[mi][mj+1]!='|')
        {
            random_map[mi][mj]=' ';
            mj++;
            random_map[mi][mj]=pifu[oo];
        }
        if(ope=="b")
        {
            for(int i=0;i<temp;i++)
            {
                cout<<bag[i]<<"拥有数:"<<ge[i]<<endl;
            }
            cout<<"按任意键继续······";
            To_continue();
        }
        if(random_map[mi-1][mj]=='T'||random_map[mi][mj-1]=='T'||random_map[mi+1][mj]=='T'||random_map[mi][mj+1]=='T')
        {
            system("cls");
            for(int i=mi-range;i<=mi+range;i++)
            {
                for(int j=mj-range;j<=mj+range;j++)
                {
                    cout<<random_map[i][j];
                }
                cout<<endl;
            }
            cout<<"可视范围:"<<range<<"×"<<range<<endl;
            cout<<"是否砍树?(y/n)";
            string c;
            cin>>c;
            if(c=="y")
            {
                cout<<endl;
                cout<<"■20%"<<endl;
                Sleep(800);
                cout<<"■■40%"<<endl;
                Sleep(800);
                cout<<"■■■60%"<<endl;
                Sleep(800);
                cout<<"■■■■80%"<<endl;
                Sleep(800);
                cout<<"■■■■■100%!"<<endl; 
                cout<<"砍树成功!"<<endl<<"按任意键继续······";
                To_continue();
                if(random_map[mi-1][mj]=='T')
                {
                    random_map[mi-1][mj]=' ';
                }
                if(random_map[mi+1][mj]=='T')
                {
                    random_map[mi+1][mj]=' ';
                }
                if(random_map[mi][mj+1]=='T')
                {
                    random_map[mi][mj+1]=' ';
                }
                if(random_map[mi][mj-1]=='T')
                {
                    random_map[mi][mj-1]=' ';
                }
                exe+=20;
                bool have=false;
                for(int i=0;i<100;i++)
                {
                    if(bag[i]=="木头")
                    {
                        have=true;
                        ge[i]++;
                        g--;
                        if(g<=30)
                        {
                            set_tree();
                        }
                        break;
                    }
                }
                if(have==false)
                {
                    bag[temp]="木头";
                    ge[temp++]=1;
                }
                
            }
        }
        if(random_map[mi-1][mj]=='C'||random_map[mi][mj-1]=='C'||random_map[mi+1][mj]=='C'||random_map[mi][mj+1]=='C')
        {
            system("cls");
            for(int i=mi-range;i<=mi+range;i++)
            {
                for(int j=mj-range;j<=mj+range;j++)
                {
                    cout<<random_map[i][j];
                }
                cout<<endl;
            }
            cout<<"可视范围:"<<range<<"×"<<range<<endl;
            cout<<"是否进入矿洞?(y/n)";
            string c;
            cin>>c;
            if(c=="y")
            {
                cout<<endl;
                cout<<"敬请期待!"<<endl<<"按任意键继续······";
                To_continue();                
            }
        }
        if(exe==level*100)
        {
            cout<<"升级!"<<endl;
            exe=exe-(exe/100*100);
            level++;
            cout<<"按任意键继续······";
            To_continue();
        }
        system("cls");
    }
    
}
void operation_system()
{
    char cho;
    cho=getch();
    if((cho=='w'||cho=='W')&&initial_choose!=1)
    {
        initial_choose--;
    }
    if((cho=='s'||cho=='S')&&initial_choose!=3)
    {
        initial_choose++;
    }
    if(cho=='k'||cho=='K')
    {
        if(initial_choose==1)
        {
            Play();
        }
        if(initial_choose==2)
        {
            system("cls");
            cout<<endl<<endl<<endl<<endl<<endl<<"                                           ";
            cout<<"游戏·说明"<<endl<<"                                           ";
            cout<<"  w"<<endl<<"                                           ";
            cout<<"a s d  控制方向。"<<endl<<"                                           ";
            cout<<"T是树"<<endl<<"                                           ";
            cout<<"b打开背包,L关闭背包,u背包向上选项,d背包向下选项。";
            cout<<endl<<endl<<endl<<"按任意键继续······";
            To_continue();
        }
        if(initial_choose==3)
        {
            system("cls");
            string p_choose;
            while(1)
            {
                system("cls");
                cout<<endl<<endl<<endl<<endl<<endl<<"                                        a  d键换皮肤    k确定"<<endl<<endl<<endl<<endl;
                cout<<"                                                     "<<pifu[oo];
                p_choose=getch();
                if(p_choose=="k")
                {
                    break;
                }
                if(p_choose=="a")
                {
                    if(oo==0)
                    {
                        
                        oo=60;
                    }
                    else
                    {
                        oo--;
                    }
                }
                if(p_choose=="d")
                {
                    if(oo==60)
                    {
                        oo=0;
                    }
                    else
                    {
                        oo++;
                    }
                }
            }
        }
        if(initial_choose==4)
        {
            system("cls");
            cout<<endl<<endl<<endl<<endl<<endl<<"                               ";
            cout<<"拜拜!"<<endl<<"                               ";
            cout<<"制作:Magnolia_tree"<<endl<<endl<<endl<<endl<<endl;
            exit(1);
        }
        
    }
}
int main()
{
    while(1)
    {
        Print_initial();
        operation_system();
        system("cls");
    }
    return 0;
}
 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值