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

相关内容

热门资讯

六分钟了解透视挂脚本!微乐小程... 六分钟了解透视挂脚本!微乐小程序免费黑科技,微乐内蒙麻将透视挂多功能法子APP1、玩家可以在微乐小程...
一分钟了解辅助挂资料!百乐科技... 一分钟了解辅助挂资料!百乐科技多功能辅助挂脚本,百乐科技原来真的是有辅助脚本1、进入到百乐科技是否有...
一分钟带你了解透视器插件!AA... 一分钟带你了解透视器插件!AAPoKer多功能透视器插件,AAPoKer其实存在有透视器插件亲,关键...
分享认知开挂工具!微乐小程序免... 分享认知开挂工具!微乐小程序免费黑科技,微乐够级开挂多功能指南APP1、微乐小程序免费黑科技辅助软件...
分享一款辅助挂要领!棋趣联盟多... 分享一款辅助挂要领!棋趣联盟多功能辅助挂攻略,棋趣联盟果然确实有辅助攻略1、在棋趣联盟插件功能辅助器...
一分钟了解辅助技巧!红龙pok... 一分钟了解辅助技巧!红龙poker多功能辅助技巧,红龙poker一直有辅助技巧红龙poker破解侠是...
最新技巧开挂脚本!微信微乐小程... 最新技巧开挂脚本!微信微乐小程序有挂黑科技,微乐捉麻子开挂多功能机巧APP1、该软件可以轻松地帮助玩...
必备攻略辅助挂课程!快玩炸翻天... 必备攻略辅助挂课程!快玩炸翻天多功能辅助挂app,快玩炸翻天果然是真的有辅助app1、快玩炸翻天有没...
一分钟揭秘作弊器教程!德扑圈多... 一分钟揭秘作弊器教程!德扑圈多功能作弊器教程,德扑圈总是真的是有作弊器教程1、下载好德扑圈正确养号方...
玩家必看科普辅助器神器!微乐小... 玩家必看科普辅助器神器!微乐小程序免费黑科技,微乐邵阳麻将辅助器多功能讲义APP进入游戏-大厅左侧-...