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

相关内容

热门资讯

专业讨论!德扑之星真破解套路(... 专业讨论!德扑之星真破解套路(辅助挂)软件透明挂(有挂了解)-哔哩哔哩;人气非常高,ai更新快且高清...
每日必看!智星德州菠萝外挂检测... 每日必看!智星德州菠萝外挂检测(辅助挂)软件透明挂(有挂教学)-哔哩哔哩1、玩家可以在智星德州菠萝外...
透视透明挂!轰趴十三水有后台(... 轰趴十三水有后台赢率提升策略‌;透视透明挂!轰趴十三水有后台(辅助挂)软件透明挂(有挂详情)-哔哩哔...
发现玩家!德扑ai助手软件(辅... 发现玩家!德扑ai助手软件(辅助挂)透视辅助(有挂教学)-哔哩哔哩;玩家在德扑ai助手软件中需先进行...
一分钟了解!x-poker辅助... 一分钟了解!x-poker辅助软件(辅助挂)辅助透视(有挂攻略)-哔哩哔哩1、每一步都需要思考,不同...
一分钟揭秘!德州最新辅助器(辅... 一分钟揭秘!德州最新辅助器(辅助挂)透视辅助(有挂攻略)-哔哩哔哩;德州最新辅助器最新版本免费下载安...
玩家攻略推荐!德州辅助(辅助挂... 玩家攻略推荐!德州辅助(辅助挂)辅助透视(有挂了解)-哔哩哔哩是由北京得德州辅助黑科技有限公司精心研...
揭秘真相!pokernow德州... 《揭秘真相!pokernow德州(辅助挂)辅助透视(有挂介绍)-哔哩哔哩》 pokernow德州软件...
五分钟了解!德州之星辅助器(辅... 五分钟了解!德州之星辅助器(辅助挂)辅助透视(有挂透明)-哔哩哔哩1、很好的工具软件,可以解锁游戏的...
推荐一款!pokermaste... 1、推荐一款!pokermaster有外挂(辅助挂)透视辅助(有挂教学)-哔哩哔哩;详细教程。2、p...