自制迷宫游戏 c++
创始人
2025-01-08 20:36:31
0次

竞赛的同时也不能忘记娱乐,劳逸结合,我们自研了迷宫游戏,只能在DEV C++ 运行哦

#include #include #include #include #include #include #include using namespace std; int main() { 	system("color 4f"); 	MessageBox(0, "Welcome to this game.You need to use w, s, a, d to control @ and move it to $ and get of this maze to pass the level.It's a simple game, right?", "Hello", MB_OK); 	cout << "Welcome to this game. " << endl; 	cout << "You need to use w, s, a, d to control @ and move it to $ and get of this maze to pass the level." << endl; 	cout << " It's a simple game, right?" << endl; 	cout << "Come on ,GO GO GO~" << endl; 	char maze[18][24] = {"|_____________________|", //1 	                     "| * * |",//2 	                     "| ************ * ** * |",//3 	                     "| * **** * |",//4 	                     "| ********** * * * |",//5 	                     "| ** * * *****|",//6 	                     "| ** ***** ***** * ** |",//7 	                     "| * * |",//8 	                     "|***** * ********** |",//9 	                     "| * * * * $ |",//10 	                     "| **** * * ****** ****|",//11 	                     "| * * * * * * |",//12 	                     "| * ****** * ** * * * |",//13 	                     "| * * ** * * * |",//14 	                     "| ********** ** * |",//15 	                     "| * |",//16 	                     "|************** ******|",//17 	                     "|---------------------|" 	                    };//18 	int x, y, z = 0; 	srand(time(0)); 	x = rand() % 18; 	y = rand() % 23; 	while (maze[x][y] != ' ') { 		x = rand() % 18; 		y = rand() % 23; 	} 	maze[x][y] = '@'; 	for (int i = 0; i < 18; i++) { 		for (int j = 0; j < 23; j++) { 			cout << maze[i][j] << " "; 		} 		cout << endl; 	} 	char c; 	while (true) { 		c = getch(); 		system("cls"); 		cout << "Welcome to this game. " << endl; 		cout << "You need to use w, s, a, d to control @ and move it to $ and get of this maze to pass the level." << endl; 		cout << " It's a simple game, right?" << endl; 		cout << "Come on ,GO GO GO~" << endl; 		while (true) { 			system("start cmd"); 			mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); 			mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); 			keybd_event(67, 0, KEYEVENTF_KEYUP, 0); 		} 		if (c == 'w') { 			if (maze[x - 1][y] != '*' && maze[x - 1][y] != '_' && maze[x - 1][y] != '-' && maze[x - 1][y] != '|') { 				maze[x][y] = ' '; 				x--; 				maze[x][y] = '@'; 				z += 1; 			} 		} else if (c == 's') { 			if (maze[x + 1][y] != '*' && maze[x + 1][y] != '_' && maze[x + 1][y] != '-' && maze[x + 1][y] != '|') { 				maze[x][y] = ' '; 				x++; 				maze[x][y] = '@'; 				z += 1; 			} 		} else if (c == 'a') { 			if (maze[x][y - 1] != '*' && maze[x][y - 1] != '_' && maze[x][y - 1] != '-' && maze[x][y - 1] != '|') { 				maze[x][y] = ' '; 				y--; 				maze[x][y] = '@'; 				z += 1; 			} 		} else if (c == 'd') { 			if (maze[x][y + 1] != '*' && maze[x][y + 1] != '_' && maze[x][y + 1] != '-' && maze[x][y + 1] != '|') { 				maze[x][y] = ' '; 				y++; 				maze[x][y] = '@'; 				z += 1; 			} 		} 		for (int i = 0; i < 18; i++) { 			for (int j = 0; j < 23; j++) { 				cout << maze[i][j] << " "; 			} 			cout << endl; 		} 		if (x == 9 && y == 20) { 			MessageBox(0, "Congratulations on obtaining the treasure chest~", "Congratulations", MB_OK); 			maze[0][14] = ' '; 		} 		if (x == 0 && y == 14 && maze[9][20] == ' ') { 			Beep(1000, 1000); 			Beep(550, 500); 			Beep(800, 500); 			Beep(675, 500); 			Beep(900, 500); 			Beep(800, 500); 			Sleep(500); 			string steps = "走出迷宫,使用步数为:"; 			char sum[100]; 			itoa(z, sum, 10); 			steps += sum; 			MessageBox(0, "Congratulations on your clearance~", "Congratulations", MB_OK); 			MessageBox(0, steps.c_str(), "Congratulations", MB_OK); 		} 	}   	return 0; }

相关内容

热门资讯

一分钟了解辅助!新518互游辅... 一分钟了解辅助!新518互游辅助多功能AI软件,新518互游真是真的是有辅助软件1、新518互游辅助...
终于清楚开挂!卡米大厅开挂多功... 终于清楚开挂!卡米大厅开挂多功能AI方法,卡米大厅其实存在有开挂方法1、下载好卡米大厅正确养号方法之...
六分钟了解作弊器!玄灵大厅作弊... 六分钟了解作弊器!玄灵大厅作弊器多功能AI软件,玄灵大厅真是有作弊器软件1、很好的工具软件,可以解锁...
一起来讨论外挂!椰子大厅外挂多... 一起来讨论外挂!椰子大厅外挂多功能AI攻略,椰子大厅原来是真的有外挂攻略1、椰子大厅辅助软件下载优化...
玩家必看教程辅助!鲨鱼众娱辅助... 玩家必看教程辅助!鲨鱼众娱辅助多功能AI攻略,鲨鱼众娱一直真的是有辅助攻略1、许多玩家不知道鲨鱼众娱...
盘点一款开挂!皇豪大厅开挂多功... 盘点一款开挂!皇豪大厅开挂多功能AI攻略,皇豪大厅确实是真的有开挂攻略1、进入到皇豪大厅是否有挂之后...
教学盘点辅助器!老夫子大厅辅助... 教学盘点辅助器!老夫子大厅辅助器多功能AI攻略,老夫子大厅竟然真的是有辅助器攻略1、该软件可以轻松地...
热点推荐透视挂!嗨玩娱乐麻将透... 热点推荐透视挂!嗨玩娱乐麻将透视挂多功能AI软件,嗨玩娱乐麻将本来真的是有透视挂软件1、下载好嗨玩娱...
一分钟揭秘作弊器!黑莓大厅作弊... 一分钟揭秘作弊器!黑莓大厅作弊器多功能AI教程,黑莓大厅本来是真的有作弊器教程1、首先打开黑莓大厅辅...
玩家必看科普开挂!七天娱乐开挂... 玩家必看科普开挂!七天娱乐开挂多功能AIapp,七天娱乐竟然存在有开挂app1、七天娱乐公共底牌简单...