本文对上期做了删改
话不多说上代码:
注彩色输出部分代码出自博主夜若渊
#include<bits/stdc++.h>
#include<windows.h>
#include<stdlib.h>
#include<cstdio>
#include<iostream>
#include<string>
#include<stdio.h>
#include<ctime>
#include<conio.h>
#include<time.h>
using namespace std;
void JZ()
{
system("cls");
for(int i=1;i<=100;i++)
{
if(i<100)
{
printf("数据加载中...\n");
}
else
{
printf("加载完毕");
}
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ");
for(int j=1;j<=50;j++)
{
printf("_");
}
printf("\n |");
for(int j=1;j<=i/2;j++)
{
printf("▇");
}
printf("\n 当前加载进度:%d%\n",i);
Sleep(5);
system("cls");
}
system("cls");
}
void COLOR_PRINT(const char* s, int color)
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | color);
printf(s);
SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY | 7);
}
//puts("=============================================================================");
/*
0 = 黑色 8 = 灰色
1 = 蓝色 9 = 淡蓝色
2 = 绿色 10 = 淡绿色
3 = 浅绿色 11 = 淡浅绿色
4 = 红色 12 = 淡红色
5 = 紫色 13 = 淡紫色
6 = 黄色 14 = 淡黄色
7 = 白色 15 = 亮白色
*/
//COLOR_PRINT("", );
int x=1,y=1,jbx,jby,dt,g,xz,d,yq=5,js=4,win=0,tgcs=0,tp=0,ywcs=0;
int tg[8];
int nd[8] = {0,1,3,3,1,1,5};
char id;
//地图数组
int Map[8][10][20] =
{
{
{7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7},
{7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7},
{7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7},
{7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7},
{7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7},
{7,0,0,0,0,0,0,0,0,0,0,0,0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,7},
{7,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,7},
{7,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,7},
{7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7},
{7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7},
{7,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,7},
{7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}
},
{
{7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7},
{7,0,0,0,2,2,2,1,1,1,1,0,1,0,2,1,0,0,2,7},
{7,0,0,0,2,2,2,0,0,0,2,2,2,1,2,1,2,1,2,7},
{7,1,1,1,2,2,2,1,1,1,2,2,2,0,2,0,2,0,2,7},
{7,1,1,1,2,2,2,1,1,1,2,2,2,1,2,1,2,1,2,7},
{7,1,1,1,2,2,2,1,1,1,2,2,2,1,2,1,2,1,2,7},
{7,1,1,1,2,2,2,1,1,1,2,2,2,0,2,0,2,0,2,7},
{7,0,0,0,2,2,2,0,0,0,2,2,2,1,2,1,2,1,2,7},
{7,1,1,1,1,0,1,1,1,1,2,2,2,1,0,0,2,0,0,7},
{7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7}
},
};
int main()
{
system("cls");
printf("走迷宫");
Sleep(2500);
JZ();
ZJM:
system("cls");
while(true)
{
printf("1.游玩 2.查看地图 3.自定义角色颜色 4.个人主页 5.关于游戏\n");
cin>>xz;
if(xz==1)
{
printf("请输入关卡序号(0-6)\n");
cin>>d;
if(d==0||d==2||d==4||d==5||d==6)
{
jbx=18;
jby=8;
}
if(d==1)
{
jbx=18;
jby=7;
}
if(d==3)
{
jbx=1;
jby=7;
}
for(int i=0;i<=d;i++)
{
if(tg[i]>0)
{
tp++;
}
}
if(tp<d)
{
printf("前面还有关卡未通过请先通过前面的关卡吧!");
Sleep(1500);
goto ZJM;
}
ywcs++;
while(true)
{
printf("当前关卡编号:%d\n难度:%d\n",d,nd[d]);
printf("当前氧气值:%d\n",yq);
for(int i=0;i<10;i++)
{
for(int j=0;j<20;j++)
{
if(jbx==x&&jby==y)
{
system("cls");
COLOR_PRINT("恭喜过关", 6);
Sleep(2000);
system("cls");
x=1;
y=1;
yq=5;
tgcs++;
goto ZJM;
}
if(yq<=0)
{
system("cls");
printf("氧气值过低,你窒息死亡了");
Sleep(1500);
system("cls");
COLOR_PRINT("Game Over", 6);
Sleep(1500);
system("cls");
x=1;
y=1;
yq=5;
goto ZJM;
}
if(Map[d][y][x]==2)
{
system("cls");
printf("你被毒死了");
Sleep(1500);
system("cls");
COLOR_PRINT("Game Over", 6);
Sleep(1500);
system("cls");
x=1;
y=1;
yq=5;
goto ZJM;
}
if(i==y&&j==x)
{
COLOR_PRINT("█", js);
}
else if(i==jby&&j==jbx)
{
COLOR_PRINT("█", 6);
}
else if(Map[d][i][j]>0)
{
COLOR_PRINT("█", Map[d][i][j]);
}
else
{
printf(" ");
}
}
printf("\n");
}
printf("按wasd移动");
char c = getch();
if(c=='w'||c=='W')
{
if(y>1)
{
y--;
}
}
if(c=='s'||c=='S')
{
if(y<8)
{
y++;
}
}
if(c=='a'||c=='A')
{
if(x>1)
{
x--;
}
}
if(c=='d'||c=='D')
{
if(x<18)
{
x++;
}
}
if(Map[d][y][x]!=1&&yq<5)
{
yq++;
}
if(Map[d][y][x]==1)
{
yq--;
}
system("cls");
}
}
if(xz==2)
{
printf("请输入要查看的关卡序号(0-6)\n");
cin>>d;
for(int i=0;i<10;i++)
{
for(int j=0;j<20;j++)
{
if(Map[d][i][j]>0)
{
COLOR_PRINT("█", Map[d][i][j]);
}
else
{
printf(" ");
}
}
printf("\n");
}
system("pause");
system("cls");
goto ZJM;
}
if(xz==3)
{
printf("请输入颜色编号:(0-15)\n");
printf("颜色对应编号:\n0 = 黑色 8 = 灰色\n1 = 蓝色 9 = 淡蓝色\n2 = 绿色 10 = 淡绿色\n3 = 浅绿色 11 = 淡浅绿色\n4 = 红色 12 = 淡红色\n5 = 紫色 13 = 淡紫色\n6 = 黄色 14 = 淡黄色\n7 = 白色 15 = 亮白色\n注:不推荐跟地图有关系的颜色。\n");
cin>>js;
system("cls");
goto ZJM;
}
if(xz==4)
{
printf("通关率:%0.2lf%\n游玩次数:%d\n通关次数:%d",1.0*tgcs/ywcs*100,ywcs,tgcs);
Sleep(3000);
system("cls");
}
if(xz==5)
{
printf("本游戏为一个走出迷宫的小游戏碰到黄色终点则获胜,不要碰绿色的毒水\n\n\n作者博客:Add123453388\n");
system("pause");
system("cls");
}
}
}
求求了点个赞吧
标签:改良版,int,迷宫,system,c++,xz,printf,include,cls From: https://blog.csdn.net/Add123458833/article/details/142286508