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

相关内容

热门资讯

透视规律!德普之星透视辅助软件... 透视规律!德普之星透视辅助软件是真的吗, (德普之星)确实真的有挂(透视)辅助软件(有挂解密)1.德...
透视国外版!wepoker国外... 透视国外版!wepoker国外版透视,(WEPOKER)一直是有挂(透视)插件程序激活码(有挂介绍)...
透视代打!拱趴大菠萝机器人,拱... 透视代打!拱趴大菠萝机器人,拱趴大菠萝挂怎么安装,力荐教程(有挂规律)1)拱趴大菠萝挂怎么安装辅助挂...
透视模拟器!德普之星辅助器ap... 透视模拟器!德普之星辅助器app, (德普)竟然有挂(透视)透视软件免费入口官网(有挂介绍)1、上手...
透视手机版!wepoker手机... 透视手机版!wepoker手机版辅助,(wepoker)好像有挂(透视)辅助软件价格(有挂插件);1...
透视透视!pokemmo手机版... 透视透视!pokemmo手机版脚本,cloudpoker外挂,科技教程(有挂工具)1、金币登录送、破...
透视插件!德普之星怎么开辅助,... 透视插件!德普之星怎么开辅助, (德普之星)果然真的是有挂(透视)透视软件免费入口官网(有挂详情)1...
透视下载!wepoker有辅助... 透视下载!wepoker有辅助工具吗,(WePoKer)原来是真的有挂(透视)破解版内购(有挂解密)...
透视讲解!来玩app破解,哈糖... 透视讲解!来玩app破解,哈糖大菠萝能开挂吗,透明挂教程(有挂解密)在进入哈糖大菠萝能开挂吗辅助挂后...
透视底牌!wepoker有机器... 透视底牌!wepoker有机器人吗,(wepoker)确实真的是有挂(透视)有机器人(有挂解密)1、...