其他分享
首页 > 其他分享> > 人生之路1.18.05优化

人生之路1.18.05优化

作者:互联网

神殿地图扩大至40*100(原先是40*40),并增加技能“瞬移”。

地图数组请自行改成41*101

原先是mm[41][41],改成mm[41][101]即可(开大一丢丢也可以)

代码如下

void SD()
{
	things[193]++; 
	use(75);
	int i,j,k,n,m,a,b;
	cout<<"生成地图中...";
	while(1)
	{
	for(i=0;i<40;i++)
	  for(j=0;j<101;j++)
	    mm[i][j]=0;
	switch(things[21])
	  {
	  	case 1:m=random(230,290);break;
	  	case 2:m=random(281,330);break;
	  	case 3:m=random(325,359);break;
	  	case 4:m=random(341,430);break;
	  }
	for(i=1;i<=m;i++)
	  {
	    do
	      {
	    	j=random(1,39);
	    	k=random(1,99);
		  }
		while(mm[j][k]!=0);
		mm[j][k]=3;
	  }
	int q=random(500,900);
	for(i=1;i<=q;i++)
	  {
	  	do
	  	  {
	  	  	j=random(1,39);
	  	  	k=random(1,99);
		  }
		while(mm[j][k]!=0);
		mm[j][k]=1;
	  }
	do
	  {
	  	j=random(1,39);
	  	k=random(1,99);
	  }
	while(mm[j][k]!=0||(j==1||k==1));
	mm[j][k]=2;
	a=j,b=k;
	teea=1;
	  break;
	}
	cls(); 
	coutwhat(0,0,40,0,"#");
	coutwhat(0,0,0,100,"#");
	coutwhat(40,0,40,100,"#");
	coutwhat(0,100,40,100,"#");
	for(i=1;i<40;i++)
	  {
	  	gotoxy(i,1);
	    for(j=1;j<100;j++)
	      {
	      	color(7);
	      	if (mm[i][j]==2)
	      	  color(1);
	        printf("%c",sd[mm[i][j]]);
	      }
	    printf("\n");
	  }
	int x=1,y=1,zd=5,sy=3;
	int _3=1;
	bool find=1;
	while(find)
	{
		gotoxy(x,y);
		color(3);
		cout<<"o";
		gotoxy(43,0);
		cout<<"B 宝藏 o你 #墙 X陷阱\n";
		cout<<"WASD移动,E退出,Q使用炸弹 V使用瞬移(下次移动时朝那个方向移动3格)\n";
		cout<<"炸弹剩余:"<<zd<<"瞬移技能剩余:"<<sy<<endl;
		printf("你(%d,%d) 宝藏(%d,%d)",x,y,a,b); 
	  	char l=_getch();
	  	if (l=='w'||l=='s'||l=='a'||l=='d')
	  	  {
	  	    gotoxy(x,y);
	  	    cout<<" "; 
	  	  }
	  	switch(l)
	  	  {
	  	  	case 'w':if (x-_3>0&&mm[x-_3][y]!=1) x-=_3,_3=1;break;
	  	  	case 's':if (x+_3<=40&&mm[x+_3][y]!=1)x+=_3,_3=1;break;
	  	  	case 'a':if (y-_3>0&&mm[x][y-_3]!=1)y-=_3,_3=1;break;
	  	  	case 'd':if (y+_3<=100&&mm[x][y+_3]!=1)y+=_3,_3=1;break;
	  	  	case 'q':
	  	  	  {
				if (zd)
	  	  	  		  {
	  	  	  		  	for(i=x-1;i<=x+1;i++)
	  	  	  		  	  for(j=y-1;j<=y+1;j++)
	  	  	  		  	    if (mm[i][j]==1||mm[i][j]==3)
	  	  	  		  	      {
	  	  	  		  	        mm[i][j]=0;
	  	  	  		  	        cout<<" ";
	  	  	  		  	        gotoxy(i,j);
	  	  	  		  	      }
	  	  	  		  	zd--;
					  }
					break;
			  }
			case 'v':if (sy) sy--,_3=3;break;
			case 'e':if (things[193]-things[194]-things[196]>=50)hdcj(3);Getmap();cls();return;
		  }
		switch(mm[x][y])
		  {
		  	case 2:
		  		{
		  			int c,d;
		  			c=rand()%3+4;
		  			d=rand()%15+5;
		  			++things[194]; 
		  			printf("恭喜你找到了宝藏!获得:%s*%d",fsn[c].c_str(),d);
		  			fost[c]+=d;
		  			c=rand()%10000+1000;
		  			d=rand()%8000+500;
		  			cout<<' '<<"XP*"<<c<<" money*"<<d;
		  			things[1]+=c;
		  			things[7]+=d;
		  			find=false;
		  			break;
				}
			case 3:
				{
					happened+=(name+"在探索神殿时踩中陷阱/");
					++things[196];
					Die();
					return;
				}
		  }
	}
	gs();
	Getmap();
}

新增成就【逃跑专家】

