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

相关内容

热门资讯

目前来看!微信小程序免费黑科技... 您好,微信小程序免费黑科技这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很...
实测分享!钱塘十三水怎么开挂辅... 实测分享!钱塘十三水怎么开挂辅助,随意玩有没有辅助,模块教程(果真有挂)1、上手简单,内置详细流程视...
现场直击!微信小程序免费黑科技... 现场直击!微信小程序免费黑科技透视,同乡游辅助工具妙招教程(真的有挂)微信小程序免费黑科技透视方法中...
必备科技!科乐游戏辅助脚本视频... 必备科技!科乐游戏辅助脚本视频,开心泉州小程序辅助免费下载,模板教程(详细教程)1、每一步都需要思考...
教程攻略!微乐小程序免费黑科技... 教程攻略!微乐小程序免费黑科技苹果,wepoker插件程序讲义教程(真实有挂)1、起透看视 微乐小程...
分享一款!微信边锋辅助挂件,战... 分享一款!微信边锋辅助挂件,战皇大厅辅助那个可靠,绝活儿教程(有挂方式)1、微信边锋辅助挂件辅助软件...
玩家科普!微信小程序免费黑科技... 玩家科普!微信小程序免费黑科技透视,乐酷辅助图片法子教程(有挂教程)微信小程序免费黑科技辅助器是一种...
普及知识!新畅游互娱辅助app... 普及知识!新畅游互娱辅助app,微友联盟辅助下载,方案教程(有挂猫腻)1、完成新畅游互娱辅助app有...
必看攻略!微乐小程序免费黑科技... 必看攻略!微乐小程序免费黑科技安卓,江西中至小程序黑科技教程书教程(有挂详情)所有人都在同一条线上,...
玩家必看分享!微乐智能辅助软件... 玩家必看分享!微乐智能辅助软件是真的吗,盛世辅助器,手册教程(发现有挂)1、让任何用户在无需微乐智能...