延续上一期
一、海岛奇胎
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
using namespace std;
typedef BOOL (WINAPI *PROCSETCONSOLEFONT)(HANDLE, DWORD);
PROCSETCONSOLEFONT SetConsoleFont;
POINT Windowpos(){POINT pt;GetCursorPos(&pt);HWND h=GetForegroundWindow();ScreenToClient(h,&pt);pt.x=(pt.x+4)/10+0.5;pt.y=pt.y/8+0.5;swap(pt.x,pt.y);return pt;}
int mouse;POINT pt;float kx,ky;int ti(float a) {return ((int)(a*10+5))/10;}
void Print(int a){HMODULE hKernel32 = GetModuleHandle("kernel32");SetConsoleFont = (PROCSETCONSOLEFONT)GetProcAddress(hKernel32,"SetConsoleFont");SetConsoleFont(GetStdHandle(STD_OUTPUT_HANDLE),a);}
void Setpos(float x,float y){COORD pos;pos.X=ti(y*4)/2;pos.Y=ti(x);SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
//Setpos中,横5和竖5是一样的长度,在C,N中我们把y*2存入,/2输出 ,所以 支持4.5
struct node {float x,y,fx,fy;int kind,staytime,blood,CD,enemy,turn=6;bool life;} M[100001],E[100001];//Mytower Enemy Bullet
struct bullet {float x,y,vx,vy,h;int kind,staytime,enemy,endx,endy,up;bool life;} B[100001];//,ice,medical,durg,
float Espeed[7]= {-1, 0.14, 0.2, 0.08, 0.3, 0.3, 0.1};//敌人速度
float Bspeed[7]= {-1, 0.6, 0.6, 0.6, 1, 0.1, 0.6};//打塔的子弹速度
float Bfspeed[7]= {-1, 0.4, 0.4, -1, 0.3, 1, 0.4};//打敌的子弹速度
float MR[7]= {-1, 12, 10, 25, 8, 15, 20};
float ER[7]= {-1, 5, 1.8, 8, 7, 1, 10};
int MCDmax[7]= {10000, 10, 7, 60, 2, 90, 50};
int ECDmax[7]= {-1, 30, 10, 40, 25, 1, 40};
int Mblood[7]= {-1,200,150,300,250,400,300};
int Eblood[7]= {-1,50,100,30,100,10,200};
bool Zhan[50][50];
//Pk_Pb : personkill_or_placeboom
int m[51][101],n[51][101],o[51][101],T,CD,CDmax,Day,ml,mr,el,er,bl,br,money,Level=1,endless;
void Color(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_INTENSITY|FOREGROUND_BLUE);
}
void C(int i,int j){Color(0);
Setpos(i,j/2.0);int N=n[i][j];if(N==-1) printf(" ");if(N>=0&&N<=9) printf("%d",N);
if(N==-2) printf("+");if(N==-3) Color(5),printf("+"),n[i][j]=-1,o[i][j]=4;if(N==-4) Color(3),printf("+"),n[i][j]=-1,o[i][j]=4;
//以下字符占2格
if(N==11) Color(1),printf("О");if(N==13) Color(3),printf("◎");if(N==14) Color(4),printf("+");if(N==16) Color(5),printf("◎");
if(N==-11) Color(1),printf("⊙");if(N==-12) Color(2),printf("⊙");if(N==-13) Color(3),printf("⊙");if(N==-14) Color(4+rand()%2),printf("█");if(N==-15) Color(1),printf("●");if(N==-16) Color(5),printf("¤");
if(N==49) Color(0),printf("营");if(N==50) Color(0),printf("墙");if(N==51) Color(1),printf("●");if(N==52) Color(2),printf("■");if(N==53) Color(3),printf("▲");if(N==54) Color(4),printf("▼");if(N==55) Color(6),printf("◆");if(N==56) Color(5),printf("★");
if(N==81) Color(1),printf("○");if(N==82) Color(2),printf("□");if(N==83) Color(3),printf("△");if(N==84) Color(4),printf("▽");if(N==85) Color(6),printf("◇");if(N==86) Color(5),printf("☆");
if(N==1001) printf("╔");//if(N==1002) printf("╦");
if(N==1003) printf("╗");if(N==1004) printf("╠");if(N==1005) printf("╣");if(N==1006) printf("╚");if(N==1007) printf("╩");if(N==1008) printf("╝");
if(N==1011) printf("↖");if(N==1012) printf("↑");if(N==1013) printf("↗");if(N==1014) printf("←");if(N==1015) printf("→");if(N==1016) printf("↙");if(N==1017) printf("↓");if(N==1018) printf("↘");
}
void Map(int a){if(a==1){for(int i=1;i<=50;i++)for(int j=1;j<=100;j++){
if(n[i][j]!=m[i][j]||T%800==0){C(i,j);if(n[i][j]>=50||n[i][j]<=-10) n[i][j+1]=-1,j++;}
if(o[i][j]==1) C(i,j);if(o[i][j]>0) o[i][j]--;
}
for(int i=1;i<=50;i++)for(int j=1;j<=100;j++){m[i][j]=n[i][j];}}
}
void N(float x,float y,int w){int xx=(int)(x+0.5),yy=(int)(y*2.0+0.5);if(xx>49||yy>98||xx<1||yy<1) return;else n[xx][yy]=w;}
int Turn[9][2]={{0,0},{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
void Circle(int x,int y,int kind,int ex)
{int R;
if(kind==1){int k=M[ex].kind;R=MR[k];int next=20-0.5*R;
for(int i=0;i<=360;i+=next) N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-2);
if(k==3) for(int i=0;i<=360;i+=15) R=10,N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-2);
}
if(kind==-1){int k=M[ex].kind;R=MR[k];int next=20-0.5*R;
for(int i=0;i<=360;i+=next) N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-1);
if(k==3) for(int i=0;i<=360;i+=15) R=10,N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-1);
}
if(kind==2){R=ex;int next=20-0.5*R;
for(int i=0;i<=360;i+=next) N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-3);
}
if(kind==-2){R=ex;int next=20-0.5*R;
for(int i=0;i<=360;i+=next) N(x+R*sin(3.1416*i/180),y+R*cos(3.1416*i/180),-4);
}
}
void Cout(int a,int kind){
if(kind==1)//炮台
{
float x=M[a].x,y=M[a].y;
N(x,y,M[a].kind+50);
if(a==1) N(x,y,49);
int i=1;if(M[a].blood>=100) i=2;
for(i;i<=8;i++) N(x+Turn[i][0],y+Turn[i][1],1000+i),Zhan[(int)x+Turn[i][0]][(int)y+Turn[i][1]]=1;
int t=M[a].turn;
// N(Turn[t][0],y+Turn[t][1],1010+t);
int b=max(0,M[a].blood),bb=0;while(b>0){bb++;N(x-1,y+1-0.5*bb,b%10);b/=10;}
}
if(kind==2)//人
{
float x=E[a].x,y=E[a].y;
N(x,y,E[a].kind+80);
N(x+1,y,1012);//
Zhan[(int)x][(int)y]=Zhan[(int)x+1][(int)y]=1;
// N(x+1,y,1010+E[a].turn);
int b=max(0,E[a].blood),bb=0;while(b>0){bb++;N(x-1,y+1-0.5*bb,b%10);b/=10;}
}
if(kind==3)//对塔子弹
{
float x=B[a].x,y=B[a].y;
N(x,y,10+B[a].kind);
}
if(kind==4)//对人子弹
{
float x=B[a].x,y=B[a].y;
N(x-B[a].h,y,-10+B[a].kind);
}
}
int Find_enemy(int Who,int good_or_bad){
int ans=-1,r=rand()%2;float ansx=1e9,x;//搜敌人
if(good_or_bad>=1){float X=M[Who].x,Y=M[Who].y;
if(good_or_bad==2) X=E[Who].x,Y=E[Who].y;
for(int i=el;i<=er;i++){if(E[i].life==0) continue;x=sqrt((E[i].x-X)*(E[i].x-X)+(E[i].y-Y)*(E[i].y-Y));
if(good_or_bad==2&&E[i].kind==4) continue;
if(M[Who].kind==3&&x<10) continue;//迫击炮
if(M[Who].kind==6&&ans!=-1&&ansx>x) ansx=x;//火箭炮
if(ansx>x) ansx=x,ans=i;
if(ansx==x) {int r=rand()%2;if(r==1) ansx=x,ans=i;}}}
if(good_or_bad==0){float X=E[Who].x,Y=E[Who].y;for(int i=ml;i<=mr;i++) {if(M[i].life==0) continue;x=sqrt((M[i].x-X)*(M[i].x-X)+(M[i].y-Y)*(M[i].y-Y));if(ansx>x) ansx=x,ans=i;if(ansx==x) {int r=rand()%2;if(r==1) ansx=x,ans=i;}}}
return ans;
}
void Find_boomkill(int Who,float r,bool good_or_bad,int kill){
float x,X=B[Who].x,Y=B[Who].y;int kk=(float)kill/2.5;kill+=rand()%kk-kk/5;
if(good_or_bad==1){for(int i=el;i<=er;i++){if(E[i].life==0) continue;x=sqrt((E[i].x-X)*(E[i].x-X)+(E[i].y-Y)*(E[i].y-Y));if(r>=x) E[i].blood=min(E[i].blood-kill,Eblood[E[i].kind]+Day+50);}
}//搜敌人
else{for(int i=ml;i<=mr;i++){if(M[i].life==0) continue;x=sqrt((M[i].x-X)*(M[i].x-X)+(M[i].y-Y)*(M[i].y-Y));if(r>=x) M[i].blood-=kill;}
}//搜炮台
}
void Die(){
for(int i=ml;i<=mr;i++){
if(M[i].blood<=0) M[i].life=0;
// if(M[i].life==0&&i==ml) ml++;
}
for(int i=el;i<=er;i++){
if(E[i].blood<=0) E[i].life=0;
// if(E[i].life==0&&i==el) el++;
}
for(int i=bl;i<=br;i++){
if(B[i].x+B[i].vx<1||B[i].x+B[i].vx>49||B[i].y+B[i].vy<1||B[i].y+B[i].vy>98) {B[i].life=0;}
if(B[i].staytime>=100) B[i].life=0;
// if(B[i].life==0&&i==bl) bl++;
}
// if(el>er) el=er=0,memset(E,0,sizeof(E));if(bl>br) bl=br=0,memset(B,0,sizeof(B));
}
void Move(int a){
if(a==2)
{
for(int i=ml;i<=mr;i++){if(M[i].life==0) continue;Cout(i,1);}
for(int i=el;i<=er;i++){if(E[i].life==0) continue;Cout(i,2);}
return;
}
for(int i=ml;i<=mr;i++){
if(M[i].life==0) continue;
else{M[i].staytime++;int e=M[i].enemy;if(E[e].life==0) M[i].enemy=-1;
if(M[i].kind==5&&M[i].enemy==-1&&M[i].CD<=70&&T%2==0) M[i].CD++;
if(M[i].kind==0&&M[i].blood<=500&&T%20==0) M[i].blood++;
if(M[i].enemy==-1||M[i].kind==4) M[i].enemy=Find_enemy(i,1);//喷火器
if(M[i].enemy!=-1)
{int k=M[i].enemy;
float X=M[i].x,Y=M[i].y,Ax=E[k].x-X,Ay=E[k].y-Y;if(Ay==0) Ay=1e-6;float Turnn=abs(Ax/Ay*1.0),Dis=sqrt((E[k].x-X)*(E[k].x-X)+(E[k].y-Y)*(E[k].y-Y));
if(Dis>MR[M[i].kind]){M[i].enemy=-1;}
else
{M[i].CD++;
if((M[i].kind!=6&&M[i].CD>=MCDmax[M[i].kind])||(M[i].kind==6&&M[i].CD<=21&&M[i].CD%4==0))//火箭炮
{
if(M[i].kind==6) M[i].enemy=Find_enemy(i,1);
if(Turnn>=sqrt(2)+1){if(Ay>0) M[i].turn=2;else M[i].turn=7;}
else if(Turnn>=1.0/(sqrt(2)+1)*1.0){if(Ax>0&&Ay>0) M[i].turn=1;else if(Ax<0&&Ay>0) M[i].turn=3;else if(Ax<0&&Ay<0) M[i].turn=8;else M[i].turn=6;}
else {if(Ax>0) M[i].turn=5;else M[i].turn=4;}
br++,B[br].x=X,B[br].y=Y;
B[br].kind=-M[i].kind;///
B[br].life=1,B[br].enemy=M[i].enemy,B[br].endx=E[M[i].enemy].x,B[br].endy=E[M[i].enemy].y,B[br].staytime=0;
}
if(M[i].CD>=MCDmax[M[i].kind]) M[i].CD=0;
}
}Cout(i,1);}}
for(int i=el;i<=er;i++){
if(E[i].life==0) continue;
else{E[i].staytime++;E[i].CD++;
int e=E[i].enemy;if(M[e].life==0||(E[i].kind==4&&E[e].life==0)) E[i].enemy=-1;
// if(T%100==1) E[i].enemy=-1;
if(E[i].enemy==-1) {E[i].enemy=Find_enemy(i,0);if(E[i].kind==4) E[i].enemy=Find_enemy(i,2);}
if(E[i].enemy!=-1){int k=E[i].enemy;int Mkx=M[k].x;int Mky=M[k].y;if(E[i].kind==4) Mkx=E[k].x,Mky=E[k].y;
float X=E[i].x,Y=E[i].y;float Dis=sqrt((Mkx-X)*(Mkx-X)+(Mky-Y)*(Mky-Y));
float Ax=Mkx-X,Ay=Mky-Y,S=Espeed[E[i].kind];if(Ay==0) Ay=1e-6;float Turnn=abs(Ax/Ay*1.0);
if(Dis>ER[E[i].kind]){float vx=Ax*S/Dis*1.0,vy=Ay*S/Dis*1.0;E[i].x+=vx,E[i].y+=vy;}
else{
if(E[i].CD>=ECDmax[E[i].kind]){
// if(Turnn>=sqrt(2)+1){if(Ay>0) E[i].turn=7;else E[i].turn=2;}
// else if(Turnn>=1.0/(sqrt(2)+1)*1.0){if(Ax>0&&Ay>0) E[i].turn=8;else if(Ax<0&&Ay>0) E[i].turn=6;else if(Ax<0&&Ay<0) E[i].turn=1;else E[i].turn=3;}
// else {if(Ax>0) E[i].turn=4;else E[i].turn=5;}
if(E[i].kind==5) E[i].blood=-1;//炮灰 ///
if(E[i].kind==4){
br++,B[br].x=X,B[br].y=Y;
B[br].kind=4;///
B[br].life=1,B[br].enemy=E[i].enemy,B[br].endx=E[E[i].enemy].x,B[br].endy=E[E[i].enemy].y,B[br].staytime=0;
}
else{
br++,B[br].x=X,B[br].y=Y;
B[br].kind=E[i].kind;///
B[br].life=1,B[br].enemy=E[i].enemy,B[br].endx=M[E[i].enemy].x,B[br].endy=M[E[i].enemy].y,B[br].staytime=0;
}
E[i].CD=0;}
}
}Cout(i,2);
}
}
for(int i=bl;i<=br;i++){
if(B[i].life==0) continue;
else if(B[i].kind>0)//对塔子弹 >0
{
B[i].staytime++;
int k=B[i].enemy;
int Mkl=M[k].life,Mkx=M[k].x,Mky=M[k].y;
if(B[i].kind==4) Mkl=B[k].life,Mkx=B[k].x,Mky=B[k].y;
if(k!=-1&&Mkl==1) B[i].endx=Mkx,B[i].endy=Mky;
float kx=B[i].endx,ky=B[i].endy,X=B[i].x,Y=B[i].y;float Ax=kx-X,Ay=ky-Y,S=Bspeed[B[i].kind];float Dis=sqrt(Ax*Ax+Ay*Ay);float vx=Ax*S/Dis*1.0,vy=Ay*S/Dis*1.0;
B[i].x+=vx,B[i].y+=vy;//别改,对的!
if(Dis<=S){
//打中了,减血
B[i].x=B[i].endx,B[i].y=B[i].endy;
if(B[i].kind==1) Find_boomkill(i,1.5,0,20),Circle(B[i].endx,B[i].endy,-2,1);
if(B[i].kind==2) Find_boomkill(i,1.5,0,10),Circle(B[i].endx,B[i].endy,-2,1);
if(B[i].kind==3) Find_boomkill(i,3,0,20),Circle(B[i].endx,B[i].endy,-2,3);
if(B[i].kind==4) Find_boomkill(i,2,1,-5),Circle(B[i].endx,B[i].endy,-2,2);
if(B[i].kind==5) Find_boomkill(i,3,0,50),Circle(B[i].endx,B[i].endy,-2,3);//炮灰
if(B[i].kind==6) Find_boomkill(i,2,0,20),Circle(B[i].endx,B[i].endy,-2,2);
B[i].life=0;continue;
}
Cout(i,3);
}
else//对人子弹 <0
{
B[i].staytime++;
int k=B[i].enemy;if(k!=-1&&E[k].life==1) B[i].endx=E[k].x,B[i].endy=E[k].y;
float kx=B[i].endx,ky=B[i].endy,X=B[i].x,Y=B[i].y;float Ax=kx-X,Ay=ky-Y,S=Bfspeed[-B[i].kind];float Dis=sqrt(Ax*Ax+Ay*Ay);float vx=Ax*S/Dis*1.0,vy=Ay*S/Dis*1.0;
if(B[i].kind==-3){B[i].x+=1.0/(49.0-B[i].staytime)*Ax;B[i].y+=1.0/(49.0-B[i].staytime)*Ay;
if(T%2==0){
if(B[i].up==1){if(B[i].h<3) B[i].h++;else if(B[i].h<6) B[i].h+=0.5;else B[i].up++;}else if(B[i].up<=6) B[i].up++;else{if(B[i].h>3) B[i].h-=0.5;else B[i].h--;}}
}
else B[i].x+=vx,B[i].y+=vy;//抛物线
if(B[i].kind==-3&&B[i].staytime>=48) {B[i].x=B[i].endx,B[i].y=B[i].endy,Find_boomkill(i,5,1,30),Circle(B[i].endx,B[i].endy,2,4);B[i].life=0;continue;}
else if(B[i].kind!=-3&&Dis<=S)//打中了,减血
{
if(B[br].kind==-2) B[i].endx+=rand()%7-3,B[i].endy+=rand()%7-3;//重机枪
B[i].x=B[i].endx,B[i].y=B[i].endy;
if(B[i].kind==-1) Find_boomkill(i,2,1,20),Circle(B[i].endx,B[i].endy,2,2);
if(B[i].kind==-2) Find_boomkill(i,2,1,20),Circle(B[i].endx,B[i].endy,2,2);
if(B[i].kind==-4) Find_boomkill(i,2,1,5),Circle(B[i].endx,B[i].endy,2,2);
if(B[i].kind==-5) Find_boomkill(i,3,1,120),Circle(B[i].endx,B[i].endy,2,3);
if(B[i].kind==-6) Find_boomkill(i,3,1,40),Circle(B[i].endx,B[i].endy,2,3);
B[i].life=0;continue;
}
Cout(i,4);
}
}
Die();//开始处理 life=0,前面不要有 life=0
}
void StartWar(int D)
{
for(int i=-1;i<=(int)T/1000;i++){
int XY=rand()%4,W=rand()%49+1,x,y,k,R=rand()%100;
if(Level==2) XY=3;if(Level==3) XY=3*(rand()%2);
if(XY==0) x=1,y=W;if(XY==1) x=49,y=W;if(XY==2) x=W,y=1;if(XY==3) x=W,y=49;
k=rand()%6+1;///
er++,E[er].x=x,E[er].y=y,E[er].kind=k,E[er].life=1,E[er].blood=Eblood[k]+Day;
}
}
void Start()
{Color(0);
Setpos(51,0),printf("┏━━┓┏━━┓┏━━┓┏━━┓┏━━┓┏━━┓");
Setpos(52,0),printf("┃$100┃┃$120┃┃$150┃┃$180┃┃$200┃┃$250┃");
Setpos(53,0),printf("┃ ● ┃┃ ■ ┃┃ ▲ ┃┃ ▼ ┃┃ ◆ ┃┃ ★ ┃");Setpos(53,30),printf("Money: %d ",money);
Setpos(54,0),printf("┗━━┛┗━━┛┗━━┛┗━━┛┗━━┛┗━━┛");Setpos(53,40),printf("Day: %d ",Day);
}
void Click()
{
int What;
pt=Windowpos();
if(pt.x<50||pt.y>25) return;
else What=pt.y/4+1;
if(What==1) if(money>=100) money-=100;else return;
if(What==2) if(money>=120) money-=120;else return;
if(What==3) if(money>=150) money-=150;else return;
if(What==4) if(money>=180) money-=180;else return;
if(What==5) if(money>=200) money-=200;else return;
if(What==6) if(money>=250) money-=250;else return;
Color(0),Setpos(53,30),printf("Money: %d ",money);
mr++;M[mr].x=25;M[mr].kind=What;M[mr].blood=Mblood[What];M[mr].life=1;M[mr].CD=MCDmax[What]-1;
while(mouse)
{
mouse=GetAsyncKeyState(VK_LBUTTON)&0x8000;
pt=Windowpos();
M[mr].x=min(48,max(2,(int)pt.x)),M[mr].y=min(48,max(2,(int)pt.y));
Circle(M[mr].x,M[mr].y,1,mr);
Move(2);Map(1);Sleep(30);
for(int i=0;i<=8;i++) N(M[mr].x+Turn[i][0],M[mr].y+Turn[i][1],-1),N(M[mr].x+Turn[i][0],M[mr].y+Turn[i][1]+0.5,-1);
Circle(M[mr].x,M[mr].y,-1,mr);
}
system("cls");memset(n,-1,sizeof(n));memset(m,-1,sizeof(m));Start();
}
void Menu()
{
system("mode con cols=50 lines=28");Print(1);Color(0);
Setpos(5,7);cout<<"欢迎来到 海岛奇胎 !";
Setpos(7,12);cout<<"作者:胎神大大";
Setpos(8,12);cout<<"原名:城市守卫战 3.0";
Setpos(10,2);cout<<"规则:见城市守卫战,略有调整,可以自己摸索!";
Setpos(12,5);cout<<"请选择地图:";Setpos(13,7);cout<<"1.围城 ";Setpos(14,7);cout<<"2.长城 ";Setpos(15,7);cout<<"3.王者 ";Setpos(16,7);cout<<"4.放射 ";Setpos(17,7);cout<<"5.真空(魔鬼难度)";Setpos(19,7);cout<<"输入负数则开启无尽模式";Setpos(20,9);cout<<"例:-1:无尽围城";
endless=0;A:char a=_getch();if(a=='-') {endless=1;goto A;}else if(a<'1'||a>'5') goto A;else Level=a-'0';
system("mode con cols=100 lines=56");Print(2);
}
int main(){
CONSOLE_CURSOR_INFO cursor_info={1,0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);srand((unsigned)time(NULL));
St:Menu();Start();
memset(n,-1,sizeof(n));memset(m,-1,sizeof(m));memset(M,0,sizeof(M));memset(E,0,sizeof(E));memset(B,0,sizeof(B));
T=ml=mr=el=er=bl=br=0;CDmax=160;Day=1;
money=1000;if(Level==5) money=1500;
mr++,M[mr].x=25,M[mr].y=25,M[mr].kind=0,M[mr].life=1,M[mr].blood=2000;
if(Level==2) M[mr].y=2;
if(Level==3) M[mr].x=48,M[mr].y=2;
if(Level==1) for(int i=0;i<=360;i+=30) mr++,M[mr].x=25+10*sin(3.1416*i/180),M[mr].y=25+10*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500;
if(Level==2) for(int i=5;i<50;i+=6) mr++,M[mr].x=i,M[mr].y=20,M[mr].kind=0,M[mr].life=1,M[mr].blood=500,mr++,M[mr].x=i,M[mr].y=10,M[mr].kind=0,M[mr].life=1,M[mr].blood=500;
if(Level==3) for(int i=-90;i<=0;i+=45) mr++,M[mr].x=48+8*sin(3.1416*i/180),M[mr].y=2+8*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500,mr++,M[mr].x=48+16*sin(3.1416*i/180),M[mr].y=2+16*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500,mr++,M[mr].x=48+24*sin(3.1416*i/180),M[mr].y=2+24*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500;
if(Level==4) for(int i=30;i<=390;i+=60) mr++,M[mr].x=25+8*sin(3.1416*i/180),M[mr].y=25+8*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500,mr++,M[mr].x=25+15*sin(3.1416*i/180),M[mr].y=25+15*cos(3.1416*i/180),-2,M[mr].kind=0,M[mr].life=1,M[mr].blood=500;
while(M[1].life==1)
{
T++;
memset(n,-1,sizeof(n));//这里默认全输空格
//鼠标,键盘,暂停操作
mouse=GetAsyncKeyState(VK_LBUTTON)&0x8000;
pt=Windowpos();N(pt.x,pt.y,-2);
if(mouse) Click();
if(Day>=100&&endless==0) break;
CD--;if(CD<=0){CD=CDmax;StartWar(Day);Day++;Setpos(53,40),printf("Day: %d ",Day);}
if(T%50==0) money=min(money+10,1000),Setpos(53,30),printf("Money: %d ",money);
Move(1);Map(1);Sleep(30);
}
if(Day>=100) {system("color 6E"),Sleep(1000);for(int i=1;i<=1000;i++) cout<<"YOU WIN !! ";system("pause");system("color 0F");}
else {system("color 7F"),Sleep(1000);for(int i=1;i<=1000;i++) cout<<"GAME OVER... ";system("pause");system("color 0F");}
system("cls");
goto St;
return 0;
}
二、红蓝大作战
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
int m[20][20];
char a,b,c,d;
int xa=16,ya=4,xb=16,yb=15,fxa=20,fya=20;
int xShang,Tiao,Zuo,You,Quan,fang=1,blood=50,lan=20;
int yShang,Tiaob,Zuob,Youb,Quanb,fangb=-1,bloodb=50,lanb=20;
int Zhao,Fen,zou,zhao,Bao,baox,baoy,Di,diy,Bu;
int Lie,liey,lief,liefy,Ji,jiy,jif,Shun,r,R,s,S,M;
void Yan(int a)
{
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_INTENSITY|FOREGROUND_BLUE);
}
void Bai(){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);}
void SetPos(int x,int y)
{
COORD pos;
pos.X=2*y+8;
pos.Y=x;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void Xue()
{
SetPos(0,-4);for(int i=0;i<4;i++) {for(int j=0;j<38;j++)cout<<" ";cout<<endl;}SetPos(0,-4);if(lan>30) lan=30;
if(lanb>30) lanb=30;cout<<" ";Yan(5);if(lan==30) Yan(3);for(int i=1;i<=lan;i++) printf("▃");Yan(1);printf("\n1p :");for(int i=2;i<=blood;i+=2) printf("█");
if(blood%2==1) printf("▌");cout<<endl<<" ";Yan(5);if(lanb==30) Yan(3);for(int i=1;i<=lanb;i++) printf("▃");Yan(4);printf("\n2p :");for(int i=2;i<=bloodb;i+=2) printf("█");
if(bloodb%2==1) printf("▌");cout<<endl;SetPos(17,0);Yan(2);for(int j=0;j<20;j++) {cout<<"■";continue;} Bai();Yan(1);printf("\n\n 蓝方:A W D --控制\t\t");Yan(4);
printf("红方:←↑→--控制\n\n"); Yan(1);printf(" J-出拳");if(lan<1) Yan(6);printf(" K-前刺");if(lan<3) Yan(6);printf(" L-分身\t");Yan(4);printf("1-出拳");
if(lanb<1) Yan(6);printf(" 2-上挑");Yan(4);if(lanb<3) Yan(6);printf(" 3-瞬移\n\n");Yan(1);if(lan<3) Yan(6);printf(" U-回血");Yan(1);if(lan<5) Yan(6);printf(" I-裂地");Yan(1);
if(lan<10) Yan(6);printf(" O-炸地\t");Yan(4);if(lanb<3) Yan(6);printf("4-回血");Yan(4);if(lanb<5) Yan(6);printf(" 5-震爆");Yan(4);if(lanb<7) Yan(6);printf(" 6-激光");Bai();
}
void Wo(){Yan(1),SetPos(xa,ya),cout<<"●";Yan(4),SetPos(xb,yb),cout<<"●";if(Fen!=0) Bai(),SetPos(fxa,fya),cout<<"●";}
void Hong(){Wo();system("color 4F"),Sleep(10),system("color 0F"),Xue();}
void Lan(){Wo();system("color 1F"),Sleep(10),system("color 0F"),Xue();}
void Lv(){Wo();system("color 2F"),Sleep(10),system("color 0F"),Xue();}
void Zou()
{
zou=0;
SetPos(xa,ya),cout<<" ";SetPos(xb,yb),cout<<" ";
if(Fen>0) SetPos(fxa,fya),cout<<" ";SetPos(0,-4);
if(fxa<=5||xa<=5) xShang=0;
if(xa==xb&&ya==yb) xa--,zou=1;
if(fxa==xa&&fya==ya) fxa--,zou=1;
if(fxa==xb&&fya==yb) fxa--,zou=1;
if(Fen>0)
{
if(xa==fxa+1&&ya==fya&&fang==-1){if(fya>0) fya--;else fya+=2;}
if(xa==fxa+1&&ya==fya&&fang==1){if(fya<19) fya++;else fya-=2;}
if(fxa+1==xb&&fya==yb&&fang==-1){if(fya>0) fya--;else fya+=2;}
if(fxa+1==xb&&fya==yb&&fang==1){if(fya<19) fya++;else fya-=2;}
if(Tiao>0)
{
if(fang==-1&&fya>0&&(fxa!=xb||fya-1!=yb)&&(fxa!=xa||fya-1!=ya)) fya--;
if(fang==1&&fya<19&&(fxa!=xb||fya+1!=yb)&&(fxa!=xa||fya+1!=ya)) fya++;
}
if(xShang>0) m[fxa][fya]=0,fxa-=2;
if(fxa<16) m[fxa][fya]=0,fxa++;
}
if(xa+1==xb&&ya==yb&&fang==-1){if(ya>0) ya--;else ya+=2;}
if(xa+1==xb&&ya==yb&&fang==1){if(ya<19) ya++;else ya-=2;}
if(xa+1==fxa&&ya==fya&&fang==-1){if(ya>0) ya--;else ya+=2;}
if(xa+1==fxa&&ya==fya&&fang==1){if(ya<19) ya++;else ya-=2;}
if(Zuo>0&&ya>0&&Tiao==0&&(xa!=xb||ya-1!=yb)&&(fxa!=xa||fya!=ya-1)) m[xa][ya]=0,ya--;
if(Zuo>0&&fya>0&&Tiao==0&&(fxa!=xb||fya-1!=yb)&&(xa!=fxa||ya!=fya-1)) m[fxa][fya]=0,fya--;Zuo=0;
if(You>0&&ya<19&&Tiao==0&&(xa!=xb||ya+1!=yb)&&(fxa!=xa||fya!=ya+1)) m[xa][ya]=0,ya++;
if(You>0&&fya<19&&Tiao==0&&(fxa!=xb||fya+1!=yb)&&(xa!=fxa||ya!=fya+1)) m[fxa][fya]=0,fya++;You=0;
if(Tiao>0)
{
if(fang==-1&&ya>0&&(xa!=xb||ya-1!=yb)&&(fxa!=xa||fya!=ya-1)) ya--;
if(fang==1&&ya<19&&(xa!=xb||ya+1!=yb)&&(fxa!=xa||fya!=ya+1)) ya++;
}
if(xShang>0) m[xa][ya]=0,xShang--,xa-=2;
if(xa<16) m[xa][ya]=0,xa++;
if(xa==16) Tiao=0;
if(xb<=5) yShang=0;
if(xa==xb+1&&ya==yb&&fangb==-1){if(yb>0) yb--;else yb+=2;}
if(xa==xb+1&&ya==yb&&fangb==1){if(yb<19) yb++;else yb-=2;}
if(xb+1==fxa&&yb==fya&&fangb==-1){if(yb>0) yb--;else yb+=2;}
if(xb+1==fxa&&yb==fya&&fangb==1){if(yb<19) yb++;else yb-=2;}
if(Zuob>0&&yb>0&&Tiaob==0&&(xa!=xb||ya!=yb-1)&&(fxa!=xb||fya!=yb-1)) m[xb][yb]=0,Zuob=0,yb--;Zuob=0;
if(Youb>0&&yb<19&&Tiaob==0&&(xa!=xb||ya!=yb+1)&&(fxa!=xb||fya!=yb+1)) m[xb][yb]=0,Youb=0,yb++;Youb=0;
if(Tiaob>0&&Bu==0)
{
if(fangb==-1&&yb>0&&(xa!=xb||ya!=yb-1)&&(fxa!=xb||fya!=yb-1)) yb--;
if(fangb==1&&yb<19&&(xa!=xb||ya!=yb+1)&&(fxa!=xb||fya!=yb+1)) yb++;
}
if(yShang>0) m[xb][yb]=0,yShang--,xb-=2;
if(xb<16) m[xb][yb]=0,xb++;
if(xb==16) Tiaob=0;
SetPos(0,-4);if(zou==1) Zou();
Sleep(10);
}
void Xian()
{
zhao=0;s++;
if(M>=5) {Zhao=0;return;}
if(s==70) {s=0;if(lan<40)lan++;if(lanb<40)lanb++;Xue();}
SetPos(0,-4);
if(Bao!=0)
{
Bao--;Zhao--;
for(int i=baox-3;i<=baox+3;i++)
for(int j=baoy-3;j<=baoy+3;j++) if(i<=16&&j>=0&&j<=19) m[i][j]=9;
for(int i=baox-1;i<=baox+1;i++)
for(int j=baoy-1;j<=baoy+1;j++) if(i<=16&&j>=0&&j<=19) m[i][j]=0;
}if(Bao==0) baox=0,baoy=0;
if(Lie!=0)
{
Lie--;Zhao--;
if(lief==-1) for(int i=1;i<=7-Lie;i++) if(liey+Lie>=0) m[18-i][liey+Lie]=11;
if(lief==1) for(int i=1;i<=7-Lie;i++) if(liey-Lie<=19) m[18-i][liey-Lie]=10;
if(Fen>0)
{
if(lief==-1) for(int i=1;i<=7-Lie;i++) if(liefy+Lie>=0) m[18-i][liefy+Lie]=11;
if(lief==1) for(int i=1;i<=7-Lie;i++) if(liefy-Lie<=19) m[18-i][liefy-Lie]=10;
}
}if(Lie==0) liey=0,lief=0,liefy=0;
if(Ji!=0)
{
Ji--;Zhao--;
if(jif==-1) for(int i=jiy;i>=0;i--) m[xb][i]=14;
if(jif==1) for(int i=jiy;i<=19;i++) m[xb][i]=13;
}if(Ji==0) jiy=0,jif=0;
if(Di!=0)
{
Di--;Zhao--;
for(int i=2;i<=16;i++) m[i][diy]=19;
if(Fen>0&&yb!=0&&yb!=19) for(int i=2;i<=16;i++) m[i][diy+fangb]=19;
}if(Di==0) diy=0;
if(Shun!=0)
{
SetPos(Shun,-4);cout<<" ";
Shun=0;
}
Bu=0;
if(m[xa][ya]==3) {Shun=xa,Zuo+=1,xShang+=4,blood-=1,Zhao=0,m[xa][ya]=7,Lan(),lan++,zhao=1;Xue();}
else if(m[xa][ya]==4) {Shun=xa,You+=1,xShang+=4,blood-=1,Zhao=0,m[xa][ya]=7,Lan(),lan++,zhao=1;Xue();}
else if(m[xa][ya]==9) {Shun=xa,xShang=7,blood-=2,Zhao=0,m[xa][ya]=7,Lan(),lan+=2,zhao=1;Xue();}
else if(m[xa][ya]==13) {Shun=xa,You+=1,blood-=2,Zhao=0,m[xa][ya]=7,Lan(),lan+=2,zhao=1;Xue();}
else if(m[xa][ya]==14) {Shun=xa,Zuo+=1,blood-=2,Zhao=0,m[xa][ya]=7,Lan(),lan+=2,zhao=1;Xue();}
else if(m[xa][ya]==15) {Shun=xa,You+=1,blood-=1,Zhao=0,m[xa][ya]=7,Lan(),lan+=1,zhao=1;Xue();}
else if(m[xa][ya]==16) {Shun=xa,Zuo+=1,blood-=1,Zhao=0,m[xa][ya]=7,Lan(),lan+=1,zhao=1;Xue();}
else m[xa][ya]=1;
if(m[fxa][fya]==3||m[fxa][fya]==4||m[fxa][fya]==9||m[fxa][fya]==13||m[fxa][fya]==14||m[fxa][fya]==15||m[fxa][fya]==16)
{Zhao=0,m[fxa][fya]=7,fxa=20,fya=20,Fen=0,Lan(),zhao=1;Xue();}
if(m[xb][yb]==5) {Shun=xb,Zuob+=4,yShang+=1,bloodb-=1,Zhao=0,m[xb][yb]=7,Hong(),lanb++,zhao=1;Xue();}
else if(m[xb][yb]==6) {Shun=xb,Youb+=4,yShang+=1,bloodb-=1,Zhao=0,m[xb][yb]=7,Hong(),lanb++,zhao=1;Xue();}
else if(m[xb][yb]==10) {Shun=xb,Youb+=1,yShang+=1,bloodb-=2,Zhao=0,m[xb][yb]=7,Hong(),lanb+=2,zhao=1;Xue();}
else if(m[xb][yb]==11) {Shun=xb,Zuob+=1,yShang+=1,bloodb-=2,Zhao=0,m[xb][yb]=7,Hong(),lanb+=2,zhao=1;Xue();}
else if(m[xb][yb]==17) {Shun=xb,Youb+=1,bloodb-=1,Zhao=0,m[xb][yb]=7,Hong(),lanb+=1,zhao=1;Xue();}
else if(m[xb][yb]==18) {Shun=xb,Zuob+=1,bloodb-=1,Zhao=0,m[xb][yb]=7,Hong(),lanb+=1,zhao=1;Xue();}
else if(m[xb][yb]==19) {Shun=xb,Bu=1,yShang+=3,bloodb-=1,Zhao=0,m[xb][yb]=7,Hong(),lanb+=1,zhao=1;Xue();}
else m[xb][yb]=2;
if(Fen>0) m[fxa][fya]=8;
for(int i=5;i<=16;i++)
for(int j=0;j<20;j++)
{
if(m[i][j]==20) {SetPos(i,j);cout<<" ",m[i][j]=0;continue;}
if(m[i][j]==1) {Yan(1),SetPos(i,j);cout<<"●",m[i][j]=20,Bai();continue;}
if(m[i][j]==2) {Yan(4),SetPos(i,j);cout<<"●",m[i][j]=20,Bai();continue;}
if(m[i][j]==8) {Bai(),SetPos(i,j);cout<<"●",m[i][j]=20;continue;}
if(m[i][j]==7) {Yan(5),SetPos(i,j);cout<<"█",m[i][j]=20,zhao=1;Bai();continue;}
if(m[i][j]==12) {Bai(),SetPos(i,j);cout<<"●",Shun=xb;continue;}
if(m[i][j]>=3&&m[i][j]<=6||(m[i][j]>=9&&m[i][j]<=11)||(m[i][j]>=13))
{Bai(),SetPos(i,j);cout<<"■";m[i][j]=20,Zhao=0,zhao=1;continue;}
}
if(zhao>0) {M++,Zou(),Xian();M=0;return;}
memset(m,0,sizeof(m));M=0;
}
void Go(char a)
{
if(a=='j') Quan++; else Quan=0;
if(a=='w'&&Tiao==0) Tiao++,xShang+=3;
if(a=='a'&&Tiao==0) Zuo=1,You=0,fang=-1;
if(a=='d'&&Tiao==0) You=1,Zuo=0,fang=1;
if(a=='j'&&Quan<=3&&fang==-1&&ya-1>=0) {m[xa][ya-1]=18;if(Fen>0&&fya-1>=0) m[fxa][fya-1]=18;}
if(a=='j'&&Quan<=3&&fang==1&&ya+1<=19) {m[xa][ya+1]=17;if(Fen>0&&fya+1<=19) m[fxa][fya+1]=17;}
if(a=='k'&&fang==-1&&lan>=1&&ya!=0) {lan--,Xue();Zhao++;for(int i=1;i<=3;i++){if(ya-i>=0) m[xa][ya-i]=5;if(Fen>0&&fya-i>=0) m[fxa][fya-i]=5;}}
if(a=='k'&&fang==1&&lan>=1&&ya!=19) {lan--,Xue();Zhao++;for(int i=1;i<=3;i++){if(ya+i<=19) m[xa][ya+i]=6;if(Fen>0&&fya+i<=19) m[fxa][fya+i]=6;}}
if(a=='l'&&Fen==0&&lan>=3) lan-=3,Xue(),Lan(),fxa=xa-3,fya=rand()%19,Fen=1,Zou(),Xian();
if(a=='u'&&lan>=3) lan-=3,Xue(),Lv(),blood+=2;
if(a=='i'&&lan>=5) lan-=5,Xue(),Zhao+=3,Di+=3,diy=yb;
if(a=='o'&&fang==-1&&lan>=10) {lan-=10,Xue();Zhao+=6,Lie=6,liey=ya-6,lief=-1,liefy=0;if(Fen>0) liefy=fya-6;}
if(a=='o'&&fang==1&&lan>=10) {lan-=10,Xue();Zhao+=6,Lie=6,liey=ya+6,lief=1,liefy=0;if(Fen>0) liefy=fya+6;}
if(a=='1') Quanb++; else Quanb=0;
if(a==72&&Tiaob==0) Tiaob++,yShang+=3;
if(a==75&&Tiaob==0) Zuob=1,Youb=0,fangb=-1;
if(a==77&&Tiaob==0) Youb=1,Zuob=0,fangb=1;
if(a=='1'&&Quanb<=3&&fangb==-1&&yb-1>=0) m[xb][yb-1]=16;
if(a=='1'&&Quanb<=3&&fangb==1&&yb+1<=19) m[xb][yb+1]=15;
if(a=='2'&&fangb==-1&&lanb>=1&&yb!=0) {lanb--,Xue();Zhao++;for(int i=1;i<=3;i++){if(yb-i>=0) m[xb][yb-i]=3;}}
if(a=='2'&&fangb==1&&lanb>=1&&yb!=19) {lanb--,Xue();Zhao++;for(int i=1;i<=3;i++){if(yb+i<=19) m[xb][yb+i]=4;}}
if(a=='3'&&fangb==1&&lanb>=3&&yb!=19) {lanb-=3;Xue();for(int i=yb;i<=18;i++) m[xb][i]=12;yb=19;Xian();}
if(a=='3'&&fangb==-1&&lanb>=3&&yb!=0) {lanb-=3;Xue();for(int i=yb;i>0;i--) m[xb][i]=12;yb=0;Xian();}
if(a=='4'&&lanb>=3) lanb-=3,Xue(),Lv(),bloodb+=2;
if(a=='5'&&lanb>=5) lanb-=5,Xue(),Zhao+=3,Bao+=3,baox=xb,baoy=yb;
if(a=='6'&&lanb>=7) lanb-=7,Xue(),Zhao+=3,Ji+=3,jiy=yb,jif=fangb;
}
int main()
{
x:
system("cls");
srand((unsigned)time(NULL));Bai();
cout<<endl<<" -------------------胎红 VS 胎蓝---------------------"<<endl;
cout<<" ---------------------------作者:胎神---------------"<<endl<<endl;Yan(5);
cout<<" 2.0版本,憾世来袭!"<<endl<<endl;
cout<<" 2大更新:"<<endl<<endl;
cout<<" 1.完美解决“闪”的问题!"<<endl<<endl;
cout<<" 2.单人模式来了!完全电脑AI控制,比双人模式更难!"<<endl<<endl;
cout<<" 3.技能平衡性调整,更合理化的对战体验。"<<endl<<endl;Yan(1);
cout<<" 已开启 闪光功能:当蓝方挨血时,画面闪蓝光,反之闪红光;恢血时闪绿光。"<<endl<<endl;Bai();
cout<<" 请输入: 1.单人模式 2.双人模式"<<endl<<endl;A:a=_getch();
if(a=='1')
{
cout<<" 你要当谁? 1.小胎蓝 2.小胎红 3.老子不想打了,让他们自己打!"<<endl<<endl;b=_getch();
cout<<" 选择难度: 1.简单的像吃屎 2.一般的像垃圾 3.巨难的像变胎"<<endl<<endl;
cout<<" (难度越简单,对方动作越迟缓。)"<<endl<<endl;d=_getch();
if(d=='1') R=5;
if(d=='2') R=3;
if(d=='3') R=1;
system("cls");
Xue();Xian();
while(blood>0&&bloodb>0)
{
SetPos(0,-4);M=0;
Zou();Xian();
if(b=='1'||b=='3')
{
S++;
if(S>=R)
{
S=0;c=0;int xxa=xa,yya=ya;
if(lanb>=7) r=rand()%6;else if(lanb>=5) r=rand()%7-2;else if(lanb>=3) r=rand()%6-2;else if(lanb>=1) r=rand()%4-1;else r=rand()%3-1;
if(Fen>0) xxa=fxa,yya=fya;
if((xb==16&&yb==0)||(xb==16&&yb==19)) r=0;
if(r==5){if(fangb==-1&&xxa==xb&&yya<=yb) c='6';if(fangb==1&&xxa==xb&&yya>=yb) c='6';else r=0;}
if(r==4){if(xxa==xb&&abs(yya-yb)<=1) r=0;if(fangb==-1&&yb-3<=yya&&yya<=yb-1) c='5';if(fangb==1&&yb+3>=yya&&yya>=yb+1) c='5';else r=0;}
if(r==3&&bloodb<30&&lan>=3) c='4';
if(r==2){if(fangb==-1&&yb-3<=yya&&yya<=yb) c='2';if(fangb==1&&yb+3>=yya&&yya>=yb) c='2';else r=0;}
if(r==1){if(fangb==-1&&yb-1==yya) c='1';else if(fangb==1&&yb+1==yya) c='1';else r=0;}
if(yya<=yb&&r==0){int rr=rand()%5;if(fangb==-1&&rr==0) c=72;else if(fangb==-1&&rr==1&&abs(yya-yb)>=5) c='3';else c=75;}
if(yya>yb&&r==0){int rr=rand()%5;if(fangb==1&&rr==0) c=72;else if(fangb==1&&rr==1&&abs(yya-yb)>=5) c='3';else c=77;}
if(c!=0) Go(c);
}
}
if(b=='2'||b=='3')
{
S++;
if(S>=R)
{
S=0;c=0;
if(lanb>=10) r=rand()%10;else if(lanb>=5) r=rand()%9-3;else if(lanb>=3) r=rand()%8-3;else if(lanb>=1) r=rand()%6-2;else r=rand()%3-1;
if((xa==16&&ya==0)||(xa==16&&ya==19)) r=0;
if(r>=6){if(fang==-1&&ya>=yb&&abs(ya-yb)<=2) c='o';if(fang==1&&ya<=yb&&abs(ya-yb)<=2) c='o';else r=0;}
if(r==5) c='i';
if(r==4&&blood<30&&lan>=3) c='u';
if(r==3&&Fen==0) c='l';
if(r==2){if(fang==1&&yb-3<=ya&&ya<=yb) c='k';if(fang==-1&&yb+3>=ya&&ya>=yb) c='k';else r=0;}
if(r==1){if(fang==1&&yb-1==ya) c='j';else if(fang==-1&&yb+1==ya) c='j';else r=0;}
if(ya>=yb&&r==0){int rr=rand()%5;if(fang==-1&&rr==0) c='w';else c='a';}
if(ya<yb&&r==0){int rr=rand()%5;if(fang==1&&rr==0) c='w';else c='d';}
if(c!=0) Go(c);
}
}
if(kbhit())
{
SetPos(0,-4);
if(b=='1')
{
if(KEY_DOWN(87)) Go('w');if(KEY_DOWN(65)) Go('a');if(KEY_DOWN(68)) Go('d');
if(KEY_DOWN(74)) Go('j');if(KEY_DOWN(75)) Go('k');if(KEY_DOWN(76)) Go('l');
if(KEY_DOWN(85)) Go('u');if(KEY_DOWN(73)) Go('i');if(KEY_DOWN(79)) Go('o');
}
if(b=='2')
{
if(KEY_DOWN(38)) Go(72);if(KEY_DOWN(37)) Go(75);if(KEY_DOWN(39)) Go(77);
if(KEY_DOWN(97)) Go('1');if(KEY_DOWN(98)) Go('2');if(KEY_DOWN(99)) Go('3');
if(KEY_DOWN(100)) Go('4');if(KEY_DOWN(101)) Go('5');if(KEY_DOWN(102)) Go('6');
}
Zou(),Xian();
}
if(Zhao>0) Zou(),Xian();
Sleep(20);
}
}
else if(a=='2')
{
system("cls");
Xue();Xian();
while(blood>0&&bloodb>0)
{
SetPos(0,-4);
if(!kbhit()) Zou(),Xian();
if(kbhit())
{
SetPos(0,-4);
if(KEY_DOWN(87)) Go('w');if(KEY_DOWN(65)) Go('a');if(KEY_DOWN(68)) Go('d');
if(KEY_DOWN(74)) Go('j');if(KEY_DOWN(75)) Go('k');if(KEY_DOWN(76)) Go('l');
if(KEY_DOWN(85)) Go('u');if(KEY_DOWN(73)) Go('i');if(KEY_DOWN(79)) Go('o');
if(KEY_DOWN(38)) Go(72);if(KEY_DOWN(37)) Go(75);if(KEY_DOWN(39)) Go(77);
if(KEY_DOWN(97)) Go('1');if(KEY_DOWN(98)) Go('2');if(KEY_DOWN(99)) Go('3');
if(KEY_DOWN(100)) Go('4');if(KEY_DOWN(101)) Go('5');if(KEY_DOWN(102)) Go('6');
Zou(),Xian();
}
if(Zhao>0) Zou(),Xian();Sleep(20);
}
}
else goto A;
system("cls");
if(blood>0) Yan(1);
if(bloodb>0) Yan(4);
cout<<endl<<endl<<endl;
cout<<" ┌-------------┐"<<endl;
cout<<" ┆ ┆"<<endl;
if(blood>0) cout<<" ┆ 1p WIN!!! ┆"<<endl;
if(bloodb>0) cout<<" ┆ 2p WIN!!! ┆"<<endl;
cout<<" ┆ ┆"<<endl;
cout<<" └-------------┘"<<endl<<endl;
Sleep(2000);Bai();system("cls");
xa=16,ya=4,xb=16,yb=15,fxa=20,fya=20;
xShang=Tiao=Zuo=You,Quan=0,fang=1,blood=50,lan=20;
yShang=Tiaob=Zuob=Youb=Quanb=0,fangb=-1,bloodb=50,lanb=20;
Zhao=Fen=zou=zhao=Bao=baox=baoy=Di=diy=Bu=0;
Lie=liey=lief=liefy=Ji=jiy=jif=Shun=r=R=s=S=M=0;goto x;
return 0;
}
三、幻门疾走
#include<bits/stdc++.h>
#include<conio.h>
#include<windows.h>
using namespace std;
void Color(int a){
if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),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==-5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN);
}
struct node{int x,y,w,turn,kind;bool life;}B[1001];
void Setpos(int x,int y){COORD pos;pos.X=y*2,pos.Y=x;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
int bl,boom,dooring,T,win,x,y,speed=300,spnum=0,Score,Bspeed=5,Mapsize=18;
int M[35][35],M2[35][35];
int dx[5]={0,-1,0,1,0},dy[5]={0,0,1,0,-1};// 上右下左
void Delete(int x,int y)
{
if(x<=0||x>=Mapsize||y<=0||y>=Mapsize) return;
M[x][y]=0;M2[x][y]=0;
for(int i=1;i<=bl;i++) if(B[i].x==x&&B[i].y==y) B[i].life=0;
Setpos(x,y);cout<<" ";
}
void Move(int i){
int x0=B[i].x,y0=B[i].y,t=B[i].turn,j=0,r=2*(rand()%2)-1;
while(j<4){
if(M[x0+dx[t]][y0+dy[t]]==0){
B[i].x=x0+dx[t];
B[i].y=y0+dy[t];
B[i].turn=t;break;}
else if(B[i].w==2&&M2[x0+dx[t]][y0+dy[t]]==1){
Delete(x0+dx[t],y0+dy[t]);
B[i].x=x0+dx[t];
B[i].y=y0+dy[t];
B[i].turn=t;break;}
j++;
if(j==1) t+=r;if(j==2) t-=2*r;if(j==3) t--;
if(t>4) t-=4;if(t<1) t+=4;
}
return;
}
void Cout(int i,int j,int a,int x)
{
int c=5;
if(x==0) a=M[i][j];
if(x==404) c=4;
if(a==0&&i%2==0&&j%2==0) return;
if(i<0||j<0||i>Mapsize||j>Mapsize) return;
Setpos(i,j);
if(i==x&&j==y) Color(1),cout<<"●";
else if(x!=0&&a==0) Color(0),cout<<" ";
else if(a==1) Color(c),cout<<"↑";
else if(a==2) Color(c),cout<<"→";
else if(a==3) Color(c),cout<<"↓";
else if(a==4) Color(c),cout<<"←";
else if(a==5) Color(7),cout<<"■";
else if(a==6) Color(3),cout<<"★";
else if(a==7) Color(2),cout<<"◆";
}
void Map(int a){
for(int i=1-a;i<=Mapsize-1+a;i++)
for(int j=1-a;j<=Mapsize-1+a;j++){Cout(i,j,a,0);}
Setpos(32,3);Color(1),cout<<"Score: "<<Score;
Setpos(32,10);Color(3),cout<<" ["<<boom<<" ★] Z ",Color(2),cout<<"["<<dooring<<" ◆] X";
}
void CreatMap(int a){
bool ii,jj;int R,kR;
bl=0;
for(int i=0;i<=Mapsize;i++)
for(int j=0;j<=Mapsize;j++){
ii=i%2;jj=j%2,R=rand()%50,kR=rand()%30;
if((ii==0&&jj==0)||i==0||j==0||i==Mapsize||j==Mapsize) M[i][j]=5;
else if(ii==1&&jj==0&&R<=31){
if(i==1) M[i][j]=1;
else if(R<=5) M[i][j]=5;
else if(i==Mapsize-1) M[i][j]=3;
else M[i][j]=1+(rand()%2)*2;
}
else if(ii==0&&jj==1&&R<=31){
if(j==1) M[i][j]=4;
else if(R<=5) M[i][j]=5;
else if(j==Mapsize-1) M[i][j]=2;
else M[i][j]=2+(rand()%2)*2;}
else if(ii==1&&jj==1){
if(R>=37) M[i][j]=5;
if(bl<=20&&kR==0) bl++;B[bl].life=1,B[bl].w=7,B[bl].x=i,B[bl].y=j,B[bl].turn=rand()%4+1;
}}
if(a==2){for(int i=7;i<=23;i++)for(int j=7;j<=23;j++) M[i][j]=0;}
}
int door(int x0,int y0,int ax,int ay,int m,int t){
int nextplace,npx,npy;
if(ax==2&&m==2&&t==1) return M[x0+1][y0];
if(ax==2&&m==4&&t==1) return M[x0+1][y0];
if(ax==2&&m==2&&t==2) return M[x0+1][y0-1];
if(ax==2&&m==4&&t==2) return M[x0+1][y0+1];
if(ax==-2&&m==2&&t==1) return M[x0-1][y0];
if(ax==-2&&m==4&&t==1) return M[x0-1][y0];
if(ax==-2&&m==2&&t==2) return M[x0-1][y0-1];
if(ax==-2&&m==4&&t==2) return M[x0-1][y0+1];
if(ay==2&&m==1&&t==1) return M[x0][y0+1];
if(ay==2&&m==3&&t==1) return M[x0][y0+1];
if(ay==2&&m==1&&t==2) return M[x0+1][y0+1];
if(ay==2&&m==3&&t==2) return M[x0-1][y0+1];
if(ay==-2&&m==1&&t==1) return M[x0][y0-1];
if(ay==-2&&m==3&&t==1) return M[x0][y0-1];
if(ay==-2&&m==1&&t==2) return M[x0+1][y0-1];
if(ay==-2&&m==3&&t==2) return M[x0-1][y0-1];
}
bool DoorCango(int x0,int y0,int ax,int ay,int m)
{
if(M2[x][y]==5) return 0;
return 1;
}
void PushDoor(int x0,int y0,int ax,int ay,int time,int px,int py,int pre){
bool go=0;
if(time==0) Setpos(x0,y0),Color(1),cout<<"●";
else if(time==1) Setpos(px,py),cout<<" ",Setpos(x,y),Color(1),cout<<"●";
if(time>=1) Setpos(x0,y0),Color(-5),cout<<"po",Color(0),Sleep(speed),spnum++,Setpos(x0,y0),Cout(x0,y0,pre,1);
int MM=M[x0][y0];M[x0][y0]=pre;
if(ax==2){
if(MM==2){
Setpos(x0+1,y0),Color(5),cout<<"↘",Sleep(speed),spnum++;
if(time==0) Setpos(x0+1,y0),Color(1),cout<<"●";
Setpos(x0+1,y0),cout<<" ",Setpos(x0+1,y0-1),Color(5),cout<<"↓",M[x0][y0]=0;
if(M[x0+1][y0-1]>=1&&M[x0+1][y0-1]<=4) PushDoor(x0+1,y0-1,0,-2,time+1,x0,y0,3),go=1;
M[x0+1][y0-1]=3;
}
if(MM==4){
Setpos(x0+1,y0),Color(5),cout<<"↙",Sleep(speed),spnum++;
if(time==0) Setpos(x0+1,y0),Color(1),cout<<"●";
Setpos(x0+1,y0),cout<<" ",Setpos(x0+1,y0+1),Color(5),cout<<"↓",M[x0][y0]=0;
if(M[x0+1][y0+1]>=1&&M[x0+1][y0+1]<=4) PushDoor(x0+1,y0+1,0,2,time+1,x0,y0,3),go=1;
M[x0+1][y0+1]=3;
}
}
if(ax==-2){
if(MM==2){
Setpos(x0-1,y0),Color(5),cout<<"↗",Sleep(speed),spnum++;
if(time==0) Setpos(x0-1,y0),Color(1),cout<<"●";
Setpos(x0-1,y0),cout<<" ",Setpos(x0-1,y0-1),Color(5),cout<<"↑",M[x0][y0]=0;
if(M[x0-1][y0-1]>=1&&M[x0-1][y0-1]<=4) PushDoor(x0-1,y0-1,0,-2,time+1,x0,y0,1),go=1;
M[x0-1][y0-1]=1;
}
if(MM==4){
Setpos(x0-1,y0),Color(5),cout<<"↖",Sleep(speed),spnum++;
if(time==0) Setpos(x0-1,y0),Color(1),cout<<"●";
Setpos(x0-1,y0),cout<<" ",Setpos(x0-1,y0+1),Color(5),cout<<"↑",M[x0][y0]=0;
if(M[x0-1][y0+1]>=1&&M[x0-1][y0+1]<=4) PushDoor(x0-1,y0+1,0,2,time+1,x0,y0,1),go=1;
M[x0-1][y0+1]=1;
}
}
if(ay==2){
if(MM==1){
Setpos(x0,y0+1),Color(5),cout<<"↗",Sleep(speed),spnum++;
if(time==0) Setpos(x0,y0+1),Color(1),cout<<"●";
Setpos(x0,y0+1),cout<<" ",Setpos(x0+1,y0+1),Color(5),cout<<"→",M[x0][y0]=0;
if(M[x0+1][y0+1]>=1&&M[x0+1][y0+1]<=4) PushDoor(x0+1,y0+1,2,0,time+1,x0,y0,2),go=1;
M[x0+1][y0+1]=2;
}
if(MM==3){
Setpos(x0,y0+1),Color(5),cout<<"↘",Sleep(speed),spnum++;
if(time==0) Setpos(x0,y0+1),Color(1),cout<<"●";
Setpos(x0,y0+1),cout<<" ",Setpos(x0-1,y0+1),Color(5),cout<<"→",M[x0][y0]=0;
if(M[x0-1][y0+1]>=1&&M[x0-1][y0+1]<=4) PushDoor(x0-1,y0+1,-2,0,time+1,x0,y0,2),go=1;
M[x0-1][y0+1]=2;
}
}
if(ay==-2){
if(MM==1){
Setpos(x0,y0-1),Color(5),cout<<"↖",Sleep(speed),spnum++;
if(time==0) Setpos(x0,y0-1),Color(1),cout<<"●";
Setpos(x0,y0-1),cout<<" ",Setpos(x0+1,y0-1),Color(5),cout<<"←",M[x0][y0]=0;
if(M[x0+1][y0-1]>=1&&M[x0+1][y0-1]<=4) PushDoor(x0+1,y0-1,2,0,time+1,x0,y0,4),go=1;
M[x0+1][y0-1]=4;
}
if(MM==3){
Setpos(x0,y0-1),Color(5),cout<<"↙",Sleep(speed),spnum++;
if(time==0) Setpos(x0,y0-1),Color(1),cout<<"●";
Setpos(x0,y0-1),cout<<" ",Setpos(x0-1,y0-1),Color(5),cout<<"←",M[x0][y0]=0;
if(M[x0-1][y0-1]>=1&&M[x0-1][y0-1]<=4) PushDoor(x0-1,y0-1,-2,0,time+1,x0,y0,4),go=1;
M[x0-1][y0-1]=4;
}
}
if(time==0) Setpos(x0,y0),cout<<" ",Setpos(x,y),Color(1),cout<<"●";
if(go==0) Map(0);
}
void OpenDoor(int x0,int y0,int x2,int y2){
int xx=(x0+x2)/2,yy=(y0+y2)/2;
if(M[xx][yy]==5||M[x2][y2]==5) return;
else if(M[xx][yy]==6) {x=x2;y=y2;boom++;M[xx][yy]=0;return;}
else if(M[xx][yy]==7) {x=x2;y=y2;dooring++;M[xx][yy]=0;return;}
else if(M[xx][yy]==0) {x=x2;y=y2;return;}
else if(M[xx][yy]>=1&&M[xx][yy]<=4) {
x=x2,y=y2;PushDoor(xx,yy,x2-x0,y2-y0,0,0,0,0);
}
}
int yx(){
str:system("cls");
Setpos(10,10);cout<<"请选择地图大小(1~6):";int a;cin>>a;if(a>=1&&a<=6) Mapsize=4*a+6;else goto str;
str2:system("cls");Setpos(12,10);cout<<"请调整小怪速度(1最慢,9最快):";cin>>a;if(a>=1&&a<=9) Bspeed=pow(2,9-a);else goto str2;
system("cls");x=y=1;
CreatMap(1);
boom=3;dooring=3;Score=0;
Map(1);
while(Score<20)
{
T++;
Setpos(x,y),cout<<" ";
if(GetAsyncKeyState(VK_UP)&0x8000) OpenDoor(x,y,x-2,y);
else if(GetAsyncKeyState(VK_DOWN)&0x8000) OpenDoor(x,y,x+2,y);
else if(GetAsyncKeyState(VK_LEFT)&0x8000) OpenDoor(x,y,x,y-2);
else if(GetAsyncKeyState(VK_RIGHT)&0x8000) OpenDoor(x,y,x,y+2);
if(kbhit())
{
char g=_getch();int fx,fy;
if(g=='z'&&boom>0) {boom--;for(int k=1;k<=4;k++) Setpos(x+dx[k],y+dy[k]),Color(5),cout<<"■",Sleep(100),Delete(x+dx[k],y+dy[k]);Delete(x,y);
for(int k=1;k<=4;k++) Setpos(x+2*dx[k],y+2*dy[k]),Color(5),cout<<"■",Sleep(100),Delete(x+2*dx[k],y+2*dy[k]);}
if(g=='x'&&dooring>0) {dooring--;for(int k=1;k<=4;k++) {Setpos(x+dx[k],y+dy[k]),Color(5),cout<<"■",Sleep(100),cout<<" ",fx=x+dx[k],fy=y+dy[k];
if(fx<=0||fx>=Mapsize||fy<=0||fy>=Mapsize) continue;
if(fx%2==1&&fy%2==0){if(fx==1) M[fx][fy]=1;else if(fx==Mapsize-1) M[fx][fy]=3;else M[fx][fy]=1+(rand()%2)*2;}
else if(fx%2==0&&fy%2==1){if(fy==1) M[fx][fy]=4;else if(fy==Mapsize-1) M[fx][fy]=2;else M[fx][fy]=2+(rand()%2)*2;}}Map(1);}
}
Setpos(x,y),Color(1),cout<<"●";
if(M[x][y]==6) boom++,M[x][y]=0,Map(1);
if(M[x][y]==7) dooring++,M[x][y]=0,Map(1);
if(spnum<=10) speed=300;
else if(spnum<=30) speed=200;
else if(spnum<=90) speed=100;
else if(spnum<=150) speed=50;
else speed=30;
Setpos(Mapsize/2,Mapsize/2),Color(1+4*((T/10)%2)),cout<<"○";
if(win==1){return 0;}
memset(M2,0,sizeof(M2));M2[Mapsize/2][Mapsize/2]=-1;
int bb=0;
if(T%Bspeed==0)
for(int i=1;i<=bl;i++) if(B[i].life==1) {bb++;
Setpos(B[i].x,B[i].y);cout<<" ";
if(B[i].x==Mapsize/2&&B[i].y==Mapsize/2) {if(B[i].w==1) Score++,system("color 6E");if(B[i].w==2) Score-=2,system("color 4F");Sleep(50),system("color 0F"),Map(1);B[i].life=0;continue;}
if(B[i].w<=2) Move(i);Setpos(B[i].x,B[i].y);M2[B[i].x][B[i].y]=B[i].w;
if(B[i].w==1) Color(5),cout<<"▲";
else if(B[i].w==2) Color(4),cout<<"▼";
else if(B[i].w==3) {Color(4),cout<<"!!";int rh=rand()%5;if(rh<3) B[i].w=1;else B[i].w=2;}
else if(B[i].w%2==1) Color(4),cout<<"!!",B[i].w--;
else if(B[i].w%2==0) Color(5),cout<<"!!",B[i].w--;
}
if(T%100==0){int kk=0;for(int hi=1;hi<Mapsize;hi++)for(int hj=1;hj<Mapsize;hj++)if(M[hi][hj]>=6) kk++;kk+=dooring+boom;int rr=rand()%2;if(rr==0&&kk<=10) M[rand()%(Mapsize/2)*2+1][rand()%(Mapsize/2)*2+1]=6+rand()%2;}
if(T%100==0&&bb<=Mapsize*2/3){
for(int k=1;k<=3;k++){
int xx=rand()%(Mapsize-2)+1,yy=rand()%(Mapsize-2)+1;
if(M[xx][yy]==0&&M2[xx][yy]==0) {
bl++;B[bl].x=xx;B[bl].y=yy;B[bl].life=1;B[bl].turn=rand()%4+1;B[bl].w=7;break;
}
}}
Sleep(50);
}
system("color 6E");for(int i=1;i<=200;i++) cout<<"YOU WIN !! ";
}
void gz() {
system("cls");Color(1);
cout<<endl<<"●是你"<<endl;
cout<<"由上下左右键控制"<<endl<<endl;Color(5);
cout<<"↑←↓→是门(方向不同,如果推后有新位置给门,则可以连锁推动)"<<endl;Color(7);
cout<<"■是墙(也是门固定,绕着旋转的地方)"<<endl<<endl;Color(5);
cout<<"▲是小胎"<<endl;Color(4);
cout<<"▼是小怪"<<endl;Color(1);
cout<<"○是终点"<<endl;Color(5);
cout<<"小胎 和 小怪 会随机出现在地图上"<<endl;
cout<<"你的目标是 引领小胎,阻止小怪 到达终点"<<endl<<endl;
cout<<"道具:"<<endl<<endl;Color(3);
cout<<"★是炸弹(按 Z 使用,炸开四周的一切,包括小怪)"<<endl;Color(2);
cout<<"◆是幻门(按 X 使用,在四周刷出四扇随机方向的门)"<<endl<<endl;Color(5);
cout<<"一个小胎一分,20分通关!"<<endl<<endl;
cout<<"按任意键开始!"<<endl;
char a;a=_getch();yx();
}
int main(){
system("mode con cols=62 lines=33");
CONSOLE_CURSOR_INFO cursor_info={1,0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);srand((unsigned)time(NULL));
star:Mapsize=30;CreatMap(2);Map(1);
Setpos(10,10);Color(5);cout<<"欢迎来到 幻门疾走!";
Setpos(12,10);Color(0);cout<<"作者:胎神大大(洛谷名:TSzza)";
Setpos(14,12);cout<<"1、开始!";Setpos(16,12);cout<<"2、规则...";
start:char a;a=_getch();if(a=='1')yx();else if(a=='2')gz();else goto start;goto star;
return 0;
}
四、盲打
#include<bits/stdc++.h>
#include<windows.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
#define KEY_DOWN(VK_NONAME)((GetAsyncKeyState(VK_NONAME)&0x8000)?1:0)
using namespace std;
int to(float a) {if(a>0) return int(a+0.5);else if(a<0) return int(-a-0.5);if(a==0) return 0;}
void Setpos(float x,float y){int xx=to(x),yy=to(y*2);COORD pos;pos.X=yy,pos.Y=xx;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
int T9_Color[10]={0,-40,-30,-31,-50,-20,-21,-60,-10,-11}; //2.0 配色方案
int U3_Color[10]={0,-1,-70,-71}; //从上到下
int L8_Color[10]={0,-60,-40,-20,-10,-50,-11,-21,-30};
int B26_Color[30],L26_Color[30],FJ_Color[30]; //Board区键盘上色
void Slow(char *p) {while(1){if(*p!=0) printf("%c",*p++);else break;if(!kbhit()) Sleep(50);}}
void Slow_F(char *p) {while(1){if(*p!=0) printf("%c",*p++);else break;if(!kbhit()) Sleep(10);}}
void Color(int a){
#define SCT SetConsoleTextAttribute
#define GSH GetStdHandle(STD_OUTPUT_HANDLE)
#define WHITE FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE
if(a==0) SCT(GSH,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);if(a==10) SCT(GSH,FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);if(a==20) SCT(GSH,FOREGROUND_INTENSITY|FOREGROUND_GREEN);if(a==30) SCT(GSH,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);if(a==40) SCT(GSH,FOREGROUND_INTENSITY|FOREGROUND_RED);if(a==50) SCT(GSH,FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);if(a==60) SCT(GSH,FOREGROUND_INTENSITY|FOREGROUND_BLUE);if(a==70) SCT(GSH,FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==71) SCT(GSH,FOREGROUND_INTENSITY);if(a==11) SCT(GSH,FOREGROUND_GREEN|FOREGROUND_BLUE);if(a==21) SCT(GSH,FOREGROUND_GREEN);if(a==31) SCT(GSH,FOREGROUND_RED|FOREGROUND_BLUE);if(a==41) SCT(GSH,FOREGROUND_RED);if(a==51) SCT(GSH,FOREGROUND_RED|FOREGROUND_GREEN);if(a==61) SCT(GSH,FOREGROUND_BLUE);if(a==-1) SCT(GSH,BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);if(a==1) SCT(GSH,0);if(a==-10) SCT(GSH,BACKGROUND_INTENSITY|BACKGROUND_GREEN|BACKGROUND_BLUE);if(a==-20) SCT(GSH,BACKGROUND_INTENSITY|BACKGROUND_GREEN);if(a==-30) SCT(GSH,BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE);
if(a==-40) SCT(GSH,BACKGROUND_INTENSITY|BACKGROUND_RED|WHITE);if(a==-50) SCT(GSH,BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN);if(a==-60) SCT(GSH,BACKGROUND_INTENSITY|BACKGROUND_BLUE|WHITE);if(a==-70) SCT(GSH,BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);if(a==-71) SCT(GSH,BACKGROUND_INTENSITY|WHITE);if(a==-11) SCT(GSH,BACKGROUND_GREEN|BACKGROUND_BLUE|WHITE);if(a==-21) SCT(GSH,BACKGROUND_GREEN|WHITE);if(a==-31) SCT(GSH,BACKGROUND_RED|BACKGROUND_BLUE|WHITE);if(a==-41) SCT(GSH,BACKGROUND_RED|WHITE);if(a==-51) SCT(GSH,BACKGROUND_RED|BACKGROUND_GREEN|WHITE);if(a==-61) SCT(GSH,BACKGROUND_BLUE|WHITE);
}
struct TYPPER{
char name;
int left,up;//从左向右,从上到下
float x,y;//y是横列
}T[50],Ta[50];//Ta:all,T:字母
int N[50];//反字母对应
void Initialization_TYPPER(){
char T1[50]="*QWERTYUIOP[]";//字母1len=10+2
char T2[50]="*ASDFGHJKL;'";//字母2len=9+2
char T3[50]="*ZXCVBNM,./";//字母3len=7+3
int tl=0,tal=0;
for(int j=1;j<=3;j++) for(int i=1;i<=12;i++){
char t0;
if(j==1) t0=T1[i];if(j==2) t0=T2[i];if(j==3) t0=T3[i];
if(t0>='A'&&t0<='Z'){tl++;T[tl].name=t0;T[tl].left=i;T[tl].up=j;T[tl].x=4*j-1;T[tl].y=4*i-1;if(j==2) T[tl].y+=1;if(j==3) T[tl].y+=3;N[t0-'A'+1]=tl;}
if(t0!=0){tal++;Ta[tal].name=t0;Ta[tal].left=i;Ta[tal].up=j;Ta[tal].x=4*j-1;Ta[tal].y=4*i-1;if(j==2) Ta[tal].y+=1;if(j==3) Ta[tal].y+=3;
}
}
B26_Color['W'-'A'+1]=T9_Color[2];B26_Color['A'-'A'+1]=T9_Color[2];B26_Color['S'-'A'+1]=T9_Color[2];B26_Color['D'-'A'+1]=T9_Color[2];B26_Color['Q'-'A'+1]=T9_Color[1];B26_Color['E'-'A'+1]=T9_Color[4];B26_Color['R'-'A'+1]=T9_Color[4];B26_Color['T'-'A'+1]=T9_Color[4];B26_Color['Y'-'A'+1]=T9_Color[4];B26_Color['F'-'A'+1]=T9_Color[5];B26_Color['G'-'A'+1]=T9_Color[5];B26_Color['H'-'A'+1]=T9_Color[5];B26_Color['Z'-'A'+1]=T9_Color[3];B26_Color['X'-'A'+1]=T9_Color[3];B26_Color['C'-'A'+1]=T9_Color[3];B26_Color['V'-'A'+1]=T9_Color[3];B26_Color['B'-'A'+1]=T9_Color[6];for(char i='I';i<='P';i++) B26_Color[i-'A'+1]=T9_Color[9];B26_Color['U'-'A'+1]=T9_Color[7];B26_Color['I'-'A'+1]=T9_Color[7];B26_Color['O'-'A'+1]=T9_Color[7];
//B26_Color定义
for(int i=1;i<=26;i++){if(T[i].left<=5) L26_Color[T[i].name-'A'+1]=L8_Color[i];
if(T[i].left<=5) L26_Color[T[i].name-'A'+1]=L8_Color[T[i].left];
else if(T[i].up==1&&T[i].left>=6) L26_Color[T[i].name-'A'+1]=L8_Color[max(5,T[i].left-2)];
else if(T[i].up==2&&T[i].left>=6) L26_Color[T[i].name-'A'+1]=L8_Color[T[i].left-1];
else if(T[i].up==3&&T[i].left>=6) L26_Color[T[i].name-'A'+1]=L8_Color[T[i].left];
}
//L26_Color定义
}
void TEST_FJ();void TEACH_Board_TEST(int a);void TEACH_Board_Left();void TEACH_Board_Right();void TEACH_Board_Mid();void TEACH_Board_Remember();void TEACH_Board_Word();
int UP=2;void TYPPER_UP();
#define PSK Setpos(T[i].x,T[i].y),cout<<" ";Setpos(T[i].x+1,T[i].y),cout<<" "<<T[i].name<<" ";Setpos(T[i].x+2,T[i].y),cout<<" "
void Print_Single_Key_Char(char a) {int i=N[a-'A'+1];Color(-70);PSK;}
void Print_Single_Key_Int(int i) {Color(-70);PSK;}
void Print_Single_Key_Char_C(char a,int color) {int i=N[a-'A'+1];Color(color);PSK;}
void Print_Single_Key_Int_C(int i,int color) {Color(color);PSK;}
void Print_Local_Key_C(char local,char name,int color) {if(local>'a'&&local<'z')local+='A'-'a';if(local<'A'||local>'Z') return;int i=N[local-'A'+1];Color(color);Setpos(T[i].x,T[i].y),cout<<" ";Setpos(T[i].x+1,T[i].y),cout<<" "<<name<<" ";Setpos(T[i].x+2,T[i].y),cout<<" ";}
void Print_Hole_TYPPER_Key(){for(int i=1;i<=26;i++)Print_Single_Key_Int(i);}
void Print_Hole_TYPPER_Key_S(int sleep) {for(int i=1;i<=26;i++)Print_Single_Key_Int(i),Sleep(sleep);}
void Print_Hole_TYPPER_Key_L26() {for(int i=1;i<=26;i++) Print_Single_Key_Int_C(i,L26_Color[T[i].name-'A'+1]);}
void Print_Hole_TYPPER_Key_B26() {for(int i=1;i<=26;i++) Print_Single_Key_Int_C(i,B26_Color[T[i].name-'A'+1]);}
void Print_Hole_TYPPER_Key_L26_S(int sleep) {for(int i=1;i<=26;i++) Print_Single_Key_Int_C(i,L26_Color[T[i].name-'A'+1]),Sleep(sleep);}
void Print_Hole_TYPPER_Key_B26_S(int sleep) {for(int i=1;i<=26;i++) Print_Single_Key_Int_C(i,B26_Color[T[i].name-'A'+1]),Sleep(sleep);}
void Print_Frame(){for(int i=UP;i<=min(39,UP+13);i++){Setpos(i,2);Color(-1);if(i==UP+13)Color(-71);for(int j=1;j<=83;j++) printf(" ");}}
void Print_Frame_Line(int color){int i=15; Setpos(i,2);Color(color);for(int j=1;j<=83;j++) printf(" ");}
void Print_Frame_Line_FJ(int color){int i=16; Setpos(i,2);Color(color);for(int j=1;j<=83;j++) printf(" ");}
void Print_Hole_TYPPER(){Print_Frame();Print_Hole_TYPPER_Key();}
void Print_Hole_TYPPER_Board(){Print_Frame();for(int i=1;i<=26;i++) Print_Single_Key_Char_C('A'-1+i,B26_Color[i]);}
void Print_Hole_TYPPER_Finger(){Print_Frame();for(int i=1;i<=26;i++) Print_Single_Key_Char_C('A'-1+i,L26_Color[i]);}
void Spark_Key(char a,int color,int sleep){Print_Single_Key_Char_C(a,color);Sleep(sleep);Print_Single_Key_Char_C(a,-71);Sleep(sleep);Print_Single_Key_Char_C(a,color);Sleep(sleep);Print_Single_Key_Char_C(a,-71);Sleep(sleep);Print_Single_Key_Char_C(a,color);Sleep(sleep*2);}
void Spark_Key_Right(char a,int color,int sleep){int c=-20;Print_Single_Key_Char_C(a,color);Sleep(sleep);Print_Single_Key_Char_C(a,-20);Sleep(sleep);Print_Single_Key_Char_C(a,color);Sleep(sleep);Print_Single_Key_Char_C(a,-20);Sleep(sleep);Print_Single_Key_Char_C(a,color);Sleep(sleep*2);}
void Spark_Key_Wrong(char a,int color,int sleep){Print_Single_Key_Char_C(a,color);Sleep(sleep);Print_Single_Key_Char_C(a,-41);Sleep(sleep);Print_Single_Key_Char_C(a,color);Sleep(sleep);Print_Single_Key_Char_C(a,-41);Sleep(sleep);Print_Single_Key_Char_C(a,color);Sleep(sleep*2);}
void Print_Hole_TYPPER_Dark(){for(char i=1;i<=26;i++) Print_Single_Key_Int_C(i,-71),Sleep(20);}
void Print_Hole_TYPPER_None(){for(char i=1;i<=30;i++) {if(i>=4&&i<=30) Print_Local_Key_C(i+'A'-1-4,'?',-70);if(i>=1&&i<=26) Print_Local_Key_C(i+'A'-1,'?',-71);Sleep(20);}}
void Print_String_Key_Char(char a[100]){char t=0;for(int i=0;i<=99;i++){if(a[i]!=0) t=a[i];else break;if(t>='a'&&t<='z') t+='A'-'a';if(t>='A'&&t<='Z') Print_Single_Key_Char(t);}}
void Print_String_Key_Char_C(char a[100],int color){char t=0;for(int i=0;i<=99;i++){if(a[i]!=0) t=a[i];else break;if(t>='a'&&t<='z') t+='A'-'a';if(t>='A'&&t<='Z') Print_Single_Key_Char_C(t,color);}}
void Print_String_Key_Char_C_S(char a[100],int color,int sleep){char t=0;for(int i=0;i<=99;i++){if(a[i]!=0) t=a[i];else break;if(t>='a'&&t<='z') t+='A'-'a';if(t>='A'&&t<='Z') Print_Single_Key_Char_C(t,color);Sleep(sleep);}}
void Point(){for(int i=0;i<=36;i+=3) for(int j=0;j<=42;j+=7)Setpos(i,j),cout<<'*'<<'('<<i<<','<<j<<')';for(int i=1;i<=34;i+=3) for(int j=3;j<=39;j+=7)Setpos(i,j),cout<<'*'<<'('<<i<<','<<j<<')';}
void Slow_Frame(int x0,int y0,int x1,int y1){Color(0);
for(int i=y0;i<=y1;i++) Setpos(x0,i),printf("*"),Sleep(2);
for(int i=x0;i<=x1;i++) Setpos(i,y0),printf("*"),Setpos(i,y1),printf("*"),Sleep(2);
for(int i=y0;i<=y1;i++) Setpos(x1,i),printf("*"),Sleep(2);
}void Frame(int x0,int y0,int x1,int y1){Color(0);
for(int i=y0;i<=y1;i++) Setpos(x0,i),printf("*");
for(int i=x0;i<=x1;i++) Setpos(i,y0),printf("*"),Setpos(i,y1),printf("*");
for(int i=y0;i<=y1;i++) Setpos(x1,i),printf("*");
}
void Dark_Frame(int x0,int y0,int x1,int y1){Color(0);for(register int i=x0;i<=x1;i++)for(register int j=y0;j<=y1;j++) Setpos(i,j),printf(" ");}
void Dark_Frame_L(int x0,int y0,int x1,int y1){Color(0);for(register int j=y1;j>=y0;j--) Dark_Frame(x0,j,x1,j),Sleep(5);}
int Step_X(int x0,int y0,int x1,int y1,int step,int stepmax) {float s=(x1-x0)*1.0/stepmax*1.0;return int(x0+s*step);}
int Step_Y(int x0,int y0,int x1,int y1,int step,int stepmax) {float s=(y1-y0)*1.0/stepmax*1.0;return int(y0+s*step);}
void Light_L8(int colornum){for(int i=1;i<=26;i++){if(L26_Color[i]==L8_Color[colornum])Spark_Key(i+'A'-1,L8_Color[colornum],30);}}
void Light_String_T9(char a[100],int color){char t=0;for(int i=0;i<=99;i++){if(a[i]!=0) t=a[i];else break;if(t>='a'&&t<='z') t+='A'-'a';if(t>='A'&&t<='Z') Spark_Key(t,T9_Color[color],30);}}
void Print_Board_Name(){
Dark_Frame(2,25,8,40);
Slow_Frame(1,26,9,44);
Setpos(3,25+3),Color(T9_Color[1]),Slow_F(" QWER ");Sleep(100);
Setpos(3,30+3),Color(T9_Color[4]),Slow_F(" ERTY ");Sleep(100);
Setpos(3,35+3),Color(T9_Color[7]),Slow_F(" UIOP ");Sleep(100);
Setpos(5,26+3),Color(T9_Color[2]),Slow_F(" ASDF ");Sleep(100);
Setpos(5,31+3),Color(T9_Color[5]),Slow_F(" FGHJ ");Sleep(100);
Setpos(5,36+3),Color(T9_Color[8]),Slow_F(" JKL; ");Sleep(100);
Setpos(7,28+3),Color(T9_Color[3]),Slow_F(" ZXCV ");Sleep(100);
Setp