string cj[100]=
{"",
//  1      		2			3				4			5
  "旅程的起点","2^11","逃跑专家","就是这么任性","学习狂魔",
//	6		7			8			9			10
  "考试","富甲一方","电脑高手","学霸再现江湖","登山游记",
//	11			12			13				14			15
  "天上的城市","钻石!","挖矿时间到","可怕的影子","这就是作者",
//	16		17		18				19			20
  "老赌徒","富二代","真是个肉盾","出击时间到!","光头强",
//	21				22			23			24			25
  "是时候继续挖矿了","怪物猎人","用钻石包裹我","超级英雄","虚空来客",
//	26			27			28				29				30
  "附魔师","量子幽灵在手","搬砖工","长线挂机","现在没空",
//	31			   32				33		34			35			36
  "黑漆漆的树林","鸭蛋还是鸡蛋","结束了?","旅途的终点","梦境回魂","获得升级",
// 37	38			   39		40		41			42			43 
  "赌神","甜蜜的梦","斗牛士","扫雷战士","妙手回春","时间恶魔","再一次到达终点",
//44		45			46 			47			48				49			50
  "弹无虚发","主宰全场","恶魔终结者","游戏高手","怪物狩猎完成","资深游戏专家","人生赢家",
};
string what_do[100]=
{"",
  "进入游戏","玩2048成功一次","在神殿逃跑50次","开局时连点4个“否”","看过所有的学习提示(共27条)",
  "考一次试","拥有的零花钱超过100000","某次打字游戏速度超过250字/分钟","考一次100分","某一次登山成功",
  "去到天空之境","获得一颗钻石","获得一把铁镐","遇见一次游魂","遇见一次作者",
  "去赌场进行一次“赌大小”","在小学阶段零花钱数量达到1000000","血量超过1000","拥有一把铁剑","砍一次树",
  "打造一把钻石镐","击杀一次僵尸或骷髅","拥有一套钻石套装(注:最后做鞋子)","拥有一套英雄套装(注:最后做鞋子)","拥有一套虚空套装(注:最后做鞋子)",
  "拥有一个附魔台","拥有一把量子剑","去搬一次砖","获取一次至少8小时的挂机收益","连续48小时不上线,再次领取挂机收益即可获得",
  "去一次小树林","考一次0分","进入第六章","通过第六章","???","升一次级",
  "猜大小连中5次","在家睡一次觉","猎杀一头牛","某次“扫雷”成功","请“神医”为你治疗一次", "用“恶魔沙漏”修改一次时间轨迹", 
  "第二次击败MCYH","连续打猎打中20次","在竞技场连胜15局","终结恶魔领主","在创建游戏后的10分钟之内通关","累计击杀50只怪物",
  "使用过游戏中所有功能(除了隐藏功能一共74个)", "完成所有成就(隐藏成就除外)并且等级达到50级以上",
};

改良Sout函数,现在只要按下空格键即可直接输出完

void Sout(string n)
{
	for(int i=0;i<n.size();i++)
	  {
	  	cout<<n[i];
	  	Sleep(sudu);
	  	if (kbhit())
	  	  if (getch()==' ')
		    {
		  	  cout<<n.substr(i+1,n.size()-i);
		  	  return;
		    }
	  }
} 

新增成就数量统计

新版获得成就函数如下

void hdcj(int i)
{
	use(1);
	if (things[i+99])
	  return;
	things[195]++;
	gotoxy(48,0);
	printf("%s获得了成就:【%s】",name.c_str(),cj[i].c_str());
	things[i+99]=1;
	happened+=(name+"获得了成就【"+cj[i]+"】/"); 
	Write_File();
	Sleep(3000);
} 

家-查看状态优化,现在可以查看关于成就和神殿的数据

从case '5'开始的代码如下

case '5':cls();
	    		{
	    		use(14);
	    		const string w[]=
	    		{"关卡进度:",
	    		"经验值:",
	    		"健康值:",
	    		"水分:",
	    		"饱食度:",
	    		"攻击力:",
	    		"防御力:",
	    		"零花钱:",
	    		"精力:",
	    		"等级:",
	    		"年龄:",
				};
				string nan[5]={"","简单模式","中等模式","困难模式","炼狱模式"};
				string xs[2]={"文字","图像"};
				cout<<"姓名:"<<name<<'\n';
	    		for(i=0;i<=10;i++)
	    		if (i==1)
	    		  printf("%s%d/%lld\n",w[i].c_str(),things[i],sj[things[9]+1]);
	    		else
	    		  printf("%s%d\n",w[i].c_str(),things[i]);
	    		printf("挂机上限:%d小时\n",things[30]/60);
				printf("挂机收益:%d元/分钟\n",things[29]); 
				printf("达到过的最高等级:%d\n",things[36]);
				printf("死亡次数:%d\n",things[190]);
				printf("杀怪次数:%d\n",things[83]);
				printf("竞技场连胜次数:%d\n",things[82]);
				printf("银行卡余额:%d\n",things[93]);
				printf("显示形式:%s\n",xs[things[188]].c_str()); 
	    		cout<<"考试最高分:"<<things[20]<<'\n';
	    		cout<<"游戏难度:"<<nan[things[21]]<<'\n';
	    		cout<<"去神殿次数:"<<things[193]<<'\n';
	    		cout<<"在神殿被炸死次数:"<<things[196]<<'\n';
	    		cout<<"找到神殿宝藏次数:"<<things[194]<<'\n';
	    		cout<<"在神殿逃跑次数:"<<things[193]-things[194]-things[196]<<'\n';
	    		cout<<"成就完成数量:"<<things[195]<<"/50"<<'\n';
	    		cout<<"游戏开始时间:"<<kaishi<<'\n';
	    		time_t now;
	    		time(&now);
	    		cout<<"现在时间:"<<now<<'\n';
	    		cout<<"存档累计时间:"<<(now-kaishi)/86400<<"天"<<(now-kaishi)%86400/3600<<"小时"<<(now-kaishi)%3600/60<<"分钟"<<(now-kaishi)%60<<"秒"<<"("<<now-kaishi<<")"<<'\n';
	    		cout<<"存档号:"<<things[185]<<'\n';
	    		cout<<"存档名:"<<filename[things[185]]<<'\n';
				printf("按任意键返回");
	    		gs();
				break;
			}

新版本号:v1.18.05.248103

标签:case,一次,string,05,mm,things,之路,50,1.18
来源: https://blog.csdn.net/MCYH0206/article/details/118633096