L V 3.

代码

#include<wxn自制的头文件.h>
/***制作者:CSDN wxn小学***/
using namespace std;
bool Sh;
struct my
{
	string name;
	string Validation_strings;
	string yd;
	long long password;
	bool condition,zdcd,sy;
	int species;
}my;

struct cdd//存读档结构体 
{
	/***存档***/ 
	void cd()
	{
		ofstream OutFile("存档.游戏");//如果你想偷看我也无话可说 。 
    	OutFile<<my.name<<endl;//       那样还有意思吗?你应该扪心自问。 
		OutFile<<my.password<<endl;
		OutFile<<my.Validation_strings<<endl; 
		OutFile<<my.condition<<endl;
		OutFile<<my.zdcd<<endl;
		OutFile<<my.sy<<endl;
		OutFile<<my.yd<<endl;
		OutFile<<my.species<<endl;
    	OutFile.close();
	    return;
	}

	/***读档***/ 
	void dd()
	{
		ifstream InFile("存档.游戏");
    	InFile>>my.name;
		InFile>>my.password;
		InFile>>my.Validation_strings;
		InFile>>my.condition;
		InFile>>my.zdcd;
		InFile>>my.sy;
		InFile>>my.yd;
		InFile>>my.species;
		if(my.Validation_strings!="-----------请不要作弊-----------")
		{
			printf("作弊可耻");
			exit(0);
		} 
    	return;
	}
	
}cdd;

/***声音***/
void sy()
{
	if(my.sy==true)
	{
		if(my.yd=="随机")
		{
			int a;
			a=rand()%7+1;
			if(a==1)Beep(440,200);
			if(a==2)Beep(493.88,200);
			if(a==3)Beep(554.37,200);
			if(a==4)Beep(587.33,200);
			if(a==5)Beep(659.33,200);
			if(a==6)Beep(739.99,200);
			if(a==7)Beep(830.61,200);
		} 
		if(my.yd=="do  ")Beep(440,200);//"  "是为了掩盖 “机 ”字 
		if(my.yd=="re")Beep(493.88,200);
		if(my.yd=="mi")Beep(554.37,200);
		if(my.yd=="fa")Beep(587.33,200);
		if(my.yd=="so")Beep(659.33,200);
		if(my.yd=="la")Beep(739.99,200);
		if(my.yd=="si")Beep(830.61,200);
	}
	return;
}

/***自动存档***/
void zdcd()
{
	if(my.zdcd==true)cdd.cd();
	return;
}

/***密码验证***/
void password_authentication()
{
	o:
	cls;
	ST("密 码 认 证");
	yanse(2,0);
	printf("〓             〓\n");
	yanse(15,0);
	gotoxy(3,0);
	printf("忘记密码 或 新手:输入0");
	gotoxy(4,0);
	yanse(12,0);
	printf("不要冒充 ");
	yanse(6,0),
	printf("新手");
	yanse(13,0);
	gotoxy(0,3);
	prin("密 码 认 证",100,0);
	yanse(15,0);
	gotoxy(1,0);
	prin("输入密码:\n",10,0);
	//gotoxy(2,0);这里我移动光标搞不懂,有偏差,干脆不用了 ,cao!,换 \n 
	yanse(15,0);
	fflush(stdin);//清除缓存区
	int a;
	cin>>a;
	if(a==0)
	{
		cls;
		if(my.condition==false)
		{
			printf("检测到是新手\n");
			sep(1000);
			printf("设定名称为:\n");
			fflush(stdin);//清除缓存区
            cin>>my.name;
			printf("设定密码为:\n");
            scanf("%d",&my.password);
            zdcd();
            printf("设置成功!\n");
            sep(1000);
            cls; 
			return;
		}
		else
		{
			wt:
			cls;
			string d;
			printf("用户名:");
			cin>>d;
			if(d!=my.name)
			{
				cls;
				printf("未找到该用户!");
				sep(2000);
				goto wt;
			}
			cls;
			int c;
			cls;
			printf("请接收6位验证码(3s)");
			sep(2000);
			cls;
			int randomnumber=rand()%1000000+100000;
			printf("%d(验)\n",randomnumber);
			sep(3000);
			cls;
			printf("输入验正码\n");
			scanf("%d",&c);
			cls;
			if(c==randomnumber)
			{
			    cls;
				printf("\a验证通过\a\n");
				printf("你的密码:%d",my.password);
				sep(5000);
				cls;
				return;
			}	
			else
			{
				cls;
				printf("!!!");
				sep(1000);
				goto wt;
			}
	    }
	}
	else if(a==my.password)
	{
		cls;
		printf("\a验证通过\a");
		sep(1000);
		cls;
		return;
	}
	else
	{
		cls;
		printf("错误!");
		sep(1000);
		goto o;
	}
}

