更新小游戏

今天更新了小游戏。

加入第二关,完善各种交互效果

加入了加载动画和首页面

#include<bits/stdc++.h>
#include<windows.h> 
char mp[6][8]={{'.','#','#','#','.','.','#','.'},{'.','.','.','#','#','.','#','.'},{'#','#','.','#','#','.','.','#'},{'#','#','.','.','.','.','.','#'},{'#','#','#','#','#','#','.','#'},{'.','.','.','#','.','#','.','!'}};
char mp1[9][10]={
	{'@','#','#','#','#','#','#','#','#','#'},
	{'.','.','#','#','.','#','#','#','#','#'},
	{'#','.','#','#','.','#','#','#','#','#'},
	{'#','.','#','#','.','#','.','#','.','#'},
	{'#','.','#','#','#','#','.','.','.','#'},
	{'#','.','#','.','.','.','.','.','.','#'},
	{'#','.','#','.','#','#','#','.','.','#'},
	{'#','.','.','.','#','.','#','.','.','#'},
	{'#','#','#','#','#','.','#','#','.','!'},
};
 
int vis[4][2]={{0,-1},{0,1},{-1,0},{1,0}};

int res;
using namespace std;
void chek(){
	if(res==0)cout<<"NOWAY!"<<endl;
	else cout<<"不能这样走!"<<endl; 
}
int main(){
	cout<<"                          加载中                         "<<endl;
	cout<<"                         *" ;
	Sleep(900);
	cout<<"*" ;
	Sleep(900);
	cout<<"*" ;
	Sleep(900);
	cout<<"*" ;
	Sleep(900);
	cout<<"*" ;
	Sleep(900);
	cout<<"*" ;
	Sleep(900);
	cout<<"*" ;
	Sleep(900);
	system("cls"); 
	cout<<"                 欢迎来到迷宫冒险小游戏!"<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl<<endl;
	cout<<"                      按下E开始 " <<endl;
	char e;
	cin>>e;
	system("cls"); 
	cout<<"中国人?american? 用0或者1来选择国籍,1代表中国,0 means american。"<<endl;
	cin>>res;
	system("cls");
	if(res==1){
		cout<<"掉下去啦…………………………………………"<<endl;
		Sleep(2000);
		cout<<"你掉进了一个迷宫"<<endl;
		cout<<"你需要逃出去"<<endl;
		Sleep(2000);
		system("cls");
		cout<<"你在@的位置,尝试走到感叹号的位置逃出去!!"<<endl;
		cout<<"通过w,s,a,d控制方向! w为上,s为下,a为左,d为右"<<endl;
		Sleep(4000);
		system("cls");
	}
	else {
		cout<<"falling…………………………………………"<<endl;
		Sleep(2000);
		cout<<"you are in a maze"<<endl;
		cout<<"you should leave."<<endl;
		Sleep(2000);
		system("cls");
		cout<<"you are on the place of the @.try to go to the place of the ! and leave!!"<<endl;
		cout<<"use w,s,a,d to contrl the way! w is up,s if down,a is left,d is right";
		Sleep(2000);
		system("cls");
	} 
	mp[0][0]='@';
	for(int i=0;i<6;i++){
		for(int j=0;j<8;j++)cout<<mp[i][j]<<" ";
		cout<<endl;
	}
	int x,y;
	x=y=0; 
	while(y<6&&x<7){
		char ch;
		cin>>ch;
		if(ch=='w'){
			if(mp[y+vis[0][1]][x+vis[0][0]]=='#'){
				chek();
			}
			else {
				Beep(584,682);
				system("cls");
				mp[y][x]='.';
				x+=vis[0][0];
				y+=vis[0][1];
				
				mp[y][x]='@';
				for(int i=0;i<6;i++){
					for(int j=0;j<8;j++)cout<<mp[i][j]<<" ";
					cout<<endl;
				}
			}
		}
		else if(ch=='s'){
			if(mp[y+vis[1][1]][x+vis[1][0]]=='#'){
				chek();
			}
			else {
				Beep(584,682);
				system("cls");
				mp[y][x]='.';
				x+=vis[1][0];
				y+=vis[1][1];
				mp[y][x]='@';
				for(int i=0;i<6;i++){
					for(int j=0;j<8;j++)cout<<mp[i][j]<<" ";
					cout<<endl;
				}
			}
		}
		else if(ch=='a'){
			if(mp[y+vis[2][1]][x+vis[2][0]]=='#'){
				chek();
			}
			else {
				Beep(584,682);
				system("cls");
				mp[y][x]='.';
				x+=vis[2][0];
				y+=vis[2][1];
				mp[y][x]='@';
				for(int i=0;i<6;i++){
					for(int j=0;j<8;j++)cout<<mp[i][j]<<" ";
					cout<<endl;
				}
			}
		}
		else if(ch=='d'){
			if(mp[y+vis[3][1]][x+vis[3][0]]=='#'){
				chek();
			}
			else {
				Beep(584,682);
				system("cls");
				mp[y][x]='.';
				x+=vis[3][0];
				y+=vis[3][1];
				mp[y][x]='@';
				for(int i=0;i<6;i++){
					for(int j=0;j<8;j++)cout<<mp[i][j]<<" ";
					cout<<endl;
				}
			}
		}
	}
	Beep(682,584);
	Beep(584,682);
	if(res==1){
		cout<<"太棒了!你成功逃了出去!"<<endl;
		cout<<"你想要进入下一关吗?(0,1)选择,0代表想要"<<endl;
	}
	else {
		cout<<"good job!! you leaved"<<endl;
		cout<<"do you want to play the next level?(0,1)to choose 0 means want"<<endl;
	} 
	int s;
	cin>>s;
	y=x=0;
	system("cls");
	if(s==0){
		for(int i=0;i<9;i++){
			for(int j=0;j<10;j++)cout<<mp1[i][j]<<" ";
			cout<<endl;
		}
		while(y<9&&x<9){
			char ch;
			cin>>ch;
			if(ch=='w'){
				if(mp1[y+vis[0][1]][x+vis[0][0]]=='#'){
					chek();
				}
				else {
					Beep(584,682);
					system("cls");
					mp1[y][x]='.';
					x+=vis[0][0];
					y+=vis[0][1];
				
					mp1[y][x]='@';
					for(int i=0;i<9;i++){
						for(int j=0;j<10;j++)cout<<mp1[i][j]<<" ";
						cout<<endl;
					}
				}
			}
			else if(ch=='s'){
				if(mp1[y+vis[1][1]][x+vis[1][0]]=='#'){
					chek();
				}
				else {
					Beep(584,682);
					system("cls");
					mp1[y][x]='.';
					x+=vis[1][0];
					y+=vis[1][1];
					mp1[y][x]='@';
					for(int i=0;i<9;i++){
						for(int j=0;j<10;j++)cout<<mp1[i][j]<<" ";
						cout<<endl;
					}
				}
			}
			else if(ch=='a'){
				if(mp1[y+vis[2][1]][x+vis[2][0]]=='#'){
					chek();
				}
				else {
					Beep(584,682);
					system("cls");
					mp1[y][x]='.';
					x+=vis[2][0];
					y+=vis[2][1];
					mp1[y][x]='@';
					for(int i=0;i<0;i++){
						for(int j=0;j<10;j++)cout<<mp1[i][j]<<" ";
						cout<<endl;
					}
				}
			}
			else if(ch=='d'){
				if(mp1[y+vis[3][1]][x+vis[3][0]]=='#'){
					chek();
				}
				else {
					Beep(584,682);
					system("cls");
					mp1[y][x]='.';
					x+=vis[3][0];
					y+=vis[3][1];
					mp1[y][x]='@';
					for(int i=0;i<9;i++){
						for(int j=0;j<10;j++)cout<<mp1[i][j]<<" ";
						cout<<endl;
					}
				}
			}	
		}
		Beep(682,584);
		Beep(584,682);
		if(res==1){
			cout<<"太棒了!你又成功逃了出去!"<<endl;
			cout<<"你想要关机吗?(0,1)选择,0代表想要"<<endl;
		}
		else {
			cout<<"good job!! you leaved again。"<<endl;
			cout<<"do you want to shutdown?(0,1)to choose 0 means want"<<endl;
		} 
		int s1;
		cin>>s1;
		if(s1==0)system("shutdown -p");
		else {
			if(res==1)cout<<"再见,欢迎下次再来!";
			else cout<<"goodbye! welcome play again!" ;
		}
	}
	else return 0; 	
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值