自制迷宫游戏 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; }

相关内容

热门资讯

推荐十款WepOke软件透明挂... 推荐十款WepOke软件透明挂!太过分了其实真的是有挂的(有挂细节)(哔哩哔哩);一、AI软件牌型概...
免费测试版!德州wpk(wpK... 免费测试版!德州wpk(wpK)辅助透视!(辅助透视)详细教程(2020已更新)(哔哩哔哩);wpk...
一起来探讨微扑克规律原来是有挂... 一起来探讨微扑克规律原来是有挂,太过分了原来真的有挂,详细教程(有挂辅助)是一款可以让一直输的玩家,...
细节方法!wpk安卓版本(wP... 细节方法!wpk安卓版本(wPK)透视辅助!(辅助透视)详细教程(2021已更新)(哔哩哔哩)相信很...
技术分享《wpK辅助透视》太坑... 技术分享《wpK辅助透视》太坑了其实是有挂(有挂攻略)是一款可以让一直输的玩家,快速成为一个“必胜”...
必知教程!(WPK控制)透视辅... 您好,WPK这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在这款游戏中...
实测分享!微扑克线上辅助挂(辅... 实测分享!微扑克线上辅助挂(辅助挂)原来真的是有挂(有挂神器)详细教程(哔哩哔哩);1、很好的工具软...
新2024教程!(wpk猫腻)... 新2024教程!(wpk猫腻)辅助透视!(透视)外挂辅助挂插件(2024已更新)(哔哩哔哩)【福星临...
最新技巧《wpk微扑克透视辅助... 最新技巧《wpk微扑克透视辅助》太坑了果然确实真的有挂(有挂教程)最新技巧《wpk微扑克透视辅助》太...
总算清楚!wpk苹果版(Wpk... 您好,wpk这款游戏可以开挂的,确实是有挂的,需要了解加微【439369440】很多玩家在这款游戏中...