/***游戏一***/
void game1()
{
	int dx,dy;
	int mx,my;
	int sea[5][5];
	int ms=0;
	int maxms=0;
	int healthy=1;
	int sd=500;
	ms=0;
	char ch;
	for(int i=0;i<5;i++)
	{
		for(int j=0;j<5;j++)
		{
			sea[i][j]=0;
		}
	}
	sea[4][1]=8;
	mx=4;
	my=1;
	printf("+躲+\n");
	printf("+避+\n");
	printf("+物+\n");
	printf("+体+\n");
	printf("+..+\n");
	pause;
	sy();
	cls;
	printf("↑↓←→移动\nenter前进\n300米胜利\nEsc退出\n");
	pause;
	sy();
	dx=1;
	cls;
	while(healthy>0)
	{
		for(int i=0;i<90;i++)
		{
			if(kd(VK_UP))
			{
				if(mx>0)
				{
					sy();
					mx--;
				}
				break;
			}
			if(kd(VK_DOWN))
			{
				if(mx<4)
				{
					sy();
					mx++;
				}
				break;
			}
			if(kd(VK_LEFT))
			{
				if(my>0)
				{
					sy();
					my--;
				}
				break;
			}
			if(kd(VK_RIGHT))
			{
				if(my<4)
				{
					sy();
					my++;
				}
				break;	
			} 
			yanse(15,0);
			printf("%d米\n",ms);
			for(int i=0;i<5;i++)
			{
				for(int j=0;j<5;j++)
				{
					if(i==mx&&j==my)
					{
						yanse(9,0);
						printf("A");
					}
					else if(i==dx&&j==dy)
					{
						yanse(12,0);
						printf("O");
					}
					else
					{
						yanse(8,0);
						printf("*");
					}
				}
			printf("\n");
			}
			gotoxy_0(0,0);
		}
		if(kd(VK_RETURN))
		{
			ms+=1;
			if(dx==5)
			{
				dx=0;
				int a=rand()%2+1;
				if(a==1)
				{
					dy=my;
				}
				else dy=rand()%5+1;
			}
			else
			{
				dx++;
			}
			if(dy==my&&dx==mx)
			{
				healthy--;
			}
			if(ms==300)
			{
				Beep(830.61,500);
				Beep(830.61,500);
				Beep(830.61,500);
				Beep(830.61,500);
				cls;
				yanse(1,0);
				printf("胜利~金币加10");
				sep(2000);
				yanse(15,0);
				Sh=true;
				return;
			}
			
		}
		if(kd(VK_ESCAPE))
		{
			sy();
			sep(100);
			cls;
			yanse(15,0);
			return;
		}	
	}
	cls;
	yanse(15,0);
	gotoxy(4,8);
	printf("%d米",ms);
	gotoxy(5,9);
	printf("加油!"); 
	Sleep(2000);
	cls;
	return;
}

/***游戏2***/
void game2()
{
	int probability;
	int a;
	while(1)
	{
		probability=rand()%100+1;
		printf("机率:%d\nenter开枪\nEsc退出\n",probability);
		for(int i=0;i<9;i++)
		{
			if(kd(VK_RETURN))
			{
				sy();
				a=rand()%100+1;
				if(a<=probability)
				{
					my.species++;
					printf("你赢了,金币加一\n金币:%d",my.species);
					sep(2000);
					cls;
					zdcd(); 
				}
			}
			else if(kd(VK_ESCAPE))
			{
				sy();
				sep(100);
				cls;
				yanse(15,0);
				return;
			}
			else 
			{
				a=rand()%100+1;
				if(a<=probability)//相同的机率射中你 
				{
					my.species--;
					printf("你死了,金币减一\n金币:%d",my.species);
					sep(2000);
					cls;
					zdcd(); 
				}
				sep(95);
			}
		}
	}
	return;
}

