当前位置: 首页 > news >正文

C++控制台打飞机小游戏

我终于决定还是把这个放出来。

视频在这:https://v.youku.com/v_show/id_XNDQxMTQwNDA3Mg==.html

具体信息主界面上都有写。

按空格暂停,建议暂停后再升级属性。

记录最高分的文件进行了加密。

有boss(上面视频2分47秒)。

挺好玩的。

可能有bug,不想改了,整体体验不错就行了。

更多控制台操作可以看之前写的鼠标操作的文章(https://blog.csdn.net/C20190102/article/details/79301667),也可以直接在这个上面复制。

MinGW编译无错误,只有lld输出的几个警告。

只有一个文件,没有任何其他的东西。

可以直接扒下来编译。

一开始写的时候打了很多注释,后来就不想打了。

大家凑合着看吧,不清楚的就评论,如果我还记得到就答一下哈。

对了,为了防止暂停作弊,暂停过后开始时鼠标会回到飞机的位置。

这个代码我一个人可能总共肝了20多个小时,如果你能帮我改得更有趣,bug更少的话可以找我。

更多内容看代码:

#include<set>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<windows.h>
#include<algorithm>
#include<iostream>
#include<conio.h>
#include<fstream>
using namespace std;#define fblack 0
#define fblue 1
#define fgreen 2
#define fcyan 3
#define fred 4
#define fpurple 5
#define fyellow 6
#define fwhite 7
#define fgray 8
#define flight 8
#define bblack 0
#define bblue 16
#define bgreen 32
#define bcyan 48
#define bfred 64
#define bpurple 80
#define byellow 96
#define bwhite 112
#define bgray 128
#define blight 128
#define dirkey -32
#define upkey 72
#define downkey 80
#define leftkey 75
#define rightkey 77
#define wclear system("cls")
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#define LL long longvoid flash(int times){while(times--){system("color 08");Sleep(300);system("color 80");Sleep(300);}//Sleep(1000);system("color 08");
}
void HindCursor(){HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);CONSOLE_CURSOR_INFO CursorInfo;GetConsoleCursorInfo(handle,&CursorInfo);CursorInfo.bVisible=false;SetConsoleCursorInfo(handle,&CursorInfo);
}
struct Button{int x,y,color;const char *name;int len;
};
void GetPos(POINT &pt){HWND hwnd=GetForegroundWindow();GetCursorPos(&pt);ScreenToClient(hwnd,&pt);pt.y=pt.y/16,pt.x=pt.x/8;swap(pt.x,pt.y);
}
void color(int a){SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void gto(int x,int y){COORD pos;pos.X=y;pos.Y=x;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
Button NewButton(int x,int y,int color,const char *name){Button t;t.x=x,t.y=y,t.name=name;t.color=color;t.len=strlen(name);return t;
}
bool Preserve(Button A){gto(A.x,A.y),color(A.color),printf("%s",A.name);POINT pt;GetPos(pt);if(pt.x==A.x&&(pt.y>=A.y&&pt.y<=A.y+A.len)){color(112),gto(A.x,A.y),printf("%s",A.name);if(KEY_DOWN(MOUSE_MOVED)) return 1;}return 0;
}
pair<int,int> GetXY(){HANDLE hStdout;CONSOLE_SCREEN_BUFFER_INFO pBuffer;hStdout = GetStdHandle(STD_OUTPUT_HANDLE);GetConsoleScreenBufferInfo(hStdout, &pBuffer);return make_pair(pBuffer.dwCursorPosition.Y,pBuffer.dwCursorPosition.X);
}
template <typename T>void Tprint(int Nx,int Ny,int Color,T a){int x=GetXY().first,y=GetXY().second;gto(Nx,Ny),color(Color),cout<<a;gto(x,y);
}
void ColorPrint(){for(int i=0;i<256;i++)color(i),printf("%d\n",i);
}
void SetWindow(const char *name,int c,int w){char str[30];sprintf(str,"title %s",name);system(str);sprintf(str,"mode con cols=%d lines=%d",w,c);system(str);
}
void SetWindow(const char *name,int c,int w,int x,int y){SetConsoleTitle(name);HWND hwnd;hwnd=GetForegroundWindow();SetWindowPos(hwnd,HWND_TOP,y,x,w*8,c*16,SWP_SHOWWINDOW);
}
int read(){color(fwhite+flight);int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;
}#define TP Tprint
#define WINDOWC 45
#define WINDOWW 55
#define INF 0x3f3f3f3f
#define OC fwhite+flight+bblack //original colorbool InRange(int x){return x>=0&&x<=WINDOWC;
}int BossFlag;
int OwnShotTimes,OwnLoseBlood,OwnShotOnTimes;
int MoneyFlash,ScoreFlash;const int ConstNewDy[4]={-1,0,1};
#define MAX_BULLET_TYPE_NUM 3
const int ConstBulletColor[MAX_BULLET_TYPE_NUM+5]={0,fyellow,fred+flight,fred+flight,fblue+flight,fred+bwhite};
const char ConstBulletShape[MAX_BULLET_TYPE_NUM+5]={0,'*','*','O','|','%'};
const int ConstBulletDamage[MAX_BULLET_TYPE_NUM+5]={0,50,80,500,20,300};
/*Move 1 block every 100-Speed ms*/
const int ConstBulletSpeed[MAX_BULLET_TYPE_NUM+5]={0,50,30,10,80,20};
/*The color of the full block in the blood line*/
const int ConstBloodColor[4]={0,fred,fyellow,fgreen};#define MAX_BOSS_NUM 10
const int ConstBossFullBlood[MAX_BOSS_NUM+5]={0,1000,3000,5000,10000,30000,50000,100000,300000,500000,1000000};
const int ConstBossShotSpeed[MAX_BOSS_NUM+5][2]={{0,0},{30,-3900},{30,-3400},{50,-2900},{50,-2400},{70,-1900},{70,-1400},{90,-900},{90,-400},{100,-400},{100,-400}};
const int ConstBossStopCD[MAX_BOSS_NUM+5]={0,3200,3400,3600,3800,4000,4200,4400,4600,4800,5000};
const int ConstBossStopTime[MAX_BOSS_NUM+5]={0,3000,2800,2600,2400,2200,2000,1800,1600,1400,1200};
const int ConstBossMoveSpeed[MAX_BOSS_NUM+5]={0,800,800,800,850,850,850,900,900,900,950};
const int ConstBossScore[MAX_BOSS_NUM+5]={0,10000,20000,40000,80000,160000,320000,640000,1280000,2560000,5120000};
const int ConstBossMoney[MAX_BOSS_NUM+5]={0,100,200,500,1000,2000,5000,8000,10000,20000,50000};
const int ConstBossNeedScore[MAX_BOSS_NUM+5]={0,500,1000,1500,2000,2500,3000,3500,4000,4500,5000};struct Bullet{int isExist;int x,y,Type;int dx,dy,LastBulletRefreshTime;Bullet(){LastBulletRefreshTime=-INF;}Bullet(int isExist_,int x_,int y_,int Type_,int dx_,int dy_):isExist(isExist_),x(x_),y(y_),Type(Type_),dx(dx_),dy(dy_){}
};void MoveBullet(Bullet&);
/*We must use Bullet*, or we can't change the data(position of the bullet) in the set*/
set<Bullet*> Ammo;
void BulletsRefresh(){vector<set<Bullet*>::iterator> Throw;for(set<Bullet*>::iterator it=Ammo.begin();it!=Ammo.end();it++){Bullet *New=*it;MoveBullet(*New);/*We can't erase it right away*/if(!New->isExist)Throw.push_back(it);}for(int i=0;i<int(Throw.size());i++)Ammo.erase(Throw[i]);
}int BEGINTIME;int UFOAddBlood,UFOAddShotSpeed,UFOAddMoveSpeed,Added;struct UFO{/*Shape of the UFO:0000/0000@@@(OOO)\-/V*/int isExist;int x,y;//position of the headint dx,dy;int Blood,FullBlood;int ShotSpeed,LastShotTime;int MoveSpeed;int LastMoveTime;int Score,Money;UFO(){if(BossFlag&&!Added)UFOAddBlood+=100,UFOAddShotSpeed+=100,UFOAddMoveSpeed+=100,Added=1;if(!BossFlag&&Added)UFOAddBlood-=100,UFOAddShotSpeed-=100,UFOAddMoveSpeed-=100,Added=0;isExist=1;x=0,y=rand()%(WINDOWW-4)+4;//Must be in the screenFullBlood=rand()%300+100+UFOAddBlood;Blood=FullBlood;ShotSpeed=rand()%1000+UFOAddShotSpeed;/*Move 1 block every 1000-MoveSpeed ms*/MoveSpeed=rand()%600+300+UFOAddMoveSpeed;LastMoveTime=LastShotTime=-INF;dx=1,dy=0;Score=FullBlood/30+((clock()-BEGINTIME)/10000);Money=MoveSpeed/100.0+FullBlood/100.0;}/*effects when being hit*/void Flash(){/*the head is sure to be in the screen so we needn't check*/if(!isExist)return;if(x>0&&x<WINDOWC)TP(x,y,fpurple+bwhite,'V');if(x-1>0&&x-1<WINDOWC)TP(x-1,y-1,fpurple+bwhite,"\\-/");//Sleep(100);if(x>0&&x<WINDOWC)TP(x,y,fpurple+bblack,'V');if(x-1>0&&x-1<WINDOWC)TP(x-1,y-1,fpurple+bblack,"\\-/");}/*Check if hit only on the body*/bool Hit(int tx,int ty){return (tx==x&&ty==y)||(tx==x-1&&ty>=y-1&&ty<=y+1);}/*To check if it will hit another UFO*/void BloodRefresh(int NewX,int NewY){/*To appear gradually, we should check the position*/if(x-2>=0){TP(x-2,y-1,OC,"   ");if(isExist)if(NewX-2<WINDOWC){/*Round up*/int FullBlock=(Blood*3+FullBlood-1)/FullBlood;   //Number of "@"int EmptyBlock=3-FullBlock;                      //Number of "O"int BloodColor=ConstBloodColor[FullBlock];/*Print the blood line*/for(int i=1;i<=FullBlock;i++)TP(NewX-2,NewY-2+i,BloodColor+bblack,'@');for(int i=1;i<=EmptyBlock;i++)TP(NewX-2,NewY-2+FullBlock+i,fgray+bblack,'O');}}/*Print the blood/fullblood number*//*Due to %06d we can't use TP*/if(x-3>=0){TP(x-3,y-4,OC,"         ");if(isExist){if(NewX-3<WINDOWC){gto(NewX-3,NewY-4),color(fcyan+bblack),printf("%04d",Blood);TP(NewX-3,NewY,fcyan+bblack,'/');gto(NewX-3,NewY+1),color(fcyan+bblack),printf("%04d",FullBlood);}}}if(x-3>=WINDOWC)isExist=0;}/*Clear the shape after it died*/void ClearPrint(){BloodRefresh(x,y);if(x-1>=0&&x-1<WINDOWC)TP(x-1,y-1,OC,"   ");if(x>=0&&x<WINDOWC)TP(x,y,OC,' ');}void Shot(){int t=clock();if(!ShotSpeed||LastShotTime>=t-(5000-ShotSpeed))return;LastShotTime=t;if(x>0){Bullet *tmp=new Bullet(1,x+1,y,2,1,0);Ammo.insert(tmp);}}
};
/*It is similar to set<Bullet*> in struct Plane*/
set<UFO*> Enemy;bool UFOCrash(int,int);
bool UFOCrash(UFO,int,int,set<UFO*>::iterator);/*Move the plane to a new place*/
void UFOMovePrint(UFO &me,set<UFO*>::iterator id){int t=clock();if(me.LastMoveTime>=t-(1000-me.MoveSpeed))return;me.LastMoveTime=t;/*Change the direction*/if(rand()%3==0)me.dy=ConstNewDy[rand()%3];int NewX=me.x+me.dx,NewY=me.y+me.dy;if(UFOCrash(me,NewX,NewY,id)||NewY-4<0||NewY+4>=WINDOWW)//||NewX<0||NewY-4<0||NewX>=WINDOWC||NewY+4>=WINDOWW){for(int i=0;i<3;i++){me.dy=ConstNewDy[rand()%3];NewX=me.x+me.dx,NewY=me.y+me.dy;if(!(UFOCrash(me,NewX,NewY,id)||NewY-4<0||NewY+4>=WINDOWW))//||NewX<0||NewY-4<0||NewX>=WINDOWC||NewY+4>=WINDOWW))break;}if(UFOCrash(me,NewX,NewY,id)||NewY-4<0||NewY+4>=WINDOWW)//||NewX<0||NewY-4<0||NewX>=WINDOWC||NewY+4>=WINDOWW)return;//TP(me.x,me.y,OC,' ');if(NewX<WINDOWC){TP(me.x,me.y,fwhite+flight+bblack,' ');if(me.isExist) TP(NewX,NewY,fwhite+flight+bblack,'V');}if(NewX-1>=0&&NewX-1<WINDOWC){TP(me.x-1,me.y-1,fwhite+flight+bblack,"   ");if(me.isExist) TP(NewX-1,NewY-1,fwhite+flight+bblack,"\\-/");}me.BloodRefresh(NewX,NewY);me.x=NewX,me.y=NewY;
}
int UFORefreshTime=3000,LastUFORefreshTime=0;
void UFORefresh(){int t=clock();if(LastUFORefreshTime<t-UFORefreshTime){UFO *tmp=new UFO;Enemy.insert(tmp);LastUFORefreshTime=t;}vector<set<UFO*>::iterator> Throw;for(set<UFO*>::iterator it=Enemy.begin();it!=Enemy.end();it++){UFO *New=*it;if(!New->isExist)Throw.push_back(it);UFOMovePrint(*New,it);New->Shot();}for(int i=0;i<int(Throw.size());i++)Enemy.erase(Throw[i]);
}#define MAX_BUFF_NUM 5
const int ConstBuffAppearPossibility[2][1000]={{1,2,2,2,2,2,2,3,4,5},{2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,5}
};
const int ConstBuffAppearTime[MAX_BUFF_NUM+5]={0,5000,5000,5000,5000,5000};
const int ConstBuffLastTime[MAX_BUFF_NUM+5]={0,5000,0,5000,10000,5000};
const char ConstBuffName[MAX_BUFF_NUM+5]={0,'B','C','P','D','S'};
const char ConstBuffColor[MAX_BUFF_NUM+5]={0,fblue+flight,fgreen+flight,fred+flight,fyellow+flight,fpurple+flight};struct Plane{/*Shape of the plane:^             (x,y)/ \            (x+1,y-1) to (x+1,y+1)|---------|        (x+2,y-5) to (x+2,y+5)|             (x+3,y)---            (x+4,y-1) to (x+4,y+1)@@@@@@@@@         (x+5,y-4) to (x+5,y+4)(OOOOOOOOO)000000/000000       (x+6,y-6) to (x+6,y+6)  (Blood and full blood)*/int x,y;//position of the headint Blood,FullBlood;int LastShotTime;int ShotSpeed;LL Score,BossScore;int Buffs[10],GetBuffTime[10];double AddAtack,AddShotSpeed;int Money;int MeetBossTimes;void Init(bool isDebug){if(isDebug){Ammo.clear();LastShotTime=-INF;/*It shot one time in at most 1000-ShotSpeed ms*/ShotSpeed=20;Blood=10000,FullBlood=10000;x=WINDOWC/2,y=WINDOWW-8;Score=BossScore=0;AddAtack=AddShotSpeed=50.0;MeetBossTimes=1;memset(Buffs,0,sizeof Buffs);}else{Ammo.clear();LastShotTime=-INF;/*It shot one time in at most 1000-ShotSpeed ms*/ShotSpeed=500;Blood=500,FullBlood=500;x=WINDOWC/2,y=WINDOWW-8;Score=BossScore=0;AddAtack=AddShotSpeed=1.0;MeetBossTimes=1;memset(Buffs,0,sizeof Buffs);}}bool NeedBoss(){if(Score>=ConstBossNeedScore[MeetBossTimes])return MeetBossTimes++,1;return 0;}void Flash(int fcolor){TP(x,y,fcolor+bwhite,'^');TP(x+1,y-1,fcolor+bwhite,'/'),TP(x+1,y+1,fcolor+bwhite,'\\');TP(x+2,y-5,fcolor+bwhite,'|');for(int i=y-4;i<=y+4;i++)TP(x+2,i,fcolor+bwhite,'-');TP(x+2,y+5,fcolor+bwhite,'|');TP(x+3,y,fcolor+bwhite,'|');TP(x+4,y-1,fcolor+bwhite,'-'),TP(x+4,y,fcolor+bwhite,'-'),TP(x+4,y+1,fcolor+bwhite,'-');Sleep(200);TP(x,y,OC,'^');TP(x+1,y-1,OC,'/'),TP(x+1,y+1,OC,'\\');TP(x+2,y-5,OC,'|');for(int i=y-4;i<=y+4;i++)TP(x+2,i,OC,'-');TP(x+2,y+5,OC,'|');TP(x+3,y,OC,'|');TP(x+4,y-1,OC,'-'),TP(x+4,y,OC,'-'),TP(x+4,y+1,OC,'-');}/*Check if hit only on the body*/bool Hit(int tx,int ty){return (tx==x&&ty==y)||(tx==x+1&&ty>=y-1&&ty<=y+1)||(tx==x+2&&ty>=y-5&&ty<=y+5)||(tx==x+3&&ty==y)||(tx==x+4&&ty>=y-1&&ty<=y+1);}/*Move the blood line(just move)*//*Remember to check if the position is OK before using*//*And it won't update the plane's position (x and y)*/void BloodRefresh(int NewX,int NewY){TP(x+5,y-4,OC,"         ");TP(x+6,y-6,OC,"             ");/*Round up*/int FullBlock=(Blood*9+FullBlood-1)/FullBlood;   //Number of "@"int EmptyBlock=9-FullBlock;                      //Number of "O"int BloodColor=ConstBloodColor[(FullBlock+2)/3];/*Print the blood line*/for(int i=1;i<=FullBlock;i++)TP(NewX+5,NewY-5+i,BloodColor+bblack,'@');for(int i=1;i<=EmptyBlock;i++)TP(NewX+5,NewY-5+FullBlock+i,fgray+bblack,'O');/*Print the blood/fullblood number*//*Due to %06d we can't use TP*/gto(NewX+6,NewY-6),color(fgray+bblack),printf("%06d",Blood);TP(NewX+6,NewY,OC,'/');gto(NewX+6,NewY+1),color(fgray+bblack),printf("%06d",FullBlood);}/*Move the plane to a new place*/void MovePrint(int NewX,int NewY,int flag=1){/*Insure that player can control the plane when the mouse is out of screen*/NewX=min(NewX,WINDOWC-7);NewY=min(max(NewY,6),WINDOWW-7);if(flag&&NewX==x&&NewY==y)return;//gto(WINDOWC-1,0),color(OC),printf("%3d %3d",NewX,NewY);//Debug/*Clear the plane in the old position*/TP(x,y,OC,' ');TP(x+1,y-1,OC,' '),TP(x+1,y+1,OC,' ');for(int i=y-5;i<=y+5;i++) TP(x+2,i,OC,' ');TP(x+3,y,OC,' ');TP(x+4,y-1,OC,' '),TP(x+4,y,OC,' '),TP(x+4,y+1,OC,' ');/*Move the blood line*/BloodRefresh(NewX,NewY);/*Print in the new position*/x=NewX,y=NewY;TP(x,y,OC,'^');TP(x+1,y-1,OC,'/'),TP(x+1,y+1,OC,'\\');TP(x+2,y-5,OC,'|');for(int i=y-4;i<=y+4;i++)TP(x+2,i,OC,'-');TP(x+2,y+5,OC,'|');TP(x+3,y,OC,'|');TP(x+4,y-1,OC,'-'),TP(x+4,y,OC,'-'),TP(x+4,y+1,OC,'-');/*Refresh the bullets*/}void Shot(){/*Buff 5*//*Faster shot*/int t=clock();if(Buffs[5]==1)ShotSpeed+=100,Buffs[5]=-1;if(Buffs[5]==-1&&t-GetBuffTime[5]>=ConstBuffLastTime[5]){ShotSpeed-=100;Buffs[5]=0;GetBuffTime[5]=0;}if(!ShotSpeed||LastShotTime>=t-(1000-ShotSpeed*AddShotSpeed))return;LastShotTime=t;if(x>0){OwnShotTimes++;int Type=1;/*Buff 3*//*Get bullets more powerful*/if(Buffs[3]){if(t-GetBuffTime[3]>=ConstBuffLastTime[3])Buffs[3]=0,GetBuffTime[3]=0;elseType=3;}Ammo.insert(new Bullet(1,x-1,y,Type,-1,0));/*Buff 1*//*5 lines of bullets*/if(Buffs[1]){if(t-GetBuffTime[1]>=ConstBuffLastTime[1]){Buffs[1]=0;GetBuffTime[1]=0;return;}Ammo.insert(new Bullet(1,x-1,y-2,Type,-1,0));Ammo.insert(new Bullet(1,x-1,y-1,Type,-1,0));Ammo.insert(new Bullet(1,x-1,y+1,Type,-1,0));Ammo.insert(new Bullet(1,x-1,y+2,Type,-1,0));}}}
}Own;struct Buff{int x,y;int Type;int DisappearTime;Buff(){}Buff(int t){x=rand()%(WINDOWC-3)+1,y=rand()%(WINDOWW-2)+1,Type=t,DisappearTime=clock()+ConstBuffAppearTime[t];}
};
set<Buff*> BuffIn;
int LastBuffAppearTime;
int BuffAppearCD=3000;
void BuffRefresh(){int T=clock();/*New buff in the screen*/if(LastBuffAppearTime+BuffAppearCD<=T){int id=rand();int t=ConstBuffAppearPossibility[BossFlag][id%10];if(t)BuffIn.insert(new Buff(t));LastBuffAppearTime=T;}vector<set<Buff*>::iterator> Throw;for(set<Buff*>::iterator it=BuffIn.begin();it!=BuffIn.end();it++){Buff *p=*it;TP(p->x,p->y,ConstBuffColor[p->Type],ConstBuffName[p->Type]);if(Own.Hit(p->x,p->y)){/*Buff 2*//*Recover 100 blood*/if(p->Type==2){Own.Blood=min(Own.Blood+100,Own.FullBlood);Own.BloodRefresh(Own.x,Own.y);}else{Own.Buffs[p->Type]=1;Own.GetBuffTime[p->Type]=T;}Throw.push_back(it);TP(p->x,p->y,OC,' ');}else if(T>=p->DisappearTime){Throw.push_back(it);TP(p->x,p->y,OC,' ');}}for(int i=0;i<int(Throw.size());i++)BuffIn.erase(Throw[i]);//for(int i=1;i<=MAX_BUFF_NUM;i++)//    if(Own.Buffs[i]&&clock()-Own.GetBuffTime[i]>=ConstBuffLastTime[i])//        Own.Buffs[i]=0;
}const char CHART[15]={'|','?','^','&','=','!','@',':','p','\\'};void GameOver(){color(OC);system("cls");/*Get max score before*/LL MaxScore=0;LL num=((MaxScore*18-2)*38-1314)/2*100+52;ifstream R("./MaxScore.sc");if(!R.is_open())TP(0,0,OC,"ERROR");string str;R>>str;if(str.length()){num=0;for(int i=0;i<int(str.length());i++)if(isdigit(str[i]))num=num*10ll+str[i]-'0';}R.close();/*unlock*/MaxScore=(((num-52)/100*2+1314)/38+2)/18;TP(WINDOWC/2-2,(WINDOWW+40-10)/2,fred+flight+bblack,"Game Over!");TP(WINDOWC/2-1,(WINDOWW+40-15)/2,OC,"Your score: ");gto(WINDOWC/2-1,(WINDOWW+40-15)/2+12),color(OC),printf("%08lld",Own.Score+Own.BossScore);TP(WINDOWC/2,(WINDOWW+40-15)/2,OC,"MaxScore: ");gto(WINDOWC/2,(WINDOWW+40-15)/2+12),color(OC),printf("%08lld",max(Own.Score+Own.BossScore,MaxScore));if(Own.Score+Own.BossScore>MaxScore){TP(WINDOWC/2+1,(WINDOWW+40-15)/2+2,fred+flight+bblack,"(Refreshed!)"),MaxScore=Own.Score+Own.BossScore;/*lock*/num=((MaxScore*18-2)*38-1314)/2*100+52;string New;for(int i=1;i<=30;i++){if(rand()%2)New+=CHART[rand()%10];else if(num)New+=num%10+'0',num/=10;}while(num)New+=num%10+'0',num/=10;while(New.length()<30)New+=CHART[rand()%10];reverse(New.begin(),New.end());fstream CLEAR("./MaxScore.sc", ios::trunc);CLEAR.close();ofstream T("./MaxScore.sc");if(!T.is_open())TP(0,0,OC,"ERROR");T<<New;T.close();}TP(WINDOWC/2+2,(WINDOWW+40-15)/2-3,OC,"(Press any key to exit)");getch();gto(WINDOWC/2+4,0),exit(0);
}bool isHit(int,int,int);void MoveBullet(Bullet &me){int t=clock();if(me.LastBulletRefreshTime>=t-(100-ConstBulletSpeed[me.Type]))return;me.LastBulletRefreshTime=t;int tx=me.x+me.dx,ty=me.y+me.dy;TP(me.x,me.y,OC,' ');/*It runs out of the screen => erase it*/if(tx<0||tx>=WINDOWC||ty<0||ty>=WINDOWW||isHit(tx,ty,me.Type)){me.isExist=0;return;}TP(me.x=tx,me.y=ty,ConstBulletColor[me.Type],ConstBulletShape[me.Type]);
}#define MAX_BUFFFULLNAME_LEN 16
const int ConstBuffTipPosition[MAX_BUFF_NUM+5][2]={{0,0},{13,WINDOWW+3},{14,WINDOWW+3},{15,WINDOWW+3},{16,WINDOWW+3},{17,WINDOWW+3}};
const char ConstBuffFullName[MAX_BUFF_NUM+5][MAX_BUFFFULLNAME_LEN+5]={"","4 more bullets","recover 50 blood","more powerful","double score","shot faster"};
const int ConstMaxBuffFullNameLen[MAX_BUFF_NUM+5]={0,16,16,16,16,16};
void BuffTipRefresh(){/*TP(12,WINDOWW+3,OC,"---------Details of Buffs---------");TP(18,WINDOWW+3,OC,"----------------------------------");*/int C=fgray;for(int i=1;i<=MAX_BUFF_NUM;i++){TP(ConstBuffTipPosition[i][0],ConstBuffTipPosition[i][1],C,ConstBuffName[i]);TP(ConstBuffTipPosition[i][0],ConstBuffTipPosition[i][1]+1,C,": ");TP(ConstBuffTipPosition[i][0],ConstBuffTipPosition[i][1]+3,C+(Own.Buffs[i]?bwhite+blight:0),ConstBuffFullName[i]);gto(ConstBuffTipPosition[i][0],ConstBuffTipPosition[i][1]+3+ConstMaxBuffFullNameLen[i]),color(C+(Own.Buffs[i]?bwhite+blight:0)),printf("[%02d S]",int(Own.Buffs[i]?(ConstBuffLastTime[i]-(clock()-Own.GetBuffTime[i])+999)/1000:0));}
}void EnemyClear(){int tmp=UFORefreshTime;UFORefreshTime=INF;for(set<UFO*>::iterator it=Enemy.begin();it!=Enemy.end();it++)(*it)->isExist=0;UFORefresh();UFORefreshTime=tmp;
}double Performance();//D C B A S
const int PerfColor[10]={fblack+bwhite,fgray+bwhite,fpurple+bwhite,fgreen+bwhite,fred+bwhite};
const char PerfLevel[10][8]={"D.","C.","B.","A!","S!!"};struct BOSS{/*Shape of the boss:0000000/0000000           (x-7,y-7) to (x-7,y+7)@@@@@@@@@@@@@@@           (x-6,y-7) to (x-6,y+7)(OOOOOOOOOOOOOOO)[-----------]            (x-5,y-6) to (x-5,y+6)\OOXXXOO/              (x-4,y-4) to (x-4,y+4)+---\XXOXX/---+           (x-3,y-7) to (x-3,y+7)V    \OOO/    V           (x-2,y-7) to (x-2,y+7)\O/                 (x-1,y-1) to (x-1,y+1)V                  (x,y)*/int isExist;int x,y;//position of the headint dx,dy;int Blood,FullBlood;int ShotSpeed1,ShotSpeed2,LastShotTime1,LastShotTime2,flag2;int MoveSpeed,LastMoveTime;int Score,AppearTime;int StopCD,StopTime,LastStopTime,isStop;int Money;bool Hit(int tx,int ty){return (tx==x-5&&ty>=y-6&&ty<=y+6)||(tx==x-4&&ty>=y-4&&ty<=y+4)||(tx==x-3&&ty>=y-7&&ty<=y+7)||(tx==x-2&&((ty==y-7)||(ty==y+7)||(ty>=y-2&&ty<=y+2)))||(tx==x-1&&ty>=y-1&&ty<=y+1)||(tx==x&&ty==y);}void Die(){flash(3);BossFlag=0;double tmp=Performance();int Add=int(Score*tmp);Own.BossScore+=Add;Own.Money+=Money*(tmp/3.0);ScoreFlash=MoneyFlash=1;TP(WINDOWC/2-1,WINDOWW/2-18,OC,"+-----------------------------------+");TP(WINDOWC/2  ,WINDOWW/2-18,OC,'|'),gto(WINDOWC/2,WINDOWW/2-7),color(PerfColor[int(tmp)]),printf("%s",PerfLevel[int(tmp)]),printf("  + %d scores !",Add),TP(WINDOWC/2  ,WINDOWW/2+18,OC,'|');TP(WINDOWC/2+1,WINDOWW/2-18,OC,"+-----------------------------------+");Sleep(1500);TP(WINDOWC/2-1,WINDOWW/2-18,OC,"                                     ");TP(WINDOWC/2  ,WINDOWW/2-18,OC,"                                     ");TP(WINDOWC/2+1,WINDOWW/2-18,OC,"                                     ");if(x-7>=0) TP(x-7,y-7,OC,"               ");if(x-6>=0) TP(x-6,y-7,OC,"               ");if(InRange(x)) TP(x,y,OC,' ');if(InRange(x-1)) TP(x-1,y-1,OC,"   ");if(InRange(x-2)) TP(x-2,y-7,OC,"               ");if(InRange(x-3)) TP(x-3,y-7,OC,"               ");if(InRange(x-4)) TP(x-4,y-4,OC,"         ");if(InRange(x-5)) TP(x-5,y-6,OC,"             ");EnemyClear();}void Flash(){if(InRange(x-5)) TP(x-5,y-6,fblack+bwhite,"[-----------]");if(InRange(x-4)) TP(x-4,y-4,fblack+bwhite,'\\'),TP(x-4,y-3,fblack+bwhite,"OO"),TP(x-4,y-1,fblack+bwhite,"XXX"),TP(x-4,y+2,fblack+bwhite,"OO"),TP(x-4,y+4,fblack+bwhite,"/");if(InRange(x-3)) TP(x-3,y-7,fblack+bwhite,"+---\\XX"),TP(x-3,y,fblack+bwhite,'O'),TP(x-3,y+1,fblack+bwhite,"---+");if(InRange(x-2)) TP(x-2,y-7,fblack+bwhite,'V'),TP(x-2,y-2,fblack+bwhite,'\\'),TP(x-2,y-1,fblack+bwhite,"OOO"),TP(x-2,y+2,fblack+bwhite,'/'),TP(x-2,y+7,fblack+bwhite,'V');if(InRange(x-1)) TP(x-1,y-1,fblack+bwhite,'\\'),TP(x-1,y,fblack+bwhite,'O'),TP(x-1,y+1,fblack+bwhite,'/');if(InRange(x-5)) TP(x-5,y-6,OC,"[-----------]");if(InRange(x-4)) TP(x-4,y-4,OC,'\\'),TP(x-4,y-3,fgray+bblack,"OO"),TP(x-4,y-1,OC,"XXX"),TP(x-4,y+2,fgray+bblack,"OO"),TP(x-4,y+4,OC,"/");if(InRange(x-3)) TP(x-3,y-7,OC,"+---\\XX"),TP(x-3,y,fgray+bblack,'O'),TP(x-3,y+1,OC,"---+");if(InRange(x-2)) TP(x-2,y-7,fgray+bblack,'V'),TP(x-2,y-2,OC,'\\'),TP(x-2,y-1,fgray+bblack,"OOO"),TP(x-2,y+2,OC,'/'),TP(x-2,y+7,fgray+bblack,'V');if(InRange(x-1)) TP(x-1,y-1,OC,'\\'),TP(x-1,y,fgray+bblack,'O'),TP(x-1,y+1,OC,'/');if(InRange(x)) TP(x,y,OC,' ');if(InRange(x)) TP(x,y,OC,'V');}void Init(int S){Blood=FullBlood=ConstBossFullBlood[S];x=0,y=rand()%(WINDOWW-14)+7;//Must be in the screendx=1,dy=0;LastShotTime1=LastShotTime2=0;flag2=0;ShotSpeed1=ConstBossShotSpeed[S][0],ShotSpeed2=ConstBossShotSpeed[S][1];MoveSpeed=ConstBossMoveSpeed[S];LastMoveTime=0;Score=ConstBossScore[S];AppearTime=clock();isExist=1;StopTime=ConstBossStopTime[S],StopCD=ConstBossStopCD[S],LastStopTime=isStop=0;Money=ConstBossMoney[S];}void BloodRefresh(int NewX,int NewY){/*Print the blood/fullblood number*//*Due to %06d we can't use TP*/if(x-7>=0){dx=0;TP(x-7,y-7,OC,"               ");if(isExist){if(NewX-7<WINDOWC){gto(NewX-7,NewY-7),color(fcyan+bblack),printf("%07d",Blood);TP(NewX-7,NewY,fcyan+bblack,'/');gto(NewX-7,NewY+1),color(fcyan+bblack),printf("%07d",FullBlood);}}}/*To appear gradually, we should check the position*/if(x-6>=0){TP(x-6,y-7,OC,"               ");if(isExist)if(NewX-6<WINDOWC){/*Round up*/int FullBlock=(Blood*15+FullBlood-1)/FullBlood;   //Number of "@"int EmptyBlock=15-FullBlock;                       //Number of "O"int BloodColor=ConstBloodColor[(FullBlock+4)/5];/*Print the blood line*/for(int i=1;i<=FullBlock;i++)TP(NewX-6,NewY-8+i,BloodColor+bblack,'@');for(int i=1;i<=EmptyBlock;i++)TP(NewX-6,NewY-8+FullBlock+i,fgray+bblack,'O');}}if(x-7>=WINDOWC)isExist=0;}/*Only one boss so we don't have to make the function out*/void MovePrint(){int t=clock();if(LastMoveTime>=t-(1000-MoveSpeed))return;LastMoveTime=t;/*Change the direction*/if(rand()%10==0)dy=ConstNewDy[rand()%3];int NewX=x+dx,NewY=y+dy;if(UFOCrash(NewX,NewY)||NewY-7<0||NewY+7>=WINDOWW)for(int i=0;i<3;i++){dy=ConstNewDy[rand()%3];NewX=x+dx,NewY=y+dy;if(!(UFOCrash(NewX,NewY)||NewY-7<0||NewY+7>=WINDOWW))break;}if(UFOCrash(NewX,NewY)||NewY-7<0||NewY+7>=WINDOWW)return;if(InRange(x)) TP(x,y,OC,' ');if(InRange(NewX)) TP(NewX,NewY,OC,'V');if(InRange(x-1)) TP(x-1,y-1,OC,"   ");if(InRange(NewX-1))TP(NewX-1,NewY-1,OC,'\\'),TP(NewX-1,NewY,fgray+bblack,'O'),TP(NewX-1,NewY+1,OC,'/');if(InRange(x-2)) TP(x-2,y-7,OC,"               ");if(InRange(NewX-2)) TP(NewX-2,NewY-7,fgray+bblack,'V'),TP(NewX-2,NewY-2,OC,'\\'),TP(NewX-2,NewY-1,fgray+bblack,"OOO"),TP(NewX-2,NewY+2,OC,'/'),TP(NewX-2,NewY+7,fgray+bblack,'V');if(InRange(x-3)) TP(x-3,y-7,OC,"               ");if(InRange(NewX-3)) TP(NewX-3,NewY-7,OC,"+---\\XX"),TP(NewX-3,NewY,fgray+bblack,'O'),TP(NewX-3,NewY+1,OC,"XX/---+");if(InRange(x-4)) TP(x-4,y-4,OC,"         ");if(InRange(NewX-4)) TP(NewX-4,NewY-4,OC,'\\'),TP(NewX-4,NewY-3,fgray+bblack,"OO"),TP(NewX-4,NewY-1,OC,"XXX"),TP(NewX-4,NewY+2,fgray+bblack,"OO"),TP(NewX-4,NewY+4,OC,"/");if(InRange(x-5)) TP(x-5,y-6,OC,"             ");if(InRange(NewX-5)) TP(NewX-5,NewY-6,OC,"[-----------]");BloodRefresh(NewX,NewY);x=NewX,y=NewY;}void Shot(){int t=clock();if(LastShotTime1<t-(100-ShotSpeed1)){LastShotTime1=t;if(x-1>=0){Ammo.insert(new Bullet(1,x-1,y-7,4,1,0));Ammo.insert(new Bullet(1,x-1,y+7,4,1,0));}}if(LastShotTime2<t-(100-ShotSpeed2-500)){LastShotTime2=t,flag2=1;TP(x,y,fred+flight+bgray,'V');}if(flag2&&t>=LastShotTime2+500){flag2=0;if(x+1>=0)Ammo.insert(new Bullet(1,x+1,y,5,1,0));}}
}Boss;/*There's an awful problem that set<UFO*>Enemy will be use in the struct UFO but it needs the declaration of struct UFO so we can neither put it in front of the struct UFO nor put it after the struct UFO...*/
/*So we have to get the function Crash out of the struct UFO.*/ /*Eating shit*/
/*To check if it will hit another UFO*/
void UFOMovePrint(UFO&,set<UFO*>::iterator);
bool UFOCrash(UFO me,int NewX,int NewY,set<UFO*>::iterator ID){for(set<UFO*>::iterator it=Enemy.begin();it!=Enemy.end();it++){int ox=(*it)->x,oy=(*it)->y;if(it==ID||ox<NewX) continue;if(NewX<=ox+4&&NewX>=ox-4&&NewY>=oy-8&&NewY<=oy+8){/*avoid disfluency*/UFO *New=*it;UFOMovePrint(*New,it);return 1;}}if(BossFlag&&NewX<=Boss.x&&NewX>=Boss.x-5&&NewY>=Boss.y-9&&NewY<=Boss.y+9)return 1;return 0;
}
bool UFOCrash(int NewX,int NewY){for(set<UFO*>::iterator it=Enemy.begin();it!=Enemy.end();it++){int ox=(*it)->x,oy=(*it)->y;if(ox<NewX) continue;if(NewX<=ox+9&&NewX>=ox-9&&NewY>=oy-9&&NewY<=oy+9)return 1;}return 0;
}//OwnShotTimes,OwnLoseBlood,OwnShotOnTimes;
double Performance(){//(0,5]double p1=double(OwnShotOnTimes)/max(OwnShotTimes,1);double p2=max(double(Own.FullBlood-OwnLoseBlood)/Own.FullBlood,0.0);return min((p1+p2)*2.5,4.999999);
}void BossRefresh(){Boss.MovePrint();int t=clock();if(!Boss.isStop)Boss.Shot();if(!Boss.isStop&&Boss.LastStopTime+Boss.StopTime+Boss.StopCD<=t)Boss.LastStopTime=t,Boss.isStop=1;if(Boss.isStop&&t-Boss.LastStopTime>=Boss.StopTime)Boss.isStop=0;
}void Init(){srand((unsigned)time(NULL));//SetWindow("HPF",WINDOWC+12,WINDOWW+45,0,500);SetWindow("HPF",WINDOWC+2,WINDOWW+40);HindCursor();TP(0,0,OC,"+---------------------------------------------------------------------------------------------+");TP(2,(WINDOWW+40)/2-7,OC,"Hape Flying Game");TP(7,0,OC,"+---------------------------------------------------------------------------------------------+");Button Start=NewButton(4,(WINDOWW+40)/2-4,OC,"> Start <");Button More=NewButton(5,(WINDOWW+40)/2-4,OC,"> More  <");while(1){if(Preserve(Start)){Own.Init(0);break;}if(Preserve(More)){TP(6,3,fred,"Input the password: ");gto(6,22),color(fgray);char Key[15];fgets(Key,10,stdin);if(!strcmp(Key,"cxhsdsb\n")){Own.Init(1);break;}fflush(stdin);color(OC);system("cls");TP(0,0,OC,"+---------------------------------------------------------------------------------------------+");TP(2,(WINDOWW+40)/2-7,OC,"Hape Flying Game");TP(7,0,OC,"+---------------------------------------------------------------------------------------------+");}Sleep(50);}color(OC);system("cls");
}/*Meet the awful problem again*/
bool isHit(int NewX,int NewY,int Type){if(Type==1||Type==3){int DM=int(ConstBulletDamage[Type]*Own.AddAtack);for(set<UFO*>::iterator it=Enemy.begin();it!=Enemy.end();it++){if((*it)->Hit(NewX,NewY)){/*Mention the order, or it won't be cleared*/UFO *t=*it;t->Flash();t->Blood=max(t->Blood-DM,0);t->BloodRefresh(t->x,t->y);if(t->Blood<=0){Own.Money+=t->Money;MoneyFlash=1;ScoreFlash=1;t->isExist=0;t->ClearPrint();int Add=t->Score;/*Buff 4*//*Double score*/if(Own.Buffs[4]){if(Own.GetBuffTime[4]+ConstBuffLastTime[4]>=clock()){Own.Buffs[4]=0;Own.GetBuffTime[4]=0;}Add+=t->Score;}if(BossFlag)Add/=10;Own.Score+=Add;}return 1;}}if(BossFlag&&Boss.Hit(NewX,NewY)){Boss.Flash();Boss.Blood=max(Boss.Blood-DM/2,0);Boss.BloodRefresh(Boss.x,Boss.y);OwnShotOnTimes++;if(Boss.Blood<=0)Boss.Die(),BossFlag=0;return 1;}}else if(Own.Hit(NewX,NewY)){Own.Flash(fred+flight);OwnLoseBlood+=min(Own.Blood,ConstBulletDamage[Type]);Own.Blood=max(Own.Blood-ConstBulletDamage[Type],0);Own.BloodRefresh(Own.x,Own.y);if(Own.Blood<=0)GameOver();return 1;}return 0;
}#define MAX_GRADE 10
const int ConstUpgradeCost[MAX_GRADE+5]={10,20,50,100,200,500,1000,2000,5000,10000,INF};
const char ConstUpgradeCostStr[MAX_GRADE+5][10]={"(M 10)","(M 20)","(M 50)","(M 100)","(M 200)","(M 500)","(M 1000)","(M 2000)","(M 5000)","(M 10000)","(M INF)  "};
const int ConstGradeColor[MAX_GRADE+5]={fgreen+flight+bblack,fgreen+flight+bblack,fgreen+bblack,fblue+flight+bblack,fblue+flight+bblack,fblue+bblack,fyellow+flight+bblack,fyellow+bblack,fyellow+bblack,fred+flight+bblack,fred+bblack,fred+bblack};
const char ConstGradeName[MAX_GRADE+5][20]={"[G0]","[G1]","[G2]","[G3]","[G4]","[G5]","[G6]","[G7]","[G8]","[G9]","[G10]"};int main(){//GameOver();//ColorPrint();//getchar();Init();HWND hd;hd=GetForegroundWindow();TP(12,WINDOWW+3,OC,"---------Details of Buffs---------");TP(18,WINDOWW+3,OC,"----------------------------------");//Own.Blood=100;int cnt=1;BossFlag=0;int LastT=clock()/1000-2,LastMoney=-1;BEGINTIME=clock();int _____=0,STOP=0,LastPreserveTime=-INF;Button AddFullBlood,AddAttack,AddShotSpeed;int FullBloodGrade=0,AttackGrade=0,ShotSpeedGrade=0;string AddFullBloodTip("> Add your max blood by 500"),AddAttackTip("> Add your attack by 10%"),AddShotSpeedTip("> Add your shot speed by 10%");AddFullBlood=NewButton(5,WINDOWW+3,OC,"> Add your max blood by 200");AddAttack=NewButton(6,WINDOWW+3,OC,"> Add your attack by 10%");AddShotSpeed=NewButton(7,WINDOWW+3,OC,"> Add your shot speed by 5%");//Own.Money=10000000;while(1){if(!STOP){if(_____%10==0){gto(0,0),color(OC);for(int i=1;i<=WINDOWW+40;i++)putchar('-');gto(WINDOWC,0),color(OC);for(int i=1;i<=WINDOWW+40;i++)putchar('-');}_____++;POINT k;GetPos(k);Own.MovePrint(min(max(int(k.x)-3,1),WINDOWC-1),min(max(int(k.y),0),WINDOWW-1));if(KEY_DOWN(MOUSE_MOVED))Own.Shot();BulletsRefresh();if(BossFlag)BossRefresh();UFORefresh();BuffRefresh(),BuffTipRefresh();if(ScoreFlash){ScoreFlash=0;TP(10,WINDOWW+3,fred+flight+bwhite,"[ "),TP(10,WINDOWW+5,OC-bblack+bwhite,"Score: "),gto(10,WINDOWW+12),color(OC-bblack+bwhite),printf("%04lld + %08lld",Own.Score,Own.BossScore),TP(10,WINDOWW+27,fred+flight+bwhite," ]");Sleep(100);}TP(10,WINDOWW+3,fred+flight+bblack,"[ "),TP(10,WINDOWW+5,OC,"Score: "),gto(10,WINDOWW+12),color(OC),printf("%04lld + %08lld",Own.Score,Own.BossScore),TP(10,WINDOWW+27,fred+flight+bblack," ]");int T=(clock()-BEGINTIME)/1000;if(T!=LastT){TP(9,WINDOWW+3,fred+flight+bblack,"[ "),TP(9,WINDOWW+5,OC,"Time: "),gto(9,WINDOWW+11),color(OC),printf("%05d",T),TP(9,WINDOWW+16,fred+flight+bblack," ]");LastT=T;}}if(Own.Money!=LastMoney){if(MoneyFlash){MoneyFlash=0;TP(1,WINDOWW+3,fred+flight+bwhite,"[ "),TP(1,WINDOWW+6,OC-bblack+bwhite,"Money: "),gto(1,WINDOWW+13),color(OC-bblack+bwhite),printf("%08d",LastMoney=Own.Money),TP(1,WINDOWW+21,fred+flight+bwhite," ]");Sleep(100);}TP(1,WINDOWW+3,fred+flight+bblack,"[ "),TP(1,WINDOWW+6,OC,"Money: "),gto(1,WINDOWW+13),color(OC),printf("%08d",LastMoney=Own.Money),TP(1,WINDOWW+21,fred+flight+bblack," ]");}if(clock()-LastPreserveTime>=100){LastPreserveTime=clock();if(Preserve(AddFullBlood)){if(Own.Money>=ConstUpgradeCost[FullBloodGrade]){Own.Money-=ConstUpgradeCost[FullBloodGrade];Own.FullBlood+=200;MoneyFlash=1;FullBloodGrade++;}}if(Preserve(AddAttack)){if(Own.Money>=ConstUpgradeCost[AttackGrade]){Own.Money-=ConstUpgradeCost[AttackGrade];Own.AddAtack+=0.1;MoneyFlash=1;AttackGrade++;}}if(Preserve(AddShotSpeed)){if(Own.Money>=ConstUpgradeCost[ShotSpeedGrade]){Own.Money-=ConstUpgradeCost[ShotSpeedGrade];Own.AddShotSpeed+=0.05;MoneyFlash=1;ShotSpeedGrade++;}}TP(5,WINDOWW+31,ConstGradeColor[FullBloodGrade+1],ConstUpgradeCostStr[FullBloodGrade]);TP(2,WINDOWW+3,OC,"Max Blood: "),gto(2,WINDOWW+18),color(OC),printf("%06d",Own.FullBlood);TP(2,WINDOWW+25,ConstGradeColor[FullBloodGrade],ConstGradeName[FullBloodGrade]);Own.MovePrint(Own.x,Own.y,0);TP(6,WINDOWW+31,ConstGradeColor[AttackGrade+1],ConstUpgradeCostStr[AttackGrade]);TP(3,WINDOWW+3,OC,"Attack: "),gto(3,WINDOWW+18),color(OC),printf("%06d",int((Own.Buffs[3]?ConstBulletDamage[3]:ConstBulletDamage[1])*Own.AddAtack));TP(3,WINDOWW+25,ConstGradeColor[AttackGrade],ConstGradeName[AttackGrade]);TP(7,WINDOWW+31,ConstGradeColor[ShotSpeedGrade+1],ConstUpgradeCostStr[ShotSpeedGrade]);TP(4,WINDOWW+3,OC,"Attack Speed: "),gto(4,WINDOWW+18),color(OC),printf("%06d",int(Own.ShotSpeed*Own.AddShotSpeed));TP(4,WINDOWW+25,ConstGradeColor[ShotSpeedGrade],ConstGradeName[ShotSpeedGrade]);}if(kbhit()){char c=getch();if(c==' '){if(!STOP){TP(WINDOWC/2-1,WINDOWW/2-16,OC,"+----------------------------------+");TP(WINDOWC/2  ,WINDOWW/2-16,OC,"|   Press space bar to continue.   |");TP(WINDOWC/2+1,WINDOWW/2-16,OC,"+----------------------------------+");STOP=1;}else{TP(WINDOWC/2-1,WINDOWW/2-16,OC,"                                    ");TP(WINDOWC/2  ,WINDOWW/2-16,OC,"                                    ");TP(WINDOWC/2+1,WINDOWW/2-16,OC,"                                    ");STOP=0;RECT W;GetWindowRect(hd,&W);SetCursorPos(W.left+Own.y*8+10,W.top+Own.x*16+80);}}}/*Boos*/if(!BossFlag&&Own.NeedBoss()){//if(!BossFlag)Sleep(200);flash(3);OwnShotTimes=OwnLoseBlood=OwnShotOnTimes=0;EnemyClear();//UFORefreshTime=5000;//BuffAppearCD=5000;Boss.Init(cnt);BossFlag=1;cnt++;}}
}

相关文章:

C++控制台打飞机小游戏

我终于决定还是把这个放出来。 视频在这&#xff1a;https://v.youku.com/v_show/id_XNDQxMTQwNDA3Mg.html 具体信息主界面上都有写。 按空格暂停&#xff0c;建议暂停后再升级属性。 记录最高分的文件进行了加密。 有boss&#xff08;上面视频2分47秒&#xff09;。 挺好…...

Pinna的使用以及pinna的持续化存储(两种方法)

一、简介 pinia是 vue3 新的状态管理工具&#xff0c;简单来说相当于之前 vuex&#xff0c;它去掉了 Mutations 但是也是支持 vue2 的&#xff0c;需要的朋友可以参考下 二、使用方法 1.安装 npm install pinia -S 2..引入 import { createPinia,PiniaPluginContext } from p…...

开发中造成空指针的常见用法,如何避免

1. 前言 《手册》的第 7 页和 25 页有两段关于空指针的描述&#xff1a; 【强制】Object 的 equals 方法容易抛空指针异常&#xff0c;应使用常量或确定有值的对象来调用 equals。 【推荐】防止 NPE&#xff0c;是程序员的基本修养&#xff0c;注意 NPE 产生的场景: 返回类型为…...

MySQL事务和索引

目录 事务的概念 事务的四大特性&#xff08;ACID&#xff09; 原子性 隔离性 持久性 一致性 什么是脏读、幻读和不可重复读&#xff1f; 脏读 幻读 不可重复读 事务的隔离级别 读未提交 读已提交 可重复读 串行化 索引 索引优点 索引缺点 索引分类 索引设…...

Kali工具集简介

Kali Linux提供了数种经过定制的专门为渗透测试设计的工具。工具都会按下图中下拉选单所示的方式按组分类聚合。了解工具是做渗透测试第一个认知。 口Information Gathering(信息收集) 这些都是侦察工具,用来收集目标网络和设备的数据。在这类工具中,从找出设备的工具到查看使…...

离散数学 | 图论 | 欧拉图 | 哈密顿图 | 割点 | 桥(欧拉图和哈密顿图有没有割点和桥?)

本文主要解决以下几个问题&#xff1a; 1.欧拉图能不能有割点&#xff0c;能不能有桥&#xff1f; 2.哈密顿图能不能有割点&#xff0c;能不能有桥&#xff1f; 首先我们要明白几个定义 割点的定义就是在一个图G中&#xff0c;它本来是连通的&#xff0c;去掉一个点v以后这个…...

Android生命周期:理解与应用

摘要&#xff1a;Android生命周期是开发Android应用程序时至关重要的概念。本文将介绍Android生命周期的概念、生命周期方法的执行顺序以及如何在应用程序中正确地管理生命周期。我们还将讨论生命周期对于应用程序的重要性&#xff0c;并提供一些实际应用中的最佳实践和注意事项…...

00后真的是内卷王中王,真的想离职了....

都说00后躺平了&#xff0c;但是有一说一&#xff0c;该卷的还是卷。这不&#xff0c;前段时间我们公司来了个00年的&#xff0c;工作没两年&#xff0c;跳槽到我们公司起薪18K&#xff0c;都快接近我了。后来才知道人家是个卷王&#xff0c;从早干到晚就差搬张床到工位睡觉了。…...

linux Fd以及重定向讲解

感谢你的阅读&#xff0c;是对我最大的鼓励&#xff01;&#xff01;&#xff01;&#xff01; 目录 fd理解 文件操作重定向 让我们回顾C语言文件操作 首选我们要知道2个知识点&#xff1a; 额外知识点 如何理解一切皆文件呢&#xff1f; 当父进程fork创建子进程是否创建…...

Moonbeam近日提案公投一览

正在跟进Moonbeam治理的小伙伴&#xff0c;一起来快速浏览一下近期生态中正在发生的事情吧&#xff01;其中包含多个去中心化应用的Grant加速计划提案、HRMP开拓提案以及优化质押相关平台的内容。许多提案都与网络的运作息息相关&#xff0c;一起了解和参与Moonbeam的发展吧&am…...

凝聚青年力量,打造数字化人才队伍

当代青年人勇于探索、敢于创新、勤于变革&#xff0c;积极承担社会责任。这与ABeam倡导的「Build Beyond As One.™」的品牌理念不谋而合。ABeam的青年员工是未来社会的中坚力量&#xff0c;也正用他们的青春能量助力ABeam在中国的发展。 01 新兴青年力量 对ABeam而言&#…...

蓝牙资讯|智能家居标准Matter 1.1 发布,智能家居产品兼容更丰富

据“CSA 连接标准联盟”官方微信号&#xff0c;Matter 1.1 版本已发布&#xff0c;“1.1 版本带来的更新使设备制造商和开发者上手更容易、产品获取认证更方便&#xff0c;也让产品能更快地交付给用户。该版本还为电池供电设备提供了更大支持&#xff0c;而这类设备涉及多种类型…...

Cube Map 系列之:手把手教你 实现天空盒(Sky Box)

什么是天空盒 An skybox is a box with textures on it to look like the sky in all directions or rather to look like what is very far away including the horizon.天空盒是一个使用纹理贴图构建的盒子&#xff0c;人在其中朝任何一个方向看去&#xff0c;其纹理彷佛天空…...

腾讯VS百度:在AI上下大赌注

来源&#xff1a;猛兽财经 作者&#xff1a;猛兽财经 腾讯控股(00700)最近已经把基础模型和生成式人工智能应用方面的行业突破视为其业务的新增长机会了&#xff0c;并且正在大力投资人工智能&#xff0c;从而增强其现有产品的竞争力和拓展新的机会&#xff0c;比如腾讯已经把…...

字节原来这么容易进,是面试官放水,还是公司实在是太缺人?

本人211非科班&#xff0c;之前在字节和腾讯实习过&#xff0c;这次其实没抱着什么特别大的希望投递&#xff0c;没想到字节可以再给我一次机会&#xff0c;还是挺开心的。 本来以为有个机会就不错啦&#xff01;没想到能成功上岸&#xff0c;在这里要特别感谢帮我内推的同学&…...

生死疲劳|因为此书莫言获得诺贝尔奖

&#x1f4da;书名&#xff1a;《生死疲劳》 ✏️作者&#xff1a;莫言 历经六世的生死轮回&#xff0c; 三代人无尽的生死疲劳&#xff1b; 触碰极致的痛苦与快乐&#xff0c; 感受不灭的热情与希望。 &#x1f525;虽然本书长达39万字&#xff0c;但阅读过程却是无比的酣畅…...

Linux系统编程总结

day2 vim的三种工作模式 命令模式 vi hello.c zz 保存退出 2.编辑模式 i a o s &#xff08;有大写&#xff09;可以写东西 3.末行模式&#xff1a; 文本和末行模式不能直接切换 要切换回命令模式 再到末行模式&#xff0c;w:保存 q:退出 按两次esc回到命令模式 vim的基本…...

javascript基础二:Javscript字符串的常用方法有哪些?

在日常开发中&#xff0c;我们对字符串也是操作蛮多&#xff0c;这里我们来整理下字符串的一下最常用的方法 一、操作方法 字符串常用的操作方法归纳为增、删、改、查 增 这里增的意思并不是说直接增添内容&#xff0c;而是创建字符串的一个副本&#xff0c;再进行操作 除了…...

面了个 Java 实习生,小伙很优秀!

大家好&#xff0c;我是鱼皮&#xff0c;前几天给自己的公司面试了一位 Java 暑期实习生&#xff0c;候选人目前是大三。 整个过程我都录屏了&#xff0c;并且在征得候选人的同意后&#xff0c;把面试过程分享出来。一方面是希望对其他在学编程找工作的小伙伴有一些启发和参考…...

Java -并发(多线程)-Interview面试题收集

1、多线程并发 1&#xff09;多线程中 synchronized 锁升级的原理是什么&#xff1f; synchronized 锁升级原理&#xff1a;在锁对象的对象头里面有一个 threadid 字段&#xff0c;在第一次访问的时候 threadid 为空&#xff0c;jvm 让其持有偏向锁&#xff0c;并将 threadid…...

虚拟电厂接入现货后,最怕的不是资源不够,而是收益波动失控

2026年的虚拟电厂圈&#xff0c;大家都在焦虑一件事。不是政策不明确——去年底国家能源局发布的《电力中长期市场基本规则》&#xff0c;已经把虚拟电厂作为“新型经营主体”的入市路径、交易限额、结算方式写得明明白白。也不是资源不够——分布式光伏、工商业储能、充电桩、…...

从串行到并行:构建一个可控加减法器的高效设计实践

1. 从串行到并行&#xff1a;加减法器的设计演进之路 记得我第一次接触加法器设计时&#xff0c;对着教科书上的串行电路图发呆了整整一个下午。那些密密麻麻的连线就像一团乱麻&#xff0c;完全看不出为什么这样连接就能实现加法运算。直到后来自己动手搭建了一个4位串行加法器…...

最新多模式防红系统源码+对接易支付

内容目录一、详细介绍二、效果展示1.部分代码2.效果图展示一、详细介绍 最新多模式防红系统源码对接易支付 支持直链/跳转/短链接&#xff0c;使用本系统红了的域名可在微信和QQ直接打开&#xff0c; 系统带访问记录列表&#xff0c;可查看访问者ip和访问方式&#xff0c;带…...

开源工具助力音频内容管理:打破平台限制的跨平台解决方案

开源工具助力音频内容管理&#xff1a;打破平台限制的跨平台解决方案 【免费下载链接】xmly-downloader-qt5 喜马拉雅FM专辑下载器. 支持VIP与付费专辑. 使用GoQt5编写(Not Qt Binding). 项目地址: https://gitcode.com/gh_mirrors/xm/xmly-downloader-qt5 你是否曾遇到…...

csv文件生成与读取

1.csv 文件解析入库方法(少量) private boolean doProcessNew(FileInputStream fileInputStream) {long start System.currentTimeMillis();List<JtComplaintPredictionResultEntity> csvFileList new ArrayList<>();try (BufferedReader reader new BufferedRe…...

LFM2.5-1.2B-Thinking-GGUF企业级集成方案:与内部系统对接的认证与审计

LFM2.5-1.2B-Thinking-GGUF企业级集成方案&#xff1a;与内部系统对接的认证与审计 1. 企业级AI集成的核心挑战 当企业考虑将大语言模型集成到内部系统时&#xff0c;安全性、合规性和可管理性成为首要考量。我们最近为一家金融机构部署LFM2.5-1.2B-Thinking-GGUF模型时&…...

实战分享:如何用AST技术还原Akamai 2.0混淆后的JS代码(附避坑指南)

深入解析AST技术在Akamai 2.0 JS代码还原中的应用 现代Web安全防护体系中&#xff0c;代码混淆技术已成为保护前端逻辑的重要手段。作为行业领先的安全解决方案提供商&#xff0c;Akamai在其2.0版本中引入了更为复杂的JS混淆机制&#xff0c;这对逆向工程提出了新的挑战。本文将…...

3步突破资源提取瓶颈:让Wallpaper Engine效率提升300%的终极方案

3步突破资源提取瓶颈&#xff1a;让Wallpaper Engine效率提升300%的终极方案 【免费下载链接】repkg Wallpaper engine PKG extractor/TEX to image converter 项目地址: https://gitcode.com/gh_mirrors/re/repkg 在Wallpaper Engine资源开发领域&#xff0c;创作者和开…...

4.2-4.4

这期准备iic驱动上一期已经准备好了设备树&#xff0c;iic的驱动代码分为 I2C 适配器驱动和 I2C 设备驱动&#xff0c;一般iic适配器驱动由soc厂商去写iic设备树追加&#xff1a;1 &i2c4 { 2 status "okay"; 3 pinctrl-0 <&i2c4m1_xfer…...

STM32F103C8T6 + MPU6050 + TB6612:手把手教你从零搭建两轮平衡小车(附完整源码与PCB)

STM32F103C8T6 MPU6050 TB6612&#xff1a;从零构建两轮平衡小车的工程实践 平衡小车一直是嵌入式开发者入门的经典项目&#xff0c;它不仅融合了传感器技术、控制算法和机电一体化设计&#xff0c;还能让你在实践中深入理解PID控制等核心概念。今天我们就来拆解一个基于STM3…...