c++小游戏——迷宫

#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
int main()
{
	int i123,ab; 
	for(i123=500;i123<=1000;i123+=100){

		Beep(i123,1000);

	}
	char a,b,c,d,aa,bb,cc,dd;
	cout<<"输入四位字母ID"; 
	cin>>a;
	cin>>b;
	cin>>c;
	cin>>d;
	
	system("cls");	//清屏函数 
	
	cout<<"请再次输入四位字母ID"; 
	cin>>aa;
	cin>>bb;
	cin>>cc;
	cin>>dd;
	if(a==aa&&b==bb&&c==cc&&d==dd)
	{
		cout<<"欢迎您"<<aa<<bb<<cc<<dd;
		cout<<"您要干什么?[1]游戏[2]退出" ;
		cin>>ab;
		if(ab==1) 
		{
			system("color 8f"); 
	int i123;

	cout<<"   ."<<endl;

	cout<<"  . ."<<endl;

	cout<<" . . ."<<endl;

	cout<<"  . ."<<endl;

	cout<<"   ."<<endl;

	cout<<"  T M";

	for(i123=500;i123<=1000;i123+=100){

		Beep(i123,1000);

	}

	system("cls");
	char a[500][500]={"##############################",

   				    "#o         #   ##   # ### ####",

   				    "# ###### # # #    # # ### ####",

   				    "# #   ## #   # #### # ###   ##",

   				    "#   # ##  ###    #  #  ## ####",

   				    "##### #     # ##### ##    ####",

   				    "#   # ##### #   #   # # #    #                   {w上  s下  a左  d右}",

   				    "# # #    ## # #### ## # # ####",

   				    "# # # ##      ##      # # ####",

   				    "# # # ####### ## ###### #   ##",

   				    "# #   ##   # ## ###### ###   #",

   				    "# ###### # #####  #        # #",

   				    "#        # #     ##### ### #  ",

   				    "# ######## ##### # ### ### # #",

   				    "#     # ## ##### ###       ###",

   				    "##### # ## #      ######## # #",

   				    "#     # ## ## ###        #   #",

   				    "# # ###       ###### ####### #",

   				    "# #    ### ##      #         #",

   				    "##############################"};
   				    

	int i,i1,x=1,y=1,n=12,m=29;

	char ch;

	for(i=0;i<=19;i++){

		puts(a[i]);

	}

	while(x!=n||y!=m){

		  ch=getch();

		if(ch==115||ch==25){

			if(a[x+1][y]!=35){

				a[x][y]=32;

				x++;

				a[x][y]=111;

			}

		}

		if(ch==119||ch==24){

			if(a[x-1][y]!=35){

				a[x][y]=32;

				x--;

				a[x][y]=111;

			}

		}

		if(ch==97||ch==27){

			if(a[x][y-1]!=35){

				a[x][y]=32;

				y--;

				a[x][y]=111;

			}

		}

		if(ch==100||ch==26){

			if(a[x][y+1]!=35){

				a[x][y]=32;

				y++;

				a[x][y]=111;

			}

		}

		system("cls");

		for(i=0;i<=19;i++){

			puts(a[i]);

		}

	}

	for(i1=500;i1<=1000;i1=i1+100){

		Beep(i1,1000);

		}
		cout<<endl<<"你赢了!!!祝贺你!!!"<<aa<<bb<<cc<<dd;
		
	}
	
}
	if(ab==2)
	{
		return 0;
	 } 
	else
	{
			cout<<"ID错误!!!!"; 	
	} 
	return 10;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值