这是@ __PJL__制作的第一款游戏,希望大家点赞支持qwq!
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
#include<thread>
using namespace std;
const int MAXN = 21;
int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int len, x, y, Level = 1, hp = 3, CD = 0; // len是子弹数量
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') {
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') {
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') {
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') {
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') {
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) {
a :
system("cls");
len = CD = 0;
if(hp <= 0) {
cout << "你的hp没有了!\n";
system("pause");
system("cls");
return;
}
MAP();
x = 2, y = 2;
die = false;
while(1) {
cout << "第" << Level << "关\n";
cout << "HP : " << hp << "\n";
for(int i = 1; i <= 20; i++) {
for(int j = 1; j <= 20; j++) {
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') {
hp--;
cout << "你死了!\n";
Sleep(2000);
goto a;
}
M();
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) {
cout << (c[i][j] == 'Z' || die ? 'Z' : '@');
}
else {
cout << c[i][j];
}
}
cout << "\n";
}
if(c[x][y] == 'Z' || die == true) {
hp--;
cout << "你死了!\n";
Sleep(2000);
goto a;
}
else {
cout << "你过关了!";
Sleep(2000);
Level++;
goto a;
}
}
c[x][y] = '@';
Sleep(10);
system("cls");
}
}
void gz() {
slowsay(10, "在这个游戏中,'#'是墙,'.'是路,你的位置是'@',终点是L,WASD移动\n");
system("pause");
slowsay(10, "迷宫里当然也不是绝对安全,会有一些怪物,P就是怪物。\n");
system("pause");
slowsay(10, "TA虽然不会移动,但是怪物会向你发射子弹,敌人的子弹是'Z'。你被打到就会死翘翘,当然,你也可以跑过去徒手干掉它。。。\n");
system("pause");
slowsay(10, "在迷宫里,会有一些道具,V是回血的道具。注意,如果子弹打到道具,道具将被摧毁。当然,怪物也会被怪物打死。");
system("pause");
slowsay(10, "如果你发现地图有问题,按Q刷新地图\n");
system("pause");
slowsay(10, "接下来其他内容,就靠你自己探索了qwq\n");
}
int main() {
srand(time(0));
cout << "版权 __PJL__\n 日期 2024/5/17\n 语言 C++\n\n\n";
slowsay(10, "欢迎游玩由__PJL__制作的迷宫游戏\n");
cout << " ■ ■ ■ ■■■■■ ■■■■■\n";
cout << " ■ ■ ■■ ■■ ■ ■\n";
cout << " ■ ■ ■ ■ ■ ■ ■ ■■■■■\n";
cout << " ■ ■■ ■ ■■■■ ■ ■\n";
cout << "■ ■ ■ ■ ■ ■■■■■ ■■■■■\n";
system("pause");
cout << "正在加载……";
system("cls");
for(int i = 1; i <= 100; i++) {
cout << "loading...\n";
cout << i << "%\n";
Sleep(5);
system("cls");
}
a :
hp = 3, Level = 1, len = 0;
int x;
cout << "1. 开始游戏 2. 介绍规则\n";
cin >> x;
if(x == 1) {
game(1);
}
else if(x == 2) {
gz();
}
system("pause");
system("cls");
goto a;
return 0;
}改编的地狱难度游戏
#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"; // 重置颜色
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 = 50;
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') {
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') {
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') {
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') {
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') {
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 <= 30) {
c[i][j] = 'P';
}
else {
c[i][j] = 'V';
}
}
}
}
c[2][2] = '@', c[19][19] = 'L';
}
void game(int p) {
cout << "这个游戏是由PJL改编的!\n";
cout << "难度较高,但是被PJL削了,所以不难!\n";
system("pause");
system("cls");
cout << "废话不多说,开始游戏!";
Sleep(500);
system("cls");
a :
system("cls");
len = CD = 0;
ICD = 10;
if(hp <= 0) {
cout << "你的hp没有了!\n";
return;
}
MAP();
x = 2, y = 2;
die = false;
while(1) {
ICD = max(ICD - 1, 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') {
BLUE("J");
c[i][j] = '.';
}
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++;
}
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 = 5, ICD = 10;
}
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) {
cout << 'Z';
}
else {
if(c[i][j] == 'J') {
BLUE('J');
}
else {
cout << c[i][j];
}
}
}
cout << "\n";
}
hp--;
cout << "你死了!\n";
Sleep(2000);
goto a;
}
if(stop <= 0) {
system("color 0F");
M();
}
else {
system("color 16");
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) {
cout << (c[i][j] == 'Z' || die ? 'Z' : '@');
}
else {
if(c[i][j] == 'J') {
BLUE('J');
}
else {
cout << c[i][j];
}
}
}
cout << "\n";
}
if(c[x][y] == 'Z' || die == true) {
hp--;
cout << "你死了!\n";
Sleep(2000);
goto a;
}
else {
cout << "你过关了!";
Sleep(2000);
Level++;
goto a;
}
}
c[x][y] = '@';
Sleep(10);
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, "如果你发现地图有问题,按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");
cout << " ■ ■ ■ ■■■■■ ■■■■■\n";
cout << " ■ ■ ■■ ■■ ■ ■\n";
cout << " ■ ■ ■ ■ ■ ■ ■ ■■■■■\n";
cout << " ■ ■■ ■ ■■■■ ■ ■\n";
cout << "■ ■ ■ ■ ■ ■■■■■ ■■■■■\n";
system("pause");
cout << "正在加载……";
system("cls");
for(int i = 1; i <= 100; i++) {
cout << "loading...\n";
cout << i << "%\n";
Sleep(5);
system("cls");
}
a :
system("color 0F") ;
hp = 3, Level = 1, len = 0;
int x;
cout << "1. 开始游戏 2. 介绍规则\n";
cin >> x;
if(x == 1) {
game(1);
}
else if(x == 2) {
gz();
}
system("pause");
system("cls");
goto a;
return 0;
}