自制迷宫游戏 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... 这一现象值得深思!wepoker网页版透视方法,wepoker轻量版透视(透视)课程教程(确实有挂)...
更值得关注的是!决战辅助,决战... 更值得关注的是!决战辅助,决战十水三辅助(透视)软件-真是是有挂该软件可以轻松地帮助玩家将决战十水三...
据权威媒体报道!购买的wpk辅... 据权威媒体报道!购买的wpk辅助在哪里下载,wejoker辅助器要钱玩吗(透视)机巧教程(一直是真的...
经核实!闽游辅助软件,樱花之盛... 经核实!闽游辅助软件,樱花之盛挂(透视)脚本-本来真的有挂1、完成闽游辅助软件辅助器v3.3的残局,...
来临!wepoker有什么规律... 来临!wepoker有什么规律,hhpoker必备开挂(透视)演示教程(果然是真的挂)1、玩家可以在...
据报道!新八戒怎么控制牌型,牛... 据报道!新八戒怎么控制牌型,牛总管辅助免费版(透视)挂-真是真的是有挂1.新八戒怎么控制牌型 选牌创...
相较于以往!hhpoker辅助... 相较于以往!hhpoker辅助软件下载,德扑圈有透视吗(透视)模块教程(确实真的是有挂)1、hhpo...
有了最新消息!小程序财神十三水... 有了最新消息!小程序财神十三水脚本时评,中至赣州黑科技辅助软件视频(透视)教程-都是是真的挂亲,关键...
此事迅速冲上热搜!wepoke... 此事迅速冲上热搜!wepoker私人局开挂视频,sohoo开挂辅助(透视)模板教程(切实是有挂)1)...
今日!多乐辅助工具,广西八一字... 今日!多乐辅助工具,广西八一字牌可以破解吗(透视)挂-一贯有挂1、广西八一字牌可以破解吗辅助器安装包...