/***游戏***/
void game()
{
	while(1)
	{
		ST("游戏");
		gotoxy_0(0,0);
		gotoxy(3,7);
		printf("1|躲避物体");
		gotoxy(4,7);
		printf("2|王牌射手");
		gotoxy(5,9);
		printf("3|返回");
		if(kd('1')||kd(VK_NUMPAD1))
		{
			sy();
			sep(100);
			cls;
			game1();
			if(Sh==true)
			{
				Sh=false;
				my.species+=10;
				zdcd();
			}
			cls;
		}
		if(kd('2')||kd(VK_NUMPAD2))
		{
			sy();
			sep(100);
			cls;
			game2();
			cls;
		} 
		if(kd('3')||kd(VK_NUMPAD3))
		{
			sy();
			sep(300);
			cls;
			break;
		}
	}
	return;
} 
/***MIF***/
void MIF()
{
	while(1)
	{
		ST("界面");
		gotoxy_0(0,0);
		gotoxy(3,7);
		printf("1|进入游戏");
		gotoxy(4,9);
		printf("2|选项");
		gotoxy(5,7);
		printf("3|放松音乐");
		gotoxy(6,9);
		printf("4|退出"); 
		if(kd('1')||kd(VK_NUMPAD1))
		{
			sy();
			sep(100);
			cls;
			game();
		}
		if(kd('2')||kd(VK_NUMPAD2))
		{
			sy();
			sep(100);
			cls;
			sys("mode con cols=24 lines=11");
			while(1)
			{
				ST("选项");
				gotoxy_0(0,0);
				cout<<my.name<<"的选项:"<<endl;
				gotoxy(2,5);
				printf("1.自动存档  ");
				if(my.zdcd==true)yanse(2,0),printf("开"); 
				else yanse(12,0),printf("关");
				yanse(15,0);
				gotoxy(3,7);
				printf("2.声音  ");
				if(my.sy==true)yanse(2,0),printf("开"); 
				else yanse(12,0),printf("关");
				yanse(15,0);
				gotoxy(4,6);
				if(my.yd!="随机")printf(" ");
				printf("3.音调  ");
				cout<<my.yd;
				yanse(15,0);
				gotoxy(5,7);
				printf("4.恢复默认");
				gotoxy(6,7);
				printf("5.修改密码");
				gotoxy(7,9);
				printf("6.返回\n");
				if(kd('1')||kd(VK_NUMPAD1))
				{
					sy();
					sep(100);
					if(my.zdcd==false)my.zdcd=true;
					else my.zdcd=false;
					cdd.cd();
				}
				if(kd('2')||kd(VK_NUMPAD2))
				{
					sep(100);
					if(my.sy==false)my.sy=true;
					else my.sy=false;
					sy();
					cdd.cd();
				}
				if(kd('3')||kd(VK_NUMPAD3))
				{
					sep(100);
					if(my.yd=="do  ")my.yd="re";//"  "是为了掩盖 “机 ”字 
					else if(my.yd=="re")my.yd="mi";
					else if(my.yd=="mi")my.yd="fa";
					else if(my.yd=="fa")my.yd="so";
					else if(my.yd=="so")my.yd="la";
					else if(my.yd=="la")my.yd="si";
					else if(my.yd=="si")my.yd="随机";
					else my.yd="do  ";//"  "是为了掩盖 “机 ”字 
					sy();
					cdd.cd();
				}
				if(kd('4')||kd(VK_NUMPAD4))
				{
					sy();
					sep(100);
					my.zdcd=true;
					my.sy=true;
					my.yd="随机";
					cdd.cd();
					sy();// e~~,声音放设置后 
				}
				if(kd('5')||kd(VK_NUMPAD5))
				{
					sy();
					sep(100);
					cw:
					cls;
					int a;
					printf("输入原密码:");
					cin>>a;
					if(a!=my.password)
					{
						box(NULL,"错误","错误",MB_OK);
						goto cw;
					}
					printf("输入新密码:");
					cin>>my.password;
					printf("\a");
					cls;
					zdcd(); 
				}
				if(kd('6')||kd(VK_NUMPAD6))
				{
					sy();
					sep(100);
					cls;
					sys("mode con cols=24 lines=10");
					break;
				}
			}
		}
		if(kd('3')||kd(VK_NUMPAD3))
		{
			sep(100);
			cls;
			printf("不是很好,请谅解……");
			Beep(440,500);//1
			Beep(440,500);
			Beep(587.33,500);//4
			Beep(587.33,500);
			Beep(659.33,500);//5
			Beep(739.99,500);//6
			Beep(880,1000);//1+.
			sep(500);
			Beep(830.61,500);//7
			Beep(830.61,500);
			Beep(830.61,500);
			Beep(987.76,500);//2+.
			Beep(987.76,500);
			sep(500);
			Beep(880,500);
			Beep(587.33,500);
			Beep(493.88,500);//2
			Beep(659.33,500);
			Beep(880,500);
			Beep(659.33,500);
			Beep(493.88,500);
			Beep(739.99,500);
			Beep(880,500);
			Beep(659.33,500);
			Beep(493.88,500);
			Beep(659.33,500);
			Beep(739.99,1000);
			sep(500);
			Beep(739.99,500);
			Beep(739.99,500);
			Beep(739.99,500);
			Beep(987.76,500);
			Beep(880,500);
			Beep(987.76,1000);
			sep(500);
			Beep(987.76,500);
			Beep(987.76,500);
			Beep(987.76,500);
			Beep(880,500);
			Beep(659.33,500);
			Beep(739.99,1000);
			sep(500);
			Beep(659.33,500);
			Beep(659.33,500);
			Beep(659.33,500);
			Beep(587.33,500);
			Beep(987.76,500);
			Beep(739.99,1000);
			sep(500);
			Beep(880,500);
			Beep(880,500);
			Beep(880,500);
			Beep(987.76,500);
			Beep(659.33,500);
			Beep(739.99,1000);
			sep(500);
			Beep(739.99,500);
			Beep(739.99,500);
			Beep(739.99,500);
			Beep(659.33,500);
			Beep(554.37,500);//3
			Beep(587.33,1000);
			sep(500);
			Beep(493.88,500);
			Beep(493.88,500);
			Beep(493.88,500);
			Beep(554.37,500);
			Beep(493.88,500);
			Beep(440,1000);
			cls;
		}
		if(kd('4')||kd(VK_NUMPAD4))
		{
			sy();
			sep(100);
			cls;
			break;
		}
	}
	return;
}

