1.3版本增加了工作台功能,本人试了几轮好像没什么问题,如果有问题,欢迎评论!
#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=99,mj=49;
int level=1,exe=0;
string bag[100]={""};
int ge[100];
int g,cave;
int temp;
int oo=0;
int Marki,Markj;
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<200)
{
int treei=rand()%200,treej=rand()%100;
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<40)
{
int cavei=rand()%200,cavej=rand()%100;
if(cavei==mi&&cavej==mj)
{
continue;
}
cave++;
random_map[cavei][cavej]='C';
}
}
bool mugun(string a,string b,string c,string d,string e,string f,string g,string h,string i)
{
if(a=="木板"&&b==c&&c==d&&d==e&&e==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(b=="木板"&&a==c&&c==d&&d==e&&e==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(c=="木板"&&a==b&&b==d&&d==e&&e==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(d=="木板"&&a==b&&b==c&&c==e&&e==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(e=="木板"&&a==b&&b==c&&c==d&&d==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(f=="木板"&&a==b&&b==c&&c==d&&d==e&&e==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(g=="木板"&&a==b&&b==c&&c==d&&d==e&&e==f&&f==h&&h==i&&i=="空")
{
return true;
}
if(h=="木板"&&a==b&&b==c&&c==d&&d==e&&e==f&&f==g&&g==i&&i=="空")
{
return true;
}
if(i=="木板"&&a==b&&b==c&&c==d&&d==e&&e==f&&f==g&&g==h&&h=="空")
{
return true;
}
return false;
}
bool muban(string a,string b,string c,string d,string e,string f,string g,string h,string i)
{
if(a=="木头"&&b==c&&c==d&&d==e&&e==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(b=="木头"&&a==c&&c==d&&d==e&&e==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(c=="木头"&&a==b&&b==d&&d==e&&e==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(d=="木头"&&a==b&&b==c&&c==e&&e==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(e=="木头"&&a==b&&b==c&&c==d&&d==f&&f==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(f=="木头"&&a==b&&b==c&&c==d&&d==e&&e==g&&g==h&&h==i&&i=="空")
{
return true;
}
if(g=="木头"&&a==b&&b==c&&c==d&&d==e&&e==f&&f==h&&h==i&&i=="空")
{
return true;
}
if(h=="木头"&&a==b&&b==c&&c==d&&d==e&&e==f&&f==g&&g==i&&i=="空")
{
return true;
}
if(i=="木头"&&a==b&&b==c&&c==d&&d==e&&e==f&&f==g&&g==h&&h=="空")
{
return true;
}
return false;
}
bool mujian(string a,string b,string c,string d,string e,string f,string g,string h,string i)
{
if(a=="木板"&&d=="木板"&&g=="木棍"&&b==c&&c==e&&e==f&&f==h&&h==i&&i=="空")
{
return true;
}
if(b=="木板"&&e=="木板"&&h=="木棍"&&a==c&&c==d&&d==f&&f==g&&g==i&&i=="空")
{
return true;
}
if(c=="木板"&&f=="木板"&&i=="木棍"&&a==b&&b==d&&d==e&&e==g&&g==h&&h=="空")
{
return true;
}
return false;
}
bool mugao(string a,string b,string c,string d,string e,string f,string g,string h,string i)
{
if(a=="木板"&&b=="木板"&&c=="木板"&&e=="木棍"&&h=="木棍"&&d==f&&f==g&&g==i&&i=="空")
{
return true;
}
return false;
}
bool mufu(string a,string b,string c,string d,string e,string f,string g,string h,string i)
{
if(a=="木板"&&b=="木板"&&d=="木板"&&e=="木棍"&&h=="木棍"&&c==f&&f==g&&g==i&&i=="空")
{
return true;
}
if(b=="木板"&&c=="木板"&&e=="木板"&&f=="木棍"&&i=="木棍"&&a==d&&d==g&&g==h&&h=="空")
{
return true;
}
return false;
}
void work()
{
cout<<"工作指南:"<<endl;
cout<<"随便一个格填入木头->4块木板"<<endl;
cout<<"随便一个格填入木板->2根木棍"<<endl;
cout<<"147/258/369顺序填入木板、木板、木棍->木剑"<<endl;
cout<<"12358顺序填入木板、木板,木板、木棍、木棍->木镐"<<endl;
cout<<"12458/23569顺序填入木板、木板、木板、木棍、木棍->木斧"<<endl;
cout<<"1 2 3"<<endl<<endl;
cout<<"4 5 6"<<endl<<endl;
cout<<"7 8 9"<<endl<<endl;
cout<<"请分别填入物品进行合成。(不需要放置物品的格子输入‘空’)"<<endl;
cout<<"1:";
string thing1;
cin>>thing1;
cout<<endl<<"2:";
string thing2;
cin>>thing2;
cout<<endl<<"3:";
string thing3;
cin>>thing3;
cout<<endl<<"4:";
string thing4;
cin>>thing4;
cout<<endl<<"5:";
string thing5;
cin>>thing5;
cout<<endl<<"6:";
string thing6;
cin>>thing6;
cout<<endl<<"7:";
string thing7;
cin>>thing7;
cout<<endl<<"8:";
string thing8;
cin>>thing8;
cout<<endl<<"9:";
string thing9;
cin>>thing9;
cout<<endl;
if(muban(thing1,thing2,thing3,thing4,thing5,thing6,thing7,thing8,thing9)==true)
{
bool h=false;
for(int i=0;i<temp;i++)
{
if(bag[i]=="木头")
{
if(ge[i]==0)
{
cout<<"您没有木头!(木头可以通过砍树获得)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
return ;
}
ge[i]--;
h=true;
break;
}
}
if(h==false)
{
cout<<"您没有木头!(木头可以通过砍树获得)"<<endl;
cout<<"按任意键继续······";
To_continue();
return ;
}
cout<<"合成结果:4块木板"<<endl;
cout<<"已放入背包!"<<endl;
bool have=false;
for(int i=0;i<100;i++)
{
if(bag[i]=="木板")
{
have=true;
ge[i]+=4;
break;
}
}
if(have==false)
{
bag[temp]="木板";
ge[temp++]=4;
}
}
if(mugun(thing1,thing2,thing3,thing4,thing5,thing6,thing7,thing8,thing9)==true)
{
bool h=false;
for(int i=0;i<temp;i++)
{
if(bag[i]=="木板")
{
if(ge[i]==0)
{
cout<<"您没有木板!(木板通过用木头合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
return ;
}
ge[i]--;
h=true;
break;
}
}
if(h==false)
{
cout<<"您没有木板!(木板通过用木头合成得到)"<<endl;
cout<<"按任意键继续······";
To_continue();
return ;
}
cout<<"合成结果:2根木棍"<<endl;
cout<<"已放入背包!"<<endl;
bool have=false;
for(int i=0;i<100;i++)
{
if(bag[i]=="木棍")
{
have=true;
ge[i]+=2;
break;
}
}
if(have==false)
{
bag[temp]="木棍";
ge[temp++]=2;
}
}
if(mujian(thing1,thing2,thing3,thing4,thing5,thing6,thing7,thing8,thing9)==true)
{
bool h=false,h1=false,tmp=false;
int tmp1;
for(int i=0;i<temp;i++)
{
if(bag[i]=="木板")
{
if(ge[i]<2)
{
cout<<"您没有足够的木板!(木板通过用木头合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
return ;
}
ge[i]-=2;
tmp=true;
tmp1=i;
h=true;
}
if(bag[i]=="木棍")
{
if(ge[i]==0)
{
cout<<"您没有木棍!(木棍通过用木板合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
if(tmp==true)
{
ge[tmp1]+=2;
}
return ;
}
ge[i]--;
h1=true;
}
}
if(h==false)
{
cout<<"您没有木板!(木板通过用木头合成得到)"<<endl;
cout<<"按任意键继续······";
To_continue();
return ;
}
if(h1==false)
{
cout<<"您没有木棍!(木棍通过用木板合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
return ;
}
cout<<"合成结果:木剑"<<endl;
cout<<"已放入背包!"<<endl;
bool have=false;
for(int i=0;i<100;i++)
{
if(bag[i]=="木剑")
{
have=true;
ge[i]++;
break;
}
}
if(have==false)
{
bag[temp]="木剑";
ge[temp++]=1;
}
}
if(mugao(thing1,thing2,thing3,thing4,thing5,thing6,thing7,thing8,thing9)==true)
{
bool h=false,h1=false,tmp=false;
int tmp1;
for(int i=0;i<temp;i++)
{
if(bag[i]=="木板")
{
if(ge[i]<3)
{
cout<<"您没有足够的木板!(木板通过用木头合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
return ;
}
ge[i]-=3;
tmp=true;
tmp1=i;
h=true;
}
if(bag[i]=="木棍")
{
if(ge[i]<2)
{
cout<<"您没有木棍!(木棍通过用木板合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
if(tmp==true)
{
ge[tmp1]+=3;
}
return ;
}
ge[i]-=2;
h1=true;
}
}
if(h==false)
{
cout<<"您没有木板!(木板通过用木头合成得到)"<<endl;
cout<<"按任意键继续······";
To_continue();
return ;
}
if(h1==false)
{
cout<<"您没有木棍!(木棍通过用木板合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
return ;
}
cout<<"合成结果:木镐"<<endl;
cout<<"已放入背包!"<<endl;
bool have=false;
for(int i=0;i<100;i++)
{
if(bag[i]=="木镐")
{
have=true;
ge[i]++;
break;
}
}
if(have==false)
{
bag[temp]="木镐";
ge[temp++]=1;
}
}
if(mufu(thing1,thing2,thing3,thing4,thing5,thing6,thing7,thing8,thing9)==true)
{
bool h=false,h1=false,tmp=false;
int tmp1;
for(int i=0;i<temp;i++)
{
if(bag[i]=="木板")
{
if(ge[i]<3)
{
cout<<"您没有足够的木板!(木板通过用木头合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
return ;
}
ge[i]-=3;
tmp=true;
tmp1=i;
h=true;
}
if(bag[i]=="木棍")
{
if(ge[i]<2)
{
cout<<"您没有木棍!(木棍通过用木板合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
if(tmp==true)
{
ge[tmp1]+=3;
}
return ;
}
ge[i]-=2;
h1=true;
}
}
if(h==false)
{
cout<<"您没有木板!(木板通过用木头合成得到)"<<endl;
cout<<"按任意键继续······";
To_continue();
return ;
}
if(h1==false)
{
cout<<"您没有木棍!(木棍通过用木板合成得到)"<<endl;
cout<<"按任意键继续······"<<endl;
To_continue();
return ;
}
cout<<"合成结果:木斧"<<endl;
cout<<"已放入背包!"<<endl;
bool have=false;
for(int i=0;i<100;i++)
{
if(bag[i]=="木斧")
{
have=true;
ge[i]++;
break;
}
}
if(have==false)
{
bag[temp]="木斧";
ge[temp++]=1;
}
}
cout<<"按任意键继续······";
To_continue();
}
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+1<<","<<mj+1<<")"<<endl;
string ope;
ope=getch();
if(ope=="w")
{
random_map[mi][mj]=' ';
if(mi==0)
{
mi=199;
}
else
{
mi--;
}
random_map[mi][mj]=pifu[oo];
}
if(ope=="a")
{
random_map[mi][mj]=' ';
if(mj==0)
{
mj=99;
}
else
{
mj--;
}
random_map[mi][mj]=pifu[oo];
}
if(ope=="s")
{
random_map[mi][mj]=' ';
if(mi==199)
{
mi=0;
}
else
{
mi++;
}
random_map[mi][mj]=pifu[oo];
}
if(ope=="d")
{
random_map[mi][mj]=' ';
if(mj==99)
{
mj=0;
}
else
{
mj++;
}
random_map[mi][mj]=pifu[oo];
}
if(ope=="b")
{
for(int i=0;i<temp;i++)
{
cout<<bag[i]<<"拥有数:"<<ge[i]<<endl;
}
cout<<"工作台拥有数:1(上限1)"<<endl;
cout<<"按任意键继续······";
To_continue();
}
if(ope=="q")
{
Marki=mi;
Markj=mj;
cout<<"标记目标点!"<<endl;
cout<<"按任意键继续······";
To_continue();
}
if(ope=="g")
{
random_map[mi][mj]=' ';
mi=Marki;
mj=Markj;
random_map[mi][mj]=pifu[oo];
system("cls");
continue;
}
if(ope=="o")
{
system("cls");
work();
}
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")
{
bool fast=false;
for(int i=0;i<temp;i++)
{
if(bag[i]=="木斧")
{
fast=true;
break;
}
}
cout<<endl;
if(fast==true)
{
cout<<"■20%"<<endl;
Sleep(1500);
cout<<"■■40%"<<endl;
Sleep(1500);
cout<<"■■■60%"<<endl;
Sleep(1500);
cout<<"■■■■80%"<<endl;
Sleep(1500);
cout<<"■■■■■100%!"<<endl;
}
else
{
cout<<"■20%"<<endl;
Sleep(2000);
cout<<"■■40%"<<endl;
Sleep(2000);
cout<<"■■■60%"<<endl;
Sleep(2000);
cout<<"■■■■80%"<<endl;
Sleep(2000);
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<=180)
{
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")
{
system("cls");
srand(time(0));
int temp=rand()%3+1;
cout<<"稀有指数:"<<temp<<"(最低1,最高3,稀有与难度成正比)";
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!=4)
{
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<<"q标记目标点,g传送目标点"<<endl<<" ";
cout<<"o打开工作台进行创作"<<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;
}