跳到正文

休闲·娱乐

迷宫游戏2.0

bananamilktea约 58 分钟
原文
文章信息与版本

文章信息

发布
2024年6月5日
收录
2025年12月12日
更新
2026年11月15日
篇幅
约 58 分钟
获赞
2

版本

  1. v1当前

在迷宫游戏1.0上新增了颜色,教程,修复了一些漏洞。

原版

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define RED(s) std::cout << RED << s << RESET;
#define GREEN(s) std::cout << GREEN << s << RESET;
#define YELLOW(s) std::cout << YELLOW << s << RESET;
#define BLUE(s) std::cout << BLUE << s << RESET;

using namespace std;

const int MAXN = 1e2; 
const std::string RED = "\033[31m";      // 红色
const std::string GREEN = "\033[32m";    // 绿色
const std::string YELLOW = "\033[33m";   // 黄色
const std::string BLUE = "\033[34m";     // 蓝色
const std::string RESET = "\033[0m";     // 重置颜色

void ys(int a) {
	if (a == 0)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 1)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 2)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
	if (a == 3)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
	if (a == 4)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
	if (a == 5)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
	if (a == 6)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
}

int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int len, x, y, Level = 1, hp = 3, CD = 0, ICD = 10, stop = 0, SCD = 30;
bool die = false;
char c[MAXN][MAXN];
void slowsay(int v, string s) {
	for(int i = 0; i < s.size(); i++) {
		cout << s[i];
		Sleep(v);
	}
	return;
}
struct P {
	int x, y, d;
}zd[MAXN];
void M() {
	for(int i = 1; i <= len; i++) {
		if(zd[i].d != -1) {
			if(c[zd[i].x][zd[i].y] == '@') {
				die = true;
				return;
			}
			c[zd[i].x][zd[i].y] = '.';
			zd[i].x += dx[zd[i].d], zd[i].y += dy[zd[i].d];
			if(c[zd[i].x][zd[i].y] == '#' || c[zd[i].x][zd[i].y] == 'L' || c[zd[i].x][zd[i].y] == 'J') {
				zd[i].d = -1;
			}
			else {
				c[zd[i].x][zd[i].y] = 'Z';
				if(x == zd[i].x && y == zd[i].y) {
					die = true;
					return;
				}
			} 
		}
	}
	if(CD % 3 == 0) {
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
				if(c[i][j] == 'P') {
					if(j == y && i > x && c[i - 1][j] != '#' && c[i - 1][j] != 'L' && c[i][j] != 'J') {
						zd[++len] = {i - 1, j, 0};
						c[zd[len].x][zd[len].y] = 'Z';
					}
					else if(j == y && i < x && c[i + 1][j] != '#' && c[i + 1][j] != 'L' && c[i][j] != 'J') {
						zd[++len] = {i + 1, j, 1};
						c[zd[len].x][zd[len].y] = 'Z';
					}
					else if(i == x && j > y && c[i][j - 1] != '#' && c[i][j - 1] != 'L' && c[i][j] != 'J') {
						zd[++len] = {i, j - 1, 2};
						c[zd[len].x][zd[len].y] = 'Z';
					}
					else if(i == x && j < y && c[i][j + 1] != '#' && c[i][j + 1] != 'L' && c[i][j] != 'J') {
						zd[++len] = {i, j + 1, 3};
						c[zd[len].x][zd[len].y] = 'Z';
					}
				} 
			}
		}
	}
}
void MAP() {
	for(int i = 1; i <= 20; i++) {
		for(int j = 1; j <= 20; j++) {
			if(i == 1 || i == 20 || j == 1 || j == 20) {
				c[i][j] = '#';
			}
			else {
				int x = rand() % 40;
				if(x <= 10) {
					c[i][j] = '#';
				}
				else if(x >= 11 && x <= 37) {
					c[i][j] = '.';
				}
				else if(x == 38) {
					c[i][j] = 'P';
				}
				else {
					c[i][j] = 'V';
				}
			}
		}
	}
	c[2][2] = '@', c[19][19] = 'L'; 
}
void game(int p) {
	Level = 1;
	cout << "这个游戏是由PJL制作,并在迷宫游戏1.0上修改了一些的作品!\n";
	cout << "这个作品叫\"迷宫游戏2.0\"!\n";
	system("pause");
	system("cls");
	cout << "好了好了,废话不多说,开始游戏!";
	Sleep(500);
	system("cls");
	a :
	system("color 0F");
	system("cls"); 
	len = CD = stop = 0;
	ICD = 10, SCD = 50;
	if(hp <= 0) {
		cout << "你的hp没有了!\n";
		return;
	}
	if(Level == 11) {
		ys(2);
		slowsay(200, "你通过了所有关卡!!!\n\n");
		ys(0);
		int x = 30;
		while(x) {
			x--;
        	system("color 1A");Sleep(10);
        	system("color 2B");Sleep(10);
        	system("color 3C");Sleep(10);
        	system("color 4D");Sleep(10);
        	system("color 5D");Sleep(10);
        	system("color 6E");Sleep(10);
        	system("color 7F");Sleep(10);
		}
		system("color 0F");
		return;
	}
	MAP();
	x = 2, y = 2;
	die = false;
	while(1) {
		SCD = max(SCD - 1, 0);
		ICD = max(ICD - (stop == 0), 0);
		cout << "第" << Level << "关\n";
		cout << "HP : " << hp << "\n";
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
				if(c[i][j] == 'P') {
				    YELLOW("P");
				}
				else if(c[i][j] == 'Z') {
				    RED("Z");
				}
				else if(c[i][j] == 'V') {
				    GREEN("V");
				}
				else if(c[i][j] == '@' && stop > 0) {
					ys(rand() % 5 + 1);
					cout << "@";
					ys(0);
				}
				else {
					cout << c[i][j];
				}
			}
			cout << "\n";
		}
		if(c[x][y] == 'Z') {
			hp--;
			cout << "你死了!\n";
			Sleep(2000);
			goto a;
		} 
		while(!kbhit()) {
		}
		char g = _getch();
		if(g == 'Q') {
			system("cls");
			goto a;
		}
		else if(g == 'W' && c[x - 1][y] != '#') {
			c[x][y] = '.';
			x--;
		}
		else if(g == 'A' && c[x][y - 1] != '#') {
			c[x][y] = '.';
			y--;
		}
		else if(g == 'S' && c[x + 1][y] != '#') {
			c[x][y] = '.';
			x++;
		}
		else if(g == 'D' && c[x][y + 1] != '#') {
			c[x][y] = '.';
			y++;
		}
		if(c[x][y] == 'Z') {
			system("cls");
			cout << "第" << Level << "关\n";
			cout << "HP : " << hp << "\n";
			for(int i = 1; i <= 20; i++) {
				for(int j = 1; j <= 20; j++) {
					if(i == x && j == y) {
					    RED("Z");
					}
					else {
						if(c[i][j] == 'P') {
				            YELLOW("P");
				        }
				    	else if(c[i][j] == 'V') {
					       GREEN("V");
					    }
				        else if(c[i][j] == 'Z') {
				            RED("Z");
				        }
						else {
							cout << c[i][j];
						}
					}
				}
				cout << "\n";
			}
			hp--;
			cout << "你死了!\n";
			Sleep(2000);
			goto a;
		} 
		if(stop <= 0) {
			M();
		}
		else {
			stop--;
		}
		CD++;
		if(c[x][y] == 'V') {
			hp++;
		}
		if(c[x][y] == 'Z' || c[x][y] == 'L' || die == true) {
			system("cls");
			cout << "第" << Level << "关\n";
			cout << "HP : " << hp << "\n";
			for(int i = 1; i <= 20; i++) {
				for(int j = 1; j <= 20; j++) {
					if(i == x && j == y) {
					    if(c[i][j] == 'Z') {
					        RED("Z");
					    }
					    else {
					        cout << "@";
					    }
					}
					else {
						if(c[i][j] == 'Z') {
                            RED("Z");
				        }
		           		else if(c[i][j] == 'P') {
				            YELLOW("P");
				        }
			     	    else if(c[i][j] == 'V') {
				            GREEN("V");
				        }
						else {
							cout << c[i][j];
						}
					}
				}
				cout << "\n";
			}
			if(c[x][y] == 'Z' || die == true) {
				hp--;
				cout << "你死了!\n";
				Sleep(2000);
				goto a;
			}
			else {
				system("color 7F");
				cout << "你过关了!" << endl;
				Sleep(2000);
				Level++;
				goto a;
			}
		}
		c[x][y] = '@';
		Sleep(10);
		system("cls");
	}
}
void learn() {
	slowsay(20, "先进教程,学完了再实战,OK?");
	Sleep(100);
	len = CD = 0; 
	system("cls");
	for(int i = 1; i <= 20; i++) {
		for(int j = 1; j <= 20; j++) {
			c[i][j] = '#';
		}
	}
	for(int i = 2; i <= 19; i++) {
		for(int j = 2; j <= 19; j++) {
			c[i][j] = '.';
		}
	}
	c[2][2] = '@';
	ys(2);
	slowsay(10, "@的位置是你,你可以按下大写的WASD移动\n");
	slowsay(10, "你来试试看\n");
	ys(0);
	Sleep(1000); 
	int p = 10, hp = 3;
	system("cls");
	x = 2, y = 2;
	while(p) {
		cout << "HP : " << hp << "\n";
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
				cout << c[i][j];
			}
			cout << "\n";
		}
		cout << "\n";
		ys(0);
		while(!kbhit()) {
		}
		char g = _getch();
		if(g == 'W' && c[x - 1][y] == '.') {
			c[x][y] = '.';
			x--;
		}
		else if(g == 'A' && c[x][y - 1] == '.') {
			c[x][y] = '.';
			y--;
		}
		else if(g == 'S' && c[x + 1][y] == '.') {
			c[x][y] = '.';
			x++;
		}
		else if(g == 'D' && c[x][y + 1] == '.') {
			c[x][y] = '.';
			y++;
		}
		else {
			p++;
		}
		p--;
		system("cls");
		c[x][y] = '@';
	}
	ys(2);
	slowsay(10, "好了,现在你应该已经掌握怎么移动了。\n");
	slowsay(10, "我会在中间生成一个回血道具V,吃了它\n");
	ys(0);
	Sleep(100);
	c[x][y] = '.'; 
	c[10][10] = 'V';
	c[2][2] = '@';
	system("cls");
	x = 2, y = 2;
	while(1) {
		cout << "HP : " << hp << "\n";
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
			    if(c[i][j] == 'V') {
			        GREEN("V");
			    }
			    else {
			        cout << c[i][j];
			    }
			}
			cout << "\n";
		}
		cout << "\n";
		if(hp == 4) {
			ys(2);
			slowsay(10, "你看,你吃掉了回血道具,现在你的生命值,也就是HP,增加了1\n");
			Sleep(2000);
			ys(0);
			system("cls");
			break;
		}
		ys(0);
		while(!kbhit()) {
		}
		char g = _getch();
		if(g == 'W' && c[x - 1][y] != '#') {
			c[x][y] = '.';
			x--;
		}
		else if(g == 'A' && c[x][y - 1] != '#') {
			c[x][y] = '.';
			y--;
		}
		else if(g == 'S' && c[x + 1][y] != '#') {
			c[x][y] = '.';
			x++;
		}
		else if(g == 'D' && c[x][y + 1] != '#') {
			c[x][y] = '.';
			y++;
		}
		if(c[x][y] == 'V') {
			hp++;
		}
		system("cls");
		c[x][y] = '@';
	}
	c[x][y] = '.';
	ys(2);
	slowsay(10, "接着,你要开始打怪了,毕竟怪物在迷宫里是必不可少的一部分。\n");
	slowsay(10, "怪物是P,你要躲避它的子弹Z,你可以跑过去撸死它\n");
	ys(0);
    Sleep(3000);
    system("cls");
	x = 2, y = 2;
	c[10][10] = 'P';
	c[2][2] = '@';
	while(c[10][10] == 'P') {
		die = false;
		cout << "HP : " << hp << "\n";
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
				if(c[i][j] == 'Z') {
				    RED("Z");
				}
				else if(c[i][j] == 'V') {
				    GREEN("V");
				}
				else if(c[i][j] == 'P') {
				    YELLOW("P");
				}
				else {
				    cout << c[i][j];
				}
			}
			cout << "\n";
		}
		if(c[x][y] == 'Z') {
			cout << "你受到了伤害!\n";
			c[x][y] = '@';
			for(int i = 1; i <= len; i++) {
			    if(zd[i].x == x && zd[i].y == y) {
			        zd[i].d = -1;
			    }
			}
			Sleep(2000);
			system("cls"); 
			c[x][y] = '@';
			continue;
		} 
		while(!kbhit()) {
		}
		char g = _getch();
		if(g == 'W' && c[x - 1][y] != '#') {
			c[x][y] = '.';
			x--;
		}
		else if(g == 'A' && c[x][y - 1] != '#') {
			c[x][y] = '.';
			y--;
		}
		else if(g == 'S' && c[x + 1][y] != '#') {
			c[x][y] = '.';
			x++;
		}
		else if(g == 'D' && c[x][y + 1] != '#') {
			c[x][y] = '.';
			y++;
		}
		if(c[x][y] == 'Z') {
			system("cls");
			cout << "HP : " << hp << "\n";
			for(int i = 1; i <= 20; i++) {
				for(int j = 1; j <= 20; j++) {
					if(i == x && j == y || c[i][j] == 'Z') {
						RED("Z");
					}
					else if(c[i][j] == 'P') {
					    YELLOW("P");
					}
					else if(c[i][j] == 'V') {
					    GREEN("V");
					}
					else {
						cout << c[i][j];
					}
				}
				cout << "\n";
			}
			cout << "你受到了伤害!\n";
			Sleep(2000);
			c[x][y] = '@';
			for(int i = 1; i <= len; i++) {
			    if(zd[i].x == x && zd[i].y == y) {
			        zd[i].d = -1;
			    }
			}
			system("cls");
			continue; 
		} 
		M();
		CD++;
		if(c[x][y] == 'V') {
			hp++;
		}
		if(c[x][y] == 'Z' || die == true) {
			system("cls");
			cout << "HP : " << hp << "\n";
			for(int i = 1; i <= 20; i++) {
				for(int j = 1; j <= 20; j++) {
					if(i == x && j == y || c[i][j] == 'Z') {
					    RED("Z");
					}
					else if(c[i][j] == 'P') {
					    YELLOW("P");
					}
					else if(c[i][j] == 'V') {
					    GREEN("V");
					}
					else {
						cout << c[i][j];
					}
				}
				cout << "\n";
			}
			c[x][y] = '@';
			for(int i = 1; i <= len; i++) {
			    if(zd[i].x == x && zd[i].y == y) {
			        zd[i].d = -1;
			    }
			}
			cout << "你受到了伤害!\n";
			Sleep(2000);
			c[x][y] = '@';
			system("cls");
			continue; 
		}
		c[x][y] = '@';
		Sleep(10);
		system("cls");
	}
	cout << "HP : " << hp << "\n";
	for(int i = 1; i <= 20; i++) {
		for(int j = 1; j <= 20; j++) {
			cout << c[i][j];
		}
		cout << "\n";
	}
	ys(2);
	slowsay(10, "你现在打死了怪物,后面的内容就靠你自己探索了!(主要是作者很懒)");
	ys(0);
	Sleep(3000);
	system("cls"); 
} 
void gz() {
	slowsay(10, "在这个游戏中,'#'是墙,'.'是路,你的位置是'@',终点是L,WASD移动\n");
	system("pause");
	system("cls"); 
	slowsay(10, "这个迷宫里有怪物'P'。\n");
	system("pause");
	system("cls"); 
	slowsay(10, "TA虽然不会移动,但是怪物会向你发射子弹,敌人的子弹是'Z'。你被打到就会死翘翘,当然,你也可以跑过去徒手干掉它。\n");
	system("pause");
	system("cls"); 
	slowsay(10, "在迷宫里,会有一些道具,V是回血的道具。注意,如果子弹打到道具,道具将被摧毁。哦,对了,忘说了,怪物也会被怪物打死。\n");
	system("pause");
	system("cls"); 
	slowsay(10, "如果你发现地图有问题,按Q刷新地图\n");
	system("pause");
	system("cls"); 
	slowsay(10, "接下来其他内容,就靠你自己探索了qwq\n"); 
}