/***main***/ 
int main()
{
	noedit();
	HideCursor();
	sys("mode con cols=24 lines=10");
	RECT Rect,rectDesktop;
	centerwindow(Rect,rectDesktop);
	my.Validation_strings="-----------请不要作弊-----------"; 
	cdd.dd();
	if(my.condition==false)
	{
		box(NULL,TEXT("初始化时间较长,请耐心等待,在此期间,您可以做其他事"),TEXT("01消息"),MB_OK);
		jiazai(100,100);
		my.zdcd=true;
		my.sy=true;
		my.yd="随机";
		ST("介绍");
		st;
		prin("制作者:CSDN 小学的wxn (要转载请附上原文链接+私信)",10,0);
		prn;
		pause;
		cls;
		prin("欢迎来到本娱乐程序",10,1000);
		cls;
		yanse(5,0);
		prin("请永远不要看存档\n\n我希望看到诚实的你……",200,1000);
		box(NULL,TEXT("即将转接…"),TEXT("02消息"),MB_OK);
		my.condition=true;
	}
	yanse(15,0);
	jiazai(10,10);
	password_authentication();
	cdd.cd();
	MIF();
	cls;
	yanse(5,0);
	prin("\n\n\n我希望看到诚实的你\n\n期待你下次启动……",50,1000);
	box(NULL,TEXT("制作者:CSDN 小学的wxn\n要转载请附上原文链接+私信"),TEXT("ヾ( ̄▽ ̄)Bye~Bye~"),MB_OK);
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值