L v 2

头文件

#include<wxn自制的头文件.h>
/***制作者:CSDN wxn小学***/
using namespace std;
bool Sh;
struct my
{
	string name;
	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.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.condition;
		InFile>>my.zdcd;
		InFile>>my.sy;
		InFile>>my.yd;
		InFile>>my.species;
    	return;
	}
	
}cdd;

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

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

/***存读档***/
void CDD()
{
	ST("存读档"); 
	gotoxy(4,9);
	printf("0|读档");
	gotoxy(5,9);
	printf("1|新建");
	while(1)
	{
        if(kd('0')||kd(VK_NUMPAD0))
        {
        	cdd.dd();
        	sy(); 
        	cls;
			break;
		}
		if(kd('1')||kd(VK_NUMPAD1))
		{
			cdd.cd();
			cls;
			break;
		}
    }
    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()%999999+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米胜利\n5退出\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('5')||kd(VK_NUMPAD5))
		{
			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,enter开枪\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
				{
					my.species--;
					printf("你输了,金币减一\n金币:%d",my.species);
					sep(2000);
					cls;
					zdcd(); 
					return;
				}
			}
			else sep(95);
		}
	}
}

/***游戏***/
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(100);
			cls;
			break;
		}
	}
} 
/***MIF***/
void MIF()
{
	while(1)
	{
		ST("界面");
		gotoxy_0(0,0);
		gotoxy(3,7);
		printf("1|进入游戏");
		gotoxy(4,9);
		printf("2|设置");
		gotoxy(5,9);
		printf("3|退出"); 
		if(kd('1')||kd(VK_NUMPAD1))
		{
			sy();
			sep(100);
			cls;
			game(); 
			
		}
		if(kd('2')||kd(VK_NUMPAD2))
		{
			sy();
			sep(100);
			cls;
			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);
					fflush(stdin);//清除缓存区
					cdd.cd();
				} 
				if(kd('5')||kd(VK_NUMPAD5))
				{
					sy();
					sep(100);
					my.zdcd=true;
					my.sy=true;
					my.yd="随机";
					cdd.cd();
					sy();// e~~,声音放设置后 
				}
				if(kd('6')||kd(VK_NUMPAD6))
				{
					sy();
					sep(100);
					cls;
					break;
				}
			}
		}
		if(kd('3')||kd(VK_NUMPAD3))
		{
			sy();
			sep(100);
			cls;
			break;
		}
	}
}

/***main***/ 
int main()
{
	noedit();
	HideCursor();
	sys("mode con cols=24 lines=10");
	RECT Rect,rectDesktop;
	centerwindow(Rect,rectDesktop);
	cdd.dd();
	if(my.condition==false)
	{
		box(NULL,TEXT("初始化时间较长,请耐心等待,在此期间,您可以做其他事"),TEXT("01消息"),MB_OK);
		jiazai(100,100);
	}
	else jiazai(10,10);
	if(my.condition==false)
	{
		my.zdcd=true;
		my.sy=true;
		my.yd="随机";
		ST("介绍");
		st;
		prin("制作者:CSDN wxn小学 (有转载请附上原文链接+私信)",10,0);
		prn;
		pause;
		cls;
		prin("欢迎来到本娱乐程序",10,1000);
		cls;
		box(NULL,TEXT("即将转接…"),TEXT("02消息"),MB_OK);
	}
	password_authentication();
	my.condition=true;
	cdd.cd();
	MIF();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值