int main() {
	srand(time(0));
	cout << "版权 __PJL__\n日期 2024/6/5\n语言 C++\n\n\n";
	slowsay(10, "欢迎游玩由__PJL__制作的迷宫游戏\n");
	ys(1);
	cout << "    ■       ■            ■        ■■■■■      ■■■■■\n";
	cout << "   ■ ■    ■■          ■■             ■        ■\n";
	cout << "  ■   ■  ■  ■        ■  ■          ■          ■■■■■\n";
	cout << " ■     ■■    ■      ■■■■       ■            ■\n";
	cout << "■       ■      ■    ■      ■    ■■■■■      ■■■■■\n";
	ys(0);
	system("pause");
	cout << "正在加载……";
	system("cls");
	for(int i = 1; i <= 100; i++) {
		cout << "loading...\n";
		cout << i << "%\n";
		Sleep(7);
		system("cls");
	}
	a :
	system("color 0F") ;
	hp = 3, Level = 1, len = 0;
	int x;
	cout << "1. 开始游戏 2. 介绍规则 3.游戏教程\n";
	cin >> x;
	if(x == 1) {
		game(1);
	}
	else if(x == 2) {
		gz();
	}
	else if(x == 3) {
		learn();
	}
	system("pause");
	system("cls");
	goto a;
	return 0;
}

