游戏保存站
2026-10-06 11:31:11
发布于:吉林
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define please return
#define AC 0
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
#endif
using namespace std;
int x,y;
int fw=3,bfw=6;
int xm[11]={16};
int ym[11]={64};
int loop=0;
int now_time=1;
const int echo_life=6;
int vis[11][110][110];
int saw[11][110][110];
int stx[11],sty[11];
int mark[110][110];
int csz[200];
bool god=false;
int dis[110][110];
bool ishm[11]={true};
const int dxx[4] = {-1, 1, 0, 0};
const int dyy[4] = { 0, 0,-1, 1};
char mp[11][110][110]={
{
{'.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','#','.','.','.','#','.','.','.','#','#','#','.','.','.','#','.','.','.','#','.','.','#','#','#','#','#','.','.','.','.','#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','#','.','.','#','.','.','.','#','.','.','.','#','.','.','#','.','.','.','#','.','.','.','.','#','.','.','.','.','.','#','.','#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','#','.','#','.','.','.','.','#','.','.','.','#','.','.','#','.','.','.','#','.','.','.','.','#','.','.','.','.','#','.','.','.','#','.','.','.','.','.','#','#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','#','#','.','.','.','.','.','#','.','.','.','#','.','.','#','.','.','.','#','.','.','.','.','#','.','.','.','.','#','.','.','.','#','.','.','.','.','#','.','.','#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','#','#','.','.','.','.','.','#','.','.','.','#','.','.','.','#','.','#','.','.','.','.','.','#','.','.','.','.','#','#','#','#','#','.','.','.','#','.','.','.','.','#','.','.','.','.','#','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','#','.','#','.','.','.','.','#','.','.','.','#','.','.','.','#','.','#','.','.','.','.','.','#','.','.','.','.','#','.','.','.','#','.','.','.','.','.','.','.','.','.','#','.','.','#','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','#','.','.','#','.','.','.','#','.','.','.','#','.','.','.','.','#','.','.','.','.','.','.','#','.','.','.','.','#','.','.','.','#','.','.','.','.','.','.','.','.','.','.','#','#','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','#','.','.','.','#','.','.','.','#','#','#','.','.','.','.','.','#','.','.','.','.','#','#','#','#','#','.','.','#','.','.','.','#','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.'},
{'.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','.','X'}
}
};
struct rgb{
int r,g,b;
};
const rgb Black= {0,0,0}; // 黑色
const rgb White={255,255,255}; // 白色
const rgb Red={255,0,0}; // 红色
const rgb Lime={0,255,0}; // 亮绿 / 青柠绿
const rgb Green={0,128,0}; // 绿色(标准绿,偏暗)
const rgb Blue={0,0,255}; // 蓝色
const rgb Yellow={255,255,0}; // 黄色
const rgb Cyan={0,255,255}; // 青色 / 天蓝绿
const rgb Magenta={255,0,255}; // 洋红 / 品红
const rgb Lightgray={211,211,211}; // 浅灰
const rgb Silver={192,192,192}; // 银灰
const rgb Gray={128,128,128}; // 灰色
const rgb Darkgray={64,64,64}; // 深灰
const rgb Orange={255,165,0}; // 橙色
const rgb Purple={128,0,128}; // 紫色
const rgb Pink={255,192,203}; // 粉色
const rgb Brown={165,42,42}; // 棕色 / 褐色
const rgb Gold={255,215,0}; // 金色
const rgb Navy={0,0,128}; // 藏青 / 深蓝
const rgb Teal={0,128,128}; // 蓝绿 / 水鸭色
const rgb Olive={128,128,0}; // 橄榄绿
const rgb Skyblue={135,206,235}; // 天蓝色
const rgb Tomato={255,99,71}; // 番茄红
const rgb Coral={255,127,80}; // 珊瑚色
const rgb Chocolate={210,105,30}; // 巧克力色
const rgb Indigo={75,0,130}; // 靛蓝 / 靛青色
const rgb Darkred={139,0,0}; // 深红 / 暗红
const rgb Darkgreen={0,100,0}; // 深绿 / 暗绿
const rgb Darkblue={0,0,139}; // 深蓝 / 暗蓝
const rgb Lightyellow={255,255,224}; // 浅黄
const rgb Lightblue={173,216,230}; // 浅蓝
const rgb Lightgreen={144,238,144}; // 浅绿
const rgb Lightpink={255,182,193}; // 浅粉
const rgb Crimson={220,20,60}; // 猩红 / 深红
const rgb Salmon={250,128,114}; // 鲑鱼色 / 橙粉
const rgb Khaki={240,230,140}; // 卡其色
const rgb Violet={238,130,238}; // 紫罗兰
const rgb Turquoise={64,224,208}; // 绿松石 / 青绿
const rgb Dodgerblue={30,144,255}; // 鲜亮蓝
const rgb Midblue={0,128,255}; // 中蓝
const rgb Royalblue={65,105,225}; // 庄重中蓝
const rgb echo[6]={Red,Orange,Yellow,Lime,Midblue,Purple};
void outf(string s,int r,int g,int b){
printf("\033[38;2;%d;%d;%dm%s\033[0m",r,g,b,s.c_str());
}
void outb(string s,int r,int g,int b){
printf("\033[48;2;%d;%d;%dm%s\033[0m",r,g,b,s.c_str());
}
void outfb(string s,int fr,int fg,int fb,int br,int bg,int bb){
printf("\033[38;2;%d;%d;%dm\033[48;2;%d;%d;%dm%s%s\033[0m",fr,fg,fb,br,bg,bb,s.c_str());
}
void outf(string s,rgb x){
outf(s,x.r,x.g,x.b);
}
void outb(string s,rgb x){
outb(s,x.r,x.g,x.b);
}
void outfb(string s,rgb fx,rgb bx){
outfb(s,fx.r,fx.g,fx.b,bx.r,bx.g,bx.b);
}
void wait(int t){
Sleep(t);
}
int getkey(int t){
if(t==-1){
while(true){
if(_kbhit()) return _getch();
Sleep(1);
}
}
else if(t==0){
if(_kbhit()) return _getch();
return -1;
}
else{
int st=GetTickCount();
while(GetTickCount()-st<t){
if(_kbhit()) return _getch();
Sleep(1);
}
return -1;
}
}
void bfsmk(int loop,int sr,int sc,int id){
queue<pair<int,int>>q;
q.push({sr,sc});
mark[sr][sc]=id;
int cnt=0;
while(!q.empty()){
auto a=q.front();
q.pop();
int r=a.first,c=a.second;
cnt++;
for(int d=0;d<4;d++){
int nx=r+dxx[d],ny=c+dyy[d];
if(nx<0||nx>=xm[loop]||ny<0||ny>=ym[loop]) continue;
if(mp[loop][nx][ny]=='#') continue;
if(mark[nx][ny]) continue;
mark[nx][ny]=id;
q.push({nx,ny});
}
}
csz[id]=cnt;
}
void klst(int loop){
memset(mark,0,sizeof(mark));
memset(csz,0,sizeof(csz));
int id=0;
for(int i=0;i<xm[loop];i++){
for(int j=0;j<ym[loop];j++){
if(mp[loop][i][j]!='#'&&mark[i][j]==0) bfsmk(loop,i,j,++id);
}
}
if(id==0) return;
int bst=1;
for(int k=2;k<=id;k++){
if(csz[k]>csz[bst]) bst=k;
}
for(int i=0;i<xm[loop];i++){
for(int j=0;j<ym[loop];j++){
if(mp[loop][i][j]!='#'&&mark[i][j]!=bst) mp[loop][i][j]='#';
}
}
}
pair<int,int>ffst(int loop,int sx,int sy){
memset(dis,-1,sizeof(dis));
queue<pair<int,int>>q;
q.push({sx,sy});
dis[sx][sy]=0;
int bx=sx,by=sy,bd=0;
while(!q.empty()){
auto a=q.front();
q.pop();
int r=a.first,c=a.second;
if(dis[r][c]>bd){
bd=dis[r][c];
bx=r;
by=c;
}
for(int d=0;d<4;d++){
int nx=r+dxx[d],ny=c+dyy[d];
if(nx<0||nx>=xm[loop]||ny<0||ny>=ym[loop]) continue;
if(mp[loop][nx][ny]=='#') continue;
if(dis[nx][ny]!=-1) continue;
dis[nx][ny]=dis[r][c]+1;
q.push({nx,ny});
}
}
return{bx,by};
}
void genrms(int loop,int w,int h,int tr,int rmin,int rmax){
xm[loop]=w;
ym[loop]=h;
for(int i=0;i<w;i++){
for(int j=0;j<h;j++){
mp[loop][i][j]='#';
}
}
struct Rm{int r1,c1,r2,c2;};
Rm rms[30];
int rn=0,att=0,mxatt=tr*30;
while(rn<tr&&att<mxatt){
att++;
int rh=rmin+rand()%(rmax-rmin+1);
int rw=rmin+rand()%(rmax-rmin+1);
if(w-rh-2<1||h-rw-2<1) continue;
int r1=1+rand()%(w-rh-2);
int c1=1+rand()%(h-rw-2);
int r2=r1+rh-1,c2=c1+rw-1;
bool ok=true;
for(int t=0;t<rn;t++){
if(!(r2+1<rms[t].r1||rms[t].r2+1<r1||c2+1<rms[t].c1||rms[t].c2+1<c1)){
ok=false;
break;
}
}
if(ok) rms[rn++]={r1,c1,r2,c2};
}
for(int k=0;k<rn;k++){
for(int i=rms[k].r1;i<=rms[k].r2;i++){
for(int j=rms[k].c1;j<=rms[k].c2;j++){
mp[loop][i][j]='.';
}
}
}
for(int k=0;k+1<rn;k++){
int ar=(rms[k].r1+rms[k].r2)/2;
int ac=(rms[k].c1+rms[k].c2)/2;
int br=(rms[k+1].r1+rms[k+1].r2)/2;
int bc=(rms[k+1].c1+rms[k+1].c2)/2;
if(rand()%2){
for(int c=min(ac,bc);c<=max(ac,bc);c++) mp[loop][ar][c]='.';
for(int r=min(ar,br);r<=max(ar,br);r++) mp[loop][r][bc]='.';
}else{
for(int r=min(ar,br);r<=max(ar,br);r++) mp[loop][r][ac]='.';
for(int c=min(ac,bc);c<=max(ac,bc);c++) mp[loop][br][c]='.';
}
}
}
void genmap(int loop){
if(ishm[loop]){
stx[loop]=0;
sty[loop]=0;
return;
}
int w=min(14+loop,100);
int h=min(50+loop*3,100);
int rc=4+loop;
genrms(loop,w,h,rc,3,6);
klst(loop);
int sr=-1,sc=-1;
for(int i=0;i<w&&sr<0;i++){
for(int j=0;j<h&&sr<0;j++){
if(mp[loop][i][j]=='.'){
sr=i;
sc=j;
}
}
}
if(sr<0) return;
auto a=ffst(loop,sr,sc);
int ex=a.first,ey=a.second;
mp[loop][ex][ey]='X';
auto b=ffst(loop,ex,ey);
stx[loop]=b.first;
sty[loop]=b.second;
}
bool lclear(int x,int y,int xx,int yy){
int dx=abs(xx-x),dy=abs(yy-y);
int sx=(x<xx)?1:-1;
int sy=(y<yy)?1:-1;
int ee=dx-dy;
int nx=x,ny=y;
while(nx!=xx||ny!=yy){
int ne=2*ee;
if(ne>-dy){
ee-=dy;
nx+=sx;
}
if(ne<dx){
ee+=dx;
ny+=sy;
}
if(nx==xx&&ny==yy) return true;
if(mp[loop][nx][ny]=='#') return false;
}
}
void gotoxy(int x,int y){
COORD c={(SHORT)x,(SHORT)y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}
void cls(){
gotoxy(0,0);
}
void render(){
cls();
for(int i=0;i<xm[loop];i++){
for(int j=0;j<ym[loop];j++){
if(i==x&&j==y){
outf("@",Cyan);
}else if(vis[loop][i][j]&&now_time-vis[loop][i][j]<=echo_life){
outf("o",echo[now_time-vis[loop][i][j]-1]);
}else if(((i-x)*(i-x)+(j-y)*(j-y)<=fw*fw&&lclear(x,y,i,j))||god){
printf("%c",mp[loop][i][j]);
if((i-x)*(i-x)+(j-y)*(j-y)<=fw*fw&&lclear(x,y,i,j)) saw[loop][i][j]=now_time;
}else if(saw[loop][i][j]&&now_time-saw[loop][i][j]<=20){
outf(string(1,mp[loop][i][j]),Darkgray);
}else if(saw[loop][i][j]&&(i-x)*(i-x)+(j-y)*(j-y)<=bfw*bfw){
outf(string(1,mp[loop][i][j]),Darkgray);
}else putchar(' ');
}
printf("\033[K\n");
}
}
void domove(int dx,int dy){
int nx=x+dx,ny=y+dy;
if(nx>=0&&nx<xm[loop]&&ny>=0&&ny<ym[loop]&&mp[loop][nx][ny]!='#'){
vis[loop][x][y]=now_time;
x=nx,y=ny;
}
if(mp[loop][x][y]=='X'){
loop++;
system("cls");
god=false;
now_time=1;
if(loop>10){
outf("通关!",Gold);
exit(0);
}
genmap(loop);
x=stx[loop];
y=sty[loop];
}
now_time++;
}
bool checkkey(char c){
switch(c){
case'a':
case'A':{
domove(0,-1);
return true;
}
case'w':
case'W':{
domove(-1,0);
return true;
}
case's':
case'S':{
domove(1,0);
return true;
}
case'd':
case'D':{
domove(0,1);
return true;
}
case' ':{
now_time++;
return true;
}
case'q':
case'Q':{
god=!god;
return true;
}
default:return false;
}
}
void okansi(){
#ifdef _WIN32
HANDLE h=GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode=0;
GetConsoleMode(h,&mode);
SetConsoleMode(h,mode|ENABLE_VIRTUAL_TERMINAL_PROCESSING);
#endif
}
int main(){
// freopen("data.in","r",stdin);
// freopen("user.out","w",stdout);
srand(time(0));
okansi();
x=y=0;
while(1){
render();
while(!checkkey(getkey(-1)));
}
please AC;
}
这里空空如也




















有帮助,赞一个