俩月前的代码,拿出来看看
(仅支持windows系统)
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int a[11][11],ans=0,fs=0,l=5,i,j,b,ans1=0,ans2=0,lv=1,q=100,n,m;
int s,x,sl,g=5,d=1,mj=0,sj=0,tj=0,zj=0,mg=0,tg=0,zg=0,k,ans3=0;
int ans4=0,my,sum=0,ans5=0,sl2,ans6=0,ans7=0,wj=0,ej=0,ans8=0;
int ans9=0,ans10=0,emc=0,eg=0;
string name;
int main(){
for(i=1;i<=10;i++){
cout<<"-";
Sleep(400);
}
cout<<"100%";
cout<<endl;
cout<<"请输入人名(英文,回车结束):"<<endl;
cin>>name;
cout<<"欢迎来到空岛生存"<<endl;
for(i=1;i<=10;i++){
for(j=1;j<=10;j++){
a[i][j]=0;
}
}
a[5][5]=1;
for(i=1;i<=50;i++){
cout<<"第"<<i<<"天"<<endl;
cout<<"金币数:"<<q<<"个"<<endl;
cout<<l<<"生命值"<<endl;
cout<<"攻击力:"<<g<<endl;
cout<<"挖掘:"<<wj<<endl;
cout<<"1.查看地图2.商店3.增加木板4.药水5.人物资料6.打怪物7.跳过一天8.附魔9.进入作者模式10.拆除木板11.下矿"<<endl;
cin>>ans;
if(ans==1){
for(s=1;s<=10;s++){
for(x=1;x<=10;x++){
cout<<a[s][x];
}
cout<<endl;
}
ans=0;
}
else if(ans==2){
cout<<"欢迎来到空岛商店"<<endl;
cout<<"1.木剑(20) 2.石剑(30) 3.铁剑(60) 4.钻石剑(120)"<<endl;
cout<<"5.木镐(30) 6.铁镐(50) 7.钻石镐(180)"<<endl;
cin>>ans1;
if(ans1==1){
if(q>=20){
cout<<"已获得"<<endl;
q-=20;
mj++;
ans1=0;
}else
cout<<"您还差"<<20-q<<"个金币"<<endl;
ans1=0;
}
else if(ans1==2){
if(q>=30){
cout<<"已获得"<<endl;
q-=30;
sj++;
ans1=0;
}else
cout<<"您还差"<<30-q<<"个金币"<<endl;
ans1=0;
}
else if(ans1==3){
if(q>=60){
cout<<"已获得"<<endl;
q-=60;
tj++;
ans1=0;
if(tj==1){
cout<<"获得称号:这不是铁剑么!"<<endl;
q+=15;
}
}else
cout<<"您还差"<<60-q<<"个金币"<<endl;
ans1=0;
}
else if(ans1==4){
if(q>=120){
cout<<"已获得"<<endl;
q-=120;
zj++;
ans1=0;
if(zj==1){
cout<<"获得称号:钻石剑!"<<endl;
q+=20;
}
}else
cout<<"您还差"<<120-q<<"个金币"<<endl;
ans1=0;
}
else if(ans1==5){
if(q>=30){
cout<<"已获得"<<endl;
q-=30;
mg++;
ans1=0;
}else
cout<<"您还差"<<30-q<<"个金币"<<endl;
ans1=0;
}
else if(ans1==6){
if(q>=50){
cout<<"已获得"<<endl;
q-=50;
tg++;
ans1=0;
if(tg==1){
cout<<"获得称号:这不是铁镐么"<<endl;
q+=10;
}
}else
cout<<"您还差"<<50-q<<"个金币"<<endl;
ans1=0;
}
else if(ans1==7){
if(q>=180){
cout<<"已获得"<<endl;
q-=180;
zg++;
ans1=0;
if(zg==1){
cout<<"获得称号:钻石镐!"<<endl;
q+=25;
}
}else
cout<<"您还差"<<180-q<<"个金币"<<endl;
ans1=0;
}
}
else if(ans==3){
for(s=1;s<=10;s++){
for(x=1;x<=10;x++){
cout<<a[s][x];
}
cout<<endl;
}
ans=0;
cout<<"请输入要增加的木板数量:(每个20)"<<endl;
cin>>sl;
for(k=1;k<=sl;k++){
n=0;
m=0;
cout<<"输入(y)(x)"<<endl;
cin>>n>>m;
if(q>=20){
emc+=20;
q-=20;
a[n][m]=1;
}else
cout<<"金币不够了!"<<endl;
}
for(s=1;s<=10;s++){
for(x=1;x<=10;x++){
cout<<a[s][x];
}
cout<<endl;
}
}
g=mj*2+sj*5+tj*10+zj*15+5+eg;
if(ans==4){
cout<<"1.生命药水(+1血量)(40) 2.攻击药水(+5攻击)(55) 3.综合药水(+1生命)(+6攻击)(90)"<<endl;
cin>>ans2;
if(ans2==1){
if(q>=40){
l++;
q-=40;
ans2=0;
cout<<"已获得药水"<<endl;
}else
cout<<"金币不够了!"<<endl;
ans2=0;
}
else if(ans2==2){
if(q>=55){
g=g+5;
q-=55;
ans2=0;
cout<<"已获得药水"<<endl;
}else
cout<<"金币不够了!"<<endl;
ans2=0;
}
else if(ans2==3){
if(q>=90){
l++;
g+=6;
q-=90;
ans2=0;
cout<<"已获得药水"<<endl;
}else
cout<<"金币不够了!"<<endl;
ans2=0;
}
}
else if(ans==5){
if(sum==1){
cout<<"章浩然"<<endl;
}else
cout<<name<<endl;
cout<<i<<"天"<<endl;
cout<<g<<"攻击力"<<endl;
cout<<wj<<"挖掘"<<endl;
cout<<l<<"生命值"<<endl;
cout<<q<<"个金币"<<endl;
cout<<"Lv."<<lv<<endl;
}
//2.
else if(ans==6){
cout<<"1.僵尸(35)2.小白(50)3.苦力怕(70)4.蜘蛛(60)5.末影龙(110)"<<endl;
cin>>ans9;
if(ans9==1){
cout<<"1.挑战2.逃跑"<<endl;
cin>>ans10;
if(ans10==1){
cout<<"正在攻击";
for(n=1;n<=3;n++){
cout<<".";
Sleep(300);
}
cout<<endl;
if(g>35){
cout<<"你赢了!+20金币"<<endl;
q+=20;
ans10=0;
emc+=20;
}else
cout<<"你输了!-1条生命"<<endl;
l--;
ans10=0;
}
else if(ans10==2){
cout<<"你成功逃脱!"<<endl;
ans10=0;
}
}
else if(ans9==2){
cout<<"1.挑战2.逃跑"<<endl;
cin>>ans10;
if(ans10==1){
cout<<"正在攻击";
for(n=1;n<=3;n++){
cout<<".";
Sleep(300);
}
cout<<endl;
if(g>50){
cout<<"你赢了!+30金币"<<endl;
q+=30;
ans10=0;
emc+=30;
}else
cout<<"你输了!-1条生命"<<endl;
l--;
ans10=0;
}
else if(ans10==2){
cout<<"你成功逃脱!"<<endl;
ans10=0;
}
}
else if(ans9==3){
cout<<"1.挑战2.逃跑"<<endl;
cin>>ans10;
if(ans10==1){
cout<<"正在攻击";
for(n=1;n<=3;n++){
cout<<".";
Sleep(300);
}
cout<<endl;
if(g>70){
cout<<"你赢了!+40金币"<<endl;
q+=40;
ans10=0;
emc+=40;
}else
cout<<"你输了!-2条生命"<<endl;
l-=2;
ans10=0;
}
else if(ans10==2){
cout<<"你成功逃脱!"<<endl;
ans10=0;
}
}
else if(ans9==4){
cout<<"1.挑战2.逃跑"<<endl;
cin>>ans10;
if(ans10==1){
cout<<"正在攻击";
for(n=1;n<=3;n++){
cout<<".";
Sleep(300);
}
cout<<endl;
if(g>60){
cout<<"你赢了!+35金币"<<endl;
q+=35;
ans10=0;
emc+=35;
}else
cout<<"你输了!-2条生命"<<endl;
l-=2;
ans10=0;
}
else if(ans10==2){
cout<<"你成功逃脱!"<<endl;
ans10=0;
}
}
else if(ans9==5){
cout<<"1.挑战2.逃跑"<<endl;
cin>>ans10;
if(ans10==1){
cout<<"正在攻击";
for(n=1;n<=3;n++){
cout<<".";
Sleep(300);
}
cout<<endl;
if(g>110){
cout<<"你赢了!+55金币"<<endl;
q+=55;
ans10=0;
emc+=55;
}else
cout<<"你输了!-3条生命"<<endl;
l-=3;
ans10=0;
}
else if(ans10==2){
cout<<"你成功逃脱!"<<endl;
ans10=0;
}
}
}
else if(ans==7){
q+=5;
}
else if(ans==8){
//eg为额外攻击力
cout<<"您有"<<mj<<"个木剑(1)"<<endl;
cout<<sj<<"个石剑(2)"<<endl;
cout<<tj<<"个铁剑(3)"<<endl;
cout<<zj<<"个钻石剑(4)"<<endl;
cout<<mg<<"个木镐(5)"<<endl;
cout<<tg<<"个铁镐(6)"<<endl;
cout<<zg<<"个钻石镐(7)"<<endl;
cout<<"要附魔哪个"<<endl;
cin>>ans3;
if(ans3==1){
if(mj==0){
cout<<"你没有木剑" <<endl;
ans3=0;
}else
cout<<"附魔火焰1.I(10)2.II(20)3.III(30)"<<endl;
cout<<"附魔力量4.I(20)5.II(50)6.III(80)"<<endl;
ans3=0;
cin>>ans4;
if(ans4==1){
if(q>=10){
cout<<"已附魔"<<endl;
q-=10;
eg+=4;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==2){
if(q>=20){
cout<<"已附魔"<<endl;
q-=20;
eg+=8;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==3){
if(q>=30){
cout<<"已附魔"<<endl;
q-=30;
eg+=16;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==4){
if(q>=20){
cout<<"已附魔"<<endl;
q-=20;
eg+=9;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==5){
if(q>=50){
cout<<"已附魔"<<endl;
q-=50;
eg+=30;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==6){
if(q>=80){
cout<<"已附魔"<<endl;
q-=80;
eg+=55;
}else
cout<<"金币不够了!"<<endl;
}
ans4=0;
}
if(ans3==2){
if(sj==0){
ans3=0;
cout<<"你没有石剑" <<endl;
}else
cout<<"附魔火焰1.I(10)2.II(20)3.III(30)"<<endl;
cout<<"附魔力量4.I(20)5.II(50)6.III(80)"<<endl;
ans3=0;
cin>>ans4;
if(ans4==1){
if(q>=10){
cout<<"已附魔"<<endl;
q-=10;
eg+=4;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==2){
if(q>=20){
cout<<"已附魔"<<endl;
q-=20;
eg+=8;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==3){
if(q>=30){
q-=30;
cout<<"已附魔"<<endl;
eg+=16;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==4){
if(q>=20){
q-=20;
cout<<"已附魔"<<endl;
eg+=9;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==5){
if(q>=50){
q-=50;
cout<<"已附魔"<<endl;
eg+=30;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==6){
if(q>=80){
q-=80;
cout<<"已附魔"<<endl;
eg+=55;
}else
cout<<"金币不够了!"<<endl;
}
ans4=0;
}
if(ans3==3){
if(tj==0){
ans3=0;
cout<<"你没有铁剑" <<endl;
}else
cout<<"附魔火焰1.I(10)2.II(20)3.III(30)"<<endl;
cout<<"附魔力量4.I(20)5.II(50)6.III(80)"<<endl;
ans3=0;
cin>>ans4;
if(ans4==1){
if(q>=10){
q-=10;
cout<<"已附魔"<<endl;
eg+=4;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==2){
if(q>=20){
q-=20;
cout<<"已附魔"<<endl;
eg+=8;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==3){
if(q>=30){
q-=30;
cout<<"已附魔"<<endl;
eg+=16;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==4){
if(q>=20){
q-=20;
cout<<"已附魔"<<endl;
eg+=9;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==5){
if(q>=50){
q-=50;
cout<<"已附魔"<<endl;
eg+=30;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==6){
if(q>=80){
q-=80;
cout<<"已附魔"<<endl;
eg+=55;
}else
cout<<"金币不够了!"<<endl;
}
ans4=0;
}
if(ans3==4){
if(zj==0){
ans3=0;
cout<<"你没有钻石剑" <<endl;
}else
cout<<"附魔火焰1.I(10)2.II(20)3.III(30)"<<endl;
cout<<"附魔力量4.I(20)5.II(50)6.III(80)"<<endl;
ans3=0;
cin>>ans4;
if(ans4==1){
if(q>=10){
q-=10;
cout<<"已附魔"<<endl;
eg+=4;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==2){
if(q>=20){
q-=20;
cout<<"已附魔"<<endl;
eg+=8;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==3){
if(q>=30){
q-=30;
cout<<"已附魔"<<endl;
eg+=16;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==4){
if(q>=20){
q-=20;
cout<<"已附魔"<<endl;
eg+=9;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==5){
if(q>=50){
q-=50;
cout<<"已附魔"<<endl;
eg+=30;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==6){
if(q>=80){
q-=80;
cout<<"已附魔"<<endl;
eg+=55;
}else
cout<<"金币不够了!"<<endl;
}
ans4=0;
}
//1.
if(ans3==5){
if(mg==0){
cout<<"你没有木镐" <<endl;
ans3=0;
}else
cout<<"附魔时运1.I(20)2.II(40)3.III(70)"<<endl;
cout<<"附魔速掘4.I(40)5.II(60)6.III(90)"<<endl;
ans3=0;
cin>>ans4;
if(ans4==1){
if(q>=20){
cout<<"已附魔"<<endl;
q-=10;
ej+=5;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==2){
if(q>=40){
cout<<"已附魔"<<endl;
q-=40;
ej+=10;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==3){
if(q>=70){
cout<<"已附魔"<<endl;
q-=70;
ej+=20;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==4){
if(q>=40){
cout<<"已附魔"<<endl;
q-=40;
ej+=15;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==5){
if(q>=60){
cout<<"已附魔"<<endl;
q-=60;
ej+=30;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==6){
if(q>=90){
cout<<"已附魔"<<endl;
q-=90;
ej+=55;
}else
cout<<"金币不够了!"<<endl;
}
ans4=0;
}
else if(ans3==6){
if(tg==0){
cout<<"你没有铁镐" <<endl;
ans3=0;
}else
cout<<"附魔时运1.I(20)2.II(40)3.III(70)"<<endl;
cout<<"附魔速掘4.I(40)5.II(60)6.III(90)"<<endl;
ans3=0;
cin>>ans4;
if(ans4==1){
if(q>=20){
cout<<"已附魔"<<endl;
q-=10;
ej+=5;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==2){
if(q>=40){
cout<<"已附魔"<<endl;
q-=40;
ej+=10;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==3){
if(q>=70){
cout<<"已附魔"<<endl;
q-=70;
ej+=20;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==4){
if(q>=40){
cout<<"已附魔"<<endl;
q-=40;
ej+=15;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==5){
if(q>=60){
cout<<"已附魔"<<endl;
q-=60;
ej+=30;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==6){
if(q>=90){
cout<<"已附魔"<<endl;
q-=90;
ej+=55;
}else
cout<<"金币不够了!"<<endl;
}
ans4=0;
}
if(ans3==7){
if(zg==0){
cout<<"你没有钻石镐" <<endl;
ans3=0;
}else
cout<<"附魔时运1.I(20)2.II(40)3.III(70)"<<endl;
cout<<"附魔速掘4.I(40)5.II(60)6.III(90)"<<endl;
ans3=0;
cin>>ans4;
if(ans4==1){
if(q>=20){
cout<<"已附魔"<<endl;
q-=10;
ej+=5;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==2){
if(q>=40){
cout<<"已附魔"<<endl;
q-=40;
ej+=10;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==3){
if(q>=70){
cout<<"已附魔"<<endl;
q-=70;
ej+=20;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==4){
if(q>=40){
cout<<"已附魔"<<endl;
q-=40;
ej+=15;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==5){
if(q>=60){
cout<<"已附魔"<<endl;
q-=60;
ej+=30;
}else
cout<<"金币不够了!"<<endl;
}
else if(ans4==6){
if(q>=90){
cout<<"已附魔"<<endl;
q-=90;
ej+=55;
}else
cout<<"金币不够了!"<<endl;
}
ans4=0;
}
}
wj=mg*10+tg*25+zg*40+eg;
if(ans==9){
cout<<"请输入密码:"<<endl;
cin>>my;
if(my==5332){
//密码为‘5332’
if(sum>=1){
cout<<"您已进入作者模式"<<endl;
}else
cout<<"已进入作者模式"<<endl;
q=999999;
sum+=1;
lv=999;
l=999;
g=999;
j=999;
}else
cout<<"密码错误!"<<endl;
}
else if(ans==10){
for(s=1;s<=10;s++){
for(x=1;x<=10;x++){
cout<<a[s][x];
}
cout<<endl;
}
cout<<"输入拆除木板数量"<<endl;
cin>>ans5;
for(sl2=1;sl2<=ans5;sl2++){
cout<<"请输入(y)(x):"<<endl;
cin>>n>>m;
a[n][m]=0;
q+=5;
cout<<"增加5个金币"<<endl;
n=0;
m=0;
}
ans5=0;
for(s=1;s<=10;s++){
for(x=1;x<=10;x++){
cout<<a[s][x];
}
cout<<endl;
}
}
else if(ans==11){
cout<<"挖掘:1.铁矿(wj>=30)2.金矿(wj>=60)3.钻石矿(wj>=90)"<<endl;
cin>>ans8;
if(ans8==1){
if(wj>=30){
emc+=30;
q+=10;
cout<<"成功挖掘,增加10金币!"<<endl;
ans8=0;
}else
cout<<"您的稿子差点离开这美丽的世界"<<endl;
q-=20;
ans8=0;
}
if(ans8==2){
if(wj>=60){
emc+=40;
q+=20;
cout<<"成功挖掘,增加20金币!"<<endl;
ans8=0;
}else
cout<<"您的稿子差点离开这美丽的世界"<<endl;
q-=30;
ans=8;
}
if(ans8==3){
if(wj>=90){
emc+=50;
q+=35;
cout<<"成功挖掘,增加35金币!"<<endl;
ans8=0;
}else
cout<<"您的稿子差点离开这美丽的世界"<<endl;
q-=40;
ans=8;
}
}
lv=emc/50;
q+=10;
ans=0;
g=g+eg;
cout<<"--------------------------------------------------------------------------------------------------"<<endl;
//每天的分割线
if(l<=0){
system("color 04");
cout<<"您输了!"<<endl;
if(sum==1){
cout<<"章浩然"<<endl;
}else
cout<<name<<endl;
cout<<"Lv."<<lv<<endl;
cout<<q+lv+g<<endl;
Sleep(5000);
return 0;
}
}
system("color 02");
cout<<"恭喜";
if(sum==1){
cout<<"xxx"<<"成功通关!"<<endl;
}else
cout<<"恭喜"<<name<<"成功通关!"<<endl;
cout<<"Lv."<<lv<<endl;
cout<<q+lv+g<<endl;
Sleep(5000);
//最终得分
return 0;
}
制作C++文字游戏