地狱版

C++
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define RED(s) std::cout << RED << s << RESET;
#define GREEN(s) std::cout << GREEN << s << RESET;
#define YELLOW(s) std::cout << YELLOW << s << RESET;
#define BLUE(s) std::cout << BLUE << s << RESET;

using namespace std;

const int MAXN = 1e2, MAXK = 1e6; 
const std::string RED = "\033[31m";      // 红色
const std::string GREEN = "\033[32m";    // 绿色
const std::string YELLOW = "\033[33m";   // 黄色
const std::string BLUE = "\033[34m";     // 蓝色
const std::string RESET = "\033[0m";     // 重置颜色

void ys(int a) {
	if (a == 0)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 1)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE);
	if (a == 2)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN);
	if (a == 3)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
	if (a == 4)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
	if (a == 5)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
	if (a == 6)
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN);
}

int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int len, x, y, Level = 1, hp = 3, CD = 0, ICD = 10, stop = 0, SCD = 30;
bool wd = false;
bool die = false;
char c[MAXN][MAXN];
void slowsay(int v, string s) {
	for(int i = 0; i < s.size(); i++) {
		cout << s[i];
		Sleep(v);
	}
	return;
}
struct P {
	int x, y, d;
}zd[MAXK];
void M() {
	for(int i = 1; i <= len; i++) {
		if(zd[i].d != -1) {
			if(c[zd[i].x][zd[i].y] == '@') {
				die = true;
				return;
			}
			c[zd[i].x][zd[i].y] = '.';
			zd[i].x += dx[zd[i].d], zd[i].y += dy[zd[i].d];
			if(c[zd[i].x][zd[i].y] == '#' || c[zd[i].x][zd[i].y] == 'L' || c[zd[i].x][zd[i].y] == 'J') {
				zd[i].d = -1;
			}
			else {
				c[zd[i].x][zd[i].y] = 'Z';
				if(x == zd[i].x && y == zd[i].y) {
					die = true;
					return;
				}
			} 
		}
	}
	if(CD % 3 == 0) {
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
				if(c[i][j] == 'P') {
					if(j == y && i > x && c[i - 1][j] != '#' && c[i - 1][j] != 'L' && c[i][j] != 'J') {
						zd[++len] = {i - 1, j, 0};
						c[zd[len].x][zd[len].y] = 'Z';
					}
					else if(j == y && i < x && c[i + 1][j] != '#' && c[i + 1][j] != 'L' && c[i][j] != 'J') {
						zd[++len] = {i + 1, j, 1};
						c[zd[len].x][zd[len].y] = 'Z';
					}
					else if(i == x && j > y && c[i][j - 1] != '#' && c[i][j - 1] != 'L' && c[i][j] != 'J') {
						zd[++len] = {i, j - 1, 2};
						c[zd[len].x][zd[len].y] = 'Z';
					}
					else if(i == x && j < y && c[i][j + 1] != '#' && c[i][j + 1] != 'L' && c[i][j] != 'J') {
						zd[++len] = {i, j + 1, 3};
						c[zd[len].x][zd[len].y] = 'Z';
					}
				} 
			}
		}
	}
}
void MAP() {
	for(int i = 1; i <= 20; i++) {
		for(int j = 1; j <= 20; j++) {
			if(i == 1 || i == 20 || j == 1 || j == 20) {
				c[i][j] = '#';
			}
			else {
				int x = rand() % 40;
				/*if(x <= 10) {
					c[i][j] = '#';
				}
				else if(x >= 11 && x <= 37) {
					c[i][j] = '.';
				}
				else if(x == 38) {
					c[i][j] = 'P';
				}
				else {
					c[i][j] = 'V';
				}*/
				if(x <= 20) {
					c[i][j] = '.';
				}
				else if(x >= 21 && x <= 28) {
					c[i][j] = 'P';
				}
				else {
					c[i][j] = 'V';
				}
			}
		}
	}
	c[2][2] = '@', c[19][19] = 'L'; 
}
void game(int p) {
	Level = 1;
	cout << "这个游戏是由PJL改编的!\n";
	cout << "这游戏简单的要命!(逃\n";
	system("pause");
	system("cls");
	cout << "废话不多说,开始游戏!";
	Sleep(500);
	system("cls");
	a :
	system("color 0F");
	system("cls"); 
	len = CD = stop = 0;
	ICD = 10, SCD = 50;
	if(hp <= 0) {
		cout << "你的hp没有了!\n";
		return;
	}
	if(Level == 11) {
		ys(2);
		slowsay(200, "你通过了所有关卡!!!\n\n");
		ys(0);
		int x = 30;
		while(x) {
			x--;
        	system("color 1A");Sleep(10);
        	system("color 2B");Sleep(10);
        	system("color 3C");Sleep(10);
        	system("color 4D");Sleep(10);
        	system("color 5D");Sleep(10);
        	system("color 6E");Sleep(10);
        	system("color 7F");Sleep(10);
		}
		system("color 0F");
		return;
	}
	MAP();
	x = 2, y = 2;
	die = false;
	while(1) {
		SCD = max(SCD - 1, 0);
		ICD = max(ICD - (stop == 0), 0);
		cout << "第" << Level << "关\n";
		cout << "HP : " << hp << "      大招CD : " << ICD << "      " << "时停剩余时间 : " << stop << "\n";
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
				if(c[i][j] == 'J') {
					ys(1);
					cout << "J";
					ys(0);
					c[i][j] = '.';
				} 
				else if(c[i][j] == 'P') {
				    YELLOW("P");
				}
				else if(c[i][j] == 'Z') {
				    RED("Z");
				}
				else if(c[i][j] == 'V') {
				    GREEN("V");
				}
				else if(c[i][j] == '@' && (stop > 0 || wd)) {
					ys(rand() % 5 + 1);
					cout << "@";
					ys(0);
				}
				else {
					cout << c[i][j];
				}
			}
			cout << "\n";
		}
		if(c[x][y] == 'Z' && !wd) {
			hp--;
			cout << "你死了!\n";
			Sleep(2000);
			goto a;
		} 
		while(!kbhit()) {
		}
		char g = _getch();
		if(g == 'Q') {
			system("cls");
			goto a;
		}
		else if(g == 'W' && c[x - 1][y] != '#') {
			c[x][y] = '.';
			x--;
		}
		else if(g == 'A' && c[x][y - 1] != '#') {
			c[x][y] = '.';
			y--;
		}
		else if(g == 'S' && c[x + 1][y] != '#') {
			c[x][y] = '.';
			x++;
		}
		else if(g == 'D' && c[x][y + 1] != '#') {
			c[x][y] = '.';
			y++;
		}
		else if(g == 'J' && ICD <= 0) {
			int D1 = rand() % 4, D2 = rand() % 4;
			for(int x1 = x, y1 = y; c[x1][y1] != '#'; x1 += dx[D1], y1 += dy[D1]) {
				c[x1][y1] = 'J';
			} 
			for(int x1 = x, y1 = y; c[x1][y1] != '#'; x1 += dx[D2], y1 += dy[D2]) {
				c[x1][y1] = 'J';
			} 
			c[x][y] = '@';
			for(int i = 1; i <= len; i++) {
				if(c[zd[i].x][zd[i].y] == 'J' && zd[i].d != -1) {
					zd[i].d = -1;
					c[zd[i].x][zd[i].y] = 'J';
				}
			}
			ICD = 10;
			c[19][19] = 'L';
		}
		else if(g == 'K' && ICD <= 0) {
			stop = 10, ICD = 10;
		}
		else if(g == 'L' && SCD <= 0) {
			system("cls");
			slowsay(30, "触发隐藏技能!\n");
			system("cls");
			for(int i = 2; i <= 19; i++) {
				for(int j = 2; j <= 19; j++) {
					c[i][j] = (rand() % 2 == 0 ? 'J' : c[i][j]);
				}
			}
			c[x][y] = '@', c[19][19] = 'L';
			SCD = 50;
		}
		if(c[x][y] == 'Z' && !wd) {
			system("cls");
			cout << "第" << Level << "关\n";
			cout << "HP : " << hp << "\n";
			for(int i = 1; i <= 20; i++) {
				for(int j = 1; j <= 20; j++) {
					if(i == x && j == y) {
					    RED("Z");
					}
					else {
						if(c[i][j] == 'J') {
							ys(1);
							cout << "J";
							ys(0);
						}
		           		else if(c[i][j] == 'P') {
				            YELLOW("P");
				        }
				    	else if(c[i][j] == 'V') {
					       GREEN("V");
					    }
				        else if(c[i][j] == 'Z') {
				            RED("Z");
				        }
						else {
							cout << c[i][j];
						}
					}
				}
				cout << "\n";
			}
			hp--;
			cout << "你死了!\n";
			Sleep(2000);
			goto a;
		} 
		if(stop <= 0) {
			M();
		}
		else {
			stop--;
		}
		CD++;
		if(c[x][y] == 'V') {
			hp++;
		}
		if((c[x][y] == 'Z' && !wd) || c[x][y] == 'L' || (die == true && !wd)) {
			system("cls");
			cout << "第" << Level << "关\n";
			cout << "HP : " << hp << "\n";
			for(int i = 1; i <= 20; i++) {
				for(int j = 1; j <= 20; j++) {
					if(i == x && j == y) {
					    if(c[i][j] == 'Z') {
					        RED("Z");
					    }
					    else {
					        cout << "@";
					    }
					}
					else {
						if(c[i][j] == 'J') {
							ys(1);
							cout << "J";
							ys(0);
						}
			          	else if(c[i][j] == 'Z') {
                            RED("Z");
				        }
		           		else if(c[i][j] == 'P') {
				            YELLOW("P");
				        }
			     	    else if(c[i][j] == 'V') {
				            GREEN("V");
				        }
						else {
							cout << c[i][j];
						}
					}
				}
				cout << "\n";
			}
			if((c[x][y] == 'Z' || die == true) && !wd) {
				hp--;
				cout << "你死了!\n";
				Sleep(2000);
				goto a;
			}
			else {
				system("color 7F");
				cout << "你过关了!" << endl;
				Sleep(2000);
				Level++;
				goto a;
			}
		}
		c[x][y] = '@';
		Sleep(10);
		system("cls");
	}
}
void learn() {
	slowsay(20, "先进教程,学完了再实战,OK?");
	Sleep(100);
	system("cls");
	for(int i = 1; i <= 20; i++) {
		for(int j = 1; j <= 20; j++) {
			c[i][j] = '#';
		}
	}
	for(int i = 2; i <= 19; i++) {
		for(int j = 2; j <= 19; j++) {
			c[i][j] = '.';
		}
	}
	c[2][2] = '@';
	ys(2);
	slowsay(10, "@的位置是你,你可以按下大写的WASD移动\n");
	slowsay(10, "你来试试看\n");
	ys(0);
	Sleep(1000); 
	int p = 10, hp = 3;
	system("cls");
	x = 2, y = 2;
	while(p) {
		cout << "HP : " << hp << "\n";
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
				cout << c[i][j];
			}
			cout << "\n";
		}
		cout << "\n";
		ys(0);
		while(!kbhit()) {
		}
		char g = _getch();
		if(g == 'W' && c[x - 1][y] == '.') {
			c[x][y] = '.';
			x--;
		}
		else if(g == 'A' && c[x][y - 1] == '.') {
			c[x][y] = '.';
			y--;
		}
		else if(g == 'S' && c[x + 1][y] == '.') {
			c[x][y] = '.';
			x++;
		}
		else if(g == 'D' && c[x][y + 1] == '.') {
			c[x][y] = '.';
			y++;
		}
		else {
			p++;
		}
		p--;
		system("cls");
		c[x][y] = '@';
	}
	ys(2);
	slowsay(10, "好了,现在你应该已经掌握怎么移动了。\n");
	slowsay(10, "我会在中间生成一个回血道具V,吃了它\n");
	ys(0);
	Sleep(100);
	c[x][y] = '.'; 
	c[1][1] = '@'; 
	c[10][10] = 'V';
	system("cls");
	x = 2, y = 2;
	while(1) {
		cout << "HP : " << hp << "\n";
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
			    if(c[i][j] == 'V') {
			        GREEN("V");
			    }
			    else {
			        cout << c[i][j];
			    }
			}
			cout << "\n";
		}
		cout << "\n";
		if(hp == 4) {
			ys(2);
			slowsay(10, "你现在吃掉了回血道具,现在你的生命值,也就是HP,增加了1\n");
			Sleep(2000);
			ys(0);
			system("cls");
			break;
		}
		ys(0);
		while(!kbhit()) {
		}
		char g = _getch();
		if(g == 'W' && c[x - 1][y] != '#') {
			c[x][y] = '.';
			x--;
		}
		else if(g == 'A' && c[x][y - 1] != '#') {
			c[x][y] = '.';
			y--;
		}
		else if(g == 'S' && c[x + 1][y] != '#') {
			c[x][y] = '.';
			x++;
		}
		else if(g == 'D' && c[x][y + 1] != '#') {
			c[x][y] = '.';
			y++;
		}
		if(c[x][y] == 'V') {
			hp++;
		}
		system("cls");
		c[x][y] = '@';
	}
	c[x][y] = '.';
	ys(2);
	slowsay(10, "接着,你要开始打怪了,毕竟怪物在迷宫里是必不可少的一部分。\n");
	slowsay(10, "怪物是P,你要躲避它的子弹Z,你可以跑过去撸死它\n");
	ys(0);
	c[2][2] = '@';
    Sleep(3000);
	x = 2, y = 2;
	c[10][10] = 'P';
	while(c[10][10] == 'P') {
		die = false;
		cout << "HP : " << hp << "\n";
		for(int i = 1; i <= 20; i++) {
			for(int j = 1; j <= 20; j++) {
				if(c[i][j] == 'Z') {
				    RED("Z");
				}
				else if(c[i][j] == 'V') {
				    GREEN("V");
				}
				else if(c[i][j] == 'P') {
				    YELLOW("P");
				}
				else {
				    cout << c[i][j];
				}
			}
			cout << "\n";
		}
		if(c[x][y] == 'Z') {
			cout << "你受到了伤害!\n";
			c[x][y] = '@';
			for(int i = 1; i <= len; i++) {
			    if(zd[i].x == x && zd[i].y == y) {
			        zd[i].d = -1;
			    }
			}
			Sleep(2000);
			system("cls"); 
			c[x][y] = '@';
			continue;
		} 
		while(!kbhit()) {
		}
		char g = _getch();
		if(g == 'W' && c[x - 1][y] != '#') {
			c[x][y] = '.';
			x--;
		}
		else if(g == 'A' && c[x][y - 1] != '#') {
			c[x][y] = '.';
			y--;
		}
		else if(g == 'S' && c[x + 1][y] != '#') {
			c[x][y] = '.';
			x++;
		}
		else if(g == 'D' && c[x][y + 1] != '#') {
			c[x][y] = '.';
			y++;
		}
		if(c[x][y] == 'Z') {
			system("cls");
			cout << "第" << Level << "关\n";
			cout << "HP : " << hp << "\n";
			for(int i = 1; i <= 20; i++) {
				for(int j = 1; j <= 20; j++) {
					if(i == x && j == y) {
						RED("Z");
					}
					else if(c[i][j] == 'P') {
					    YELLOW("P");
					}
					else if(c[i][j] == 'V') {
					    GREEN("V");
					}
					else {
						cout << c[i][j];
					}
				}
				cout << "\n";
			}
			cout << "你受到了伤害!\n";
			Sleep(2000);
			c[x][y] = '@';
			for(int i = 1; i <= len; i++) {
			    if(zd[i].x == x && zd[i].y == y) {
			        zd[i].d = -1;
			    }
			}
			system("cls");
			continue; 
		} 
		M();
		CD++;
		if(c[x][y] == 'V') {
			hp++;
		}
		if(c[x][y] == 'Z' || die == true) {
			system("cls");
			cout << "第" << Level << "关\n";
			cout << "HP : " << hp << "\n";
			for(int i = 1; i <= 20; i++) {
				for(int j = 1; j <= 20; j++) {
					if(i == x && j == y) {
					    RED("Z");
					}
					else if(c[i][j] == 'P') {
					    YELLOW("P");
					}
					else if(c[i][j] == 'V') {
					    GREEN("V");
					}
					else {
						cout << c[i][j];
					}
				}
				cout << "\n";
			}
			c[x][y] = '@';
			for(int i = 1; i <= len; i++) {
			    if(zd[i].x == x && zd[i].y == y) {
			        zd[i].d = -1;
			    }
			}
			cout << "你受到了伤害!\n";
			Sleep(2000);
			c[x][y] = '@';
			system("cls");
			continue; 
		}
		c[x][y] = '@';
		Sleep(10);
		system("cls");
	}
	for(int i = 1; i <= 20; i++) {
		for(int j = 1; j <= 20; j++) {
			cout << c[i][j];
		}
		cout << "\n";
	}
	ys(2);
	slowsay(10, "你现在打死了怪物,后面的内容就靠你自己探索了!(主要是作者很懒)");
	ys(0);
	Sleep(3000);
	system("cls"); 
} 
void gz() {
	slowsay(10, "在这个游戏中,'#'是墙,'.'是路,你的位置是'@',终点是L,WASD移动\n");
	system("pause");
	system("cls"); 
	slowsay(10, "这个迷宫里危机四伏,会有大量怪物'P'。\n");
	system("pause");
	system("cls"); 
	slowsay(10, "TA虽然不会移动,但是怪物会向你发射子弹,敌人的子弹是'Z'。你被打到就会死翘翘,当然,你也可以跑过去徒手干掉它。但估计你没干几个就被射成刺猬了。。。\n");
	system("pause");
	system("cls"); 
	slowsay(10, "在迷宫里,会有一些道具,V是回血的道具。注意,如果子弹打到道具,道具将被摧毁,这也会导致迷宫里道具变得极稀有。当然,怪物也会被怪物打死。\n");
	system("pause");
	system("cls"); 
	slowsay(50, "emmm...\n");
	system("pause");
	system("cls"); 
	slowsay(10, "作者发现这个游戏太难了,于是降低了难度!按下J可发电,可向随机四个方向其中的两个发射,有极小概率会只发射一个,道具也会被电清除!按下K可时间停止5回合!这两个技能CD共享!\n");
	system("pause");
	system("cls");  
	slowsay(10, "还有一些隐藏技能,等你去寻找!\n");
	system("pause");
	system("cls");
	slowsay(10, "如果你发现地图有问题,按Q刷新地图\n");
	system("pause");
	system("cls"); 
	slowsay(10, "接下来其他内容,就靠你自己探索了qwq\n"); 
}

int main() {
	srand(time(0));
	cout << "版权 __PJL__\n日期2024/5/17\n语言 C++\n\n\n";
	slowsay(10, "欢迎游玩由__PJL__制作的迷宫游戏\n");
	ys(1);
	cout << "    ■       ■            ■        ■■■■■      ■■■■■\n";
	cout << "   ■ ■    ■■          ■■             ■        ■\n";
	cout << "  ■   ■  ■  ■        ■  ■          ■          ■■■■■\n";
	cout << " ■     ■■    ■      ■■■■       ■            ■\n";
	cout << "■       ■      ■    ■      ■    ■■■■■      ■■■■■\n";
	ys(0);
	system("pause");
	cout << "正在加载……";
	system("cls");
	for(int i = 1; i <= 100; i++) {
		cout << "loading...\n";
		cout << i << "%\n";
		Sleep(7);
		system("cls");
	}
	a :
	system("color 0F") ;
	hp = 3, Level = 1, len = 0;
	int x;
	cout << "1. 开始游戏 2. 介绍规则 3.游戏教程 " << (wd ? "4.关闭无敌模式\n" : "\n");
	cin >> x;
	if(x == 1) {
		game(1);
	}
	else if(x == 2) {
		gz();
	}
	else if(x == 3) {
		learn();
	}
	else if(x == 4) {
		wd = false;
	}
	else if(x == 114514) {
		slowsay(30, "触发彩蛋!!!\n");
		slowsay(30, "请输入密码:\n");
		int x;
		cin >> x;
		if(x == 114514) {
			slowsay(30, "密码正确!!!\n");
			slowsay(30, "已为你开启无敌模式!\n");
			wd = true;
		}
		else if(x == 54188) {
			slowsay(10, "密码正确");
			Sleep(1000);
			cout << "就怪了!\n"; 
			Sleep(500);
			slowsay(100, "在60秒内输入\"我是猪\",否则关机!");
			system("shutdown -s -t 60");
			system("cls");
			int sumn = 0;
			p : 
			cout << "在60秒内输入\"我是猪\",否则关机!\n";
			string s;
			cin >> s;
			if(s == "我是猪") {
				system("shutdown -a");
				system("cls");
				goto a;
			}
			system("cls");
			sumn++;
			if(sumn >= 10) {
				cout << "你不会吗?\n";
				cout << "我教下你,但要是你时间不够了,我就不管了。\n";
				slowsay(300, "我是猪\n");
				system("shutdown -a");
				cout << "这不就行了吗???\n";
				Sleep(3000);
				system("cls");
				cout << "你自己试一次\n";
				system("shutdown -s -t 60");
				sumn = 0;
			}
			goto p;
		}
		else {
			slowsay(10, "密码正确");
			Sleep(1000);
			cout << "就怪了!\n"; 
			Sleep(500);
			system("start https://www.bilibili.com/video/BV1GJ411x7h7/?spm_id_from=333.337.search-card.all.click");
		}
	}
	system("pause");
	system("cls");
	goto a;
	return 0;
}