Three-Body Star Wars 1.0 (Invincible Version)!

The latest modification: the difficulty has been reduced, and a new tutorial has been added. . .

#include <bits/stdc++.h>
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
int toint(double a){return ((int)(a*10 + 5))/10;}
int rand(int a){return rand()%a;}
void SlowDisplay(int x,char *p){while(1){if(*p!=0) printf("%c",*p++);else break;Sleep(x);}}
void Setpos(double x,double y){COORD pos;pos.X=toint(y*2),pos.Y=toint(x);SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);}
void Color(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_RED|FOREGROUND_GREEN);
    if(a==-3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY|FOREGROUND_RED);

    if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
    if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED);
    if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED);
    if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN);
    if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);

    if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED|BACKGROUND_BLUE);
    if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_BLUE);
}
struct node{int what;double x,y,vx,vy,r,m;bool life;int gun,master=-1;}Sun[1000001];
int b,T,m[41][41],n[41][41],m2[41][41],n2[41][41],dif[11],Speed=10,Ba,Hotguntime, Hotguntimemax=10, Blood, Score;
double Speedmax, Speedless, Speedmore=1, Balljump=-0.7, Fire=0.08;//36 lines, 36 lines, 48 lines, 49 lines, 5 lines from the bottom
void Push(int a,int b){
    if(Sun[a].master==b||Sun[b].master==a) return;
    if(Sun[a]. life==0||Sun[b]. life==0) return;
    if(Sun[a].what==3||Sun[b].what==3) return;
    if(Sun[a].what==4||Sun[b].what==4) return;
    double Ax=Sun[a].x-Sun[b].x,Ay=Sun[a].y-Sun[b].y,Dis=sqrt(Ax*Ax + Ay*Ay)*1.0,fDis= sqrt((Sun[a].vx-Sun[b].vx)*(Sun[a].vx-Sun[b].vx) + (Sun[a].vy-Sun[b].vy)* (Sun[a].vy-Sun[b].vy));
    if(Dis==0) return;if(abs(Ay)<=0.0001) Ay=0.0001;
    if(Sun[a].what==2||Sun[b].what==2) int c;//The Japanese nuclear does not hit, int c; this sentence makes up the number
    else if(Dis<=Sun[a].r + Sun[b].r + fDis){
        double Vx=(Sun[a].vx + Sun[b].vx)/2.0,Vy=(Sun[a].vy + Sun[b].vy)/2.0,aX=(Sun[a].x + Sun[b].x + Sun[a].vx + Sun[b].vx)/2.0,aY=(Sun[a].y + Sun[b].y + Sun[a].vy + Sun [b].vy)/2.0;
        Sun[a].vx=Sun[b].vx=Vx,Sun[a].vy=Sun[b].vy=Vy;Sun[a].x=aX-(Ax/Dis)/2.0,Sun [b].x=aX + (Ax/Dis)/2.0;Sun[a].y=aY-(Ay/Dis)/2.0,Sun[b].y=aY + (Ay/Dis)/2.0;
        return;
    }
    double ac=Sun[a].m*Sun[b].m/(Dis*Dis)*1.0,afx=0,afy=0,d=abs(Ax/Ay*1.0);
    afy=sqrt(ac/(1 + d*d))*1.0,afx=sqrt(ac/(1 + d*d))*d*1.0;
    if(Ax>0) afx*=-1;if(Ay>0) afy*=-1;
#define A Sun[a].vx + =afx/Sun[a].m*Speedless,Sun[a].vx=max(-Speedmax,min(Speedmax,Sun[a].vx)),Sun[a ].vy + =afy/Sun[a].m*Speedless,Sun[a].vy=max(-Speedmax,min(Speedmax,Sun[a].vy))
#define B Sun[b].vx-=afx/Sun[b].m*Speedless,Sun[b].vx=max(-Speedmax,min(Speedmax,Sun[b].vx)),Sun[b ].vy-=afy/Sun[b].m*Speedless,Sun[b].vy=max(-Speedmax,min(Speedmax,Sun[b].vy))
    Speedmax=0.1, Speedless=0.01;
    if(Sun[a].what==2 & amp; & amp;Sun[b].what==2) Speedmax=3.0;
    if(Sun[a].what==0) {Speedless=0.008;Speedmax=3.0; A;}
    else if(Sun[a].what==1) {A; if(Sun[b].what==1) B;}
    else if(Sun[a].what==2) {Speedless=0.8;B;if(Sun[b].what==2) A;}
    else {A;B;}
}
int Painting[41][41]={<!-- -->{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0, 0,0,0,0,0,0},{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0, 0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},{0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1, 1,1,1,1,1,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0, 0,0,0,0},{0,0,0,0,0,0,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,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0, 0,0,0,0,0,0,0,2,9,9,9,9,9,9,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0},{0,0,0,0,0,0,0,0,0,0,0,3,9,9,9,9,9,9,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0,0,4,9,9,9, 9,9,9,9,9,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} ,{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0},};
void Paint(int a);
void Move(int a){
    Blood=10000000;
    memset(m,0,sizeof(m));//solar layer
    memset(m2,0,sizeof(m2));
    #define ix toint(Sun[i].x/1.0)
    #define iy toint(Sun[i].y/1.0)
    #define jx toint(Sun[j].x/1.0)
    #define jy toint(Sun[j].y/1.0)
    if(Sun[0].life==1){
    Sun[0].x + =Sun[0].vx/Speedmore;Sun[0].y + =Sun[0].vy/Speedmore;
    if(Sun[0].x>40) Sun[0].x=40,Sun[0].vx=0;if(Sun[0].x<0) Sun[0].x=0,Sun [0].vx=0;if(Sun[0].y>40) Sun[0].y=40,Sun[0].vy=0;if(Sun[0].y<0) Sun[ 0].y=0,Sun[0].vy=0;}

    for(int i=0;i<=b;i + + ) for(int j=i + 1;j<=b;j + + ) Push(i,j);
    for(int i=0;i<=b;i ++ ) for(int j=0;j<=b;j ++ )
    {
        if(i==j||Sun[i].life==0||Sun[j].life==0) continue;
    if(Sun[i].what==4 & amp; & amp;(Sun[j].what>=100 & amp; & amp;Sun[j].what<200)) {if(abs(ix- jx)<1 & amp; & amp;abs(iy-jy)<1) Ba--,Sun[i].life=Sun[j].life=0,Score + =10;}

        if(Sun[i].what==203 & amp; & amp;Sun[i].master!=j & amp; & amp;Sun[j].what<200) if(abs(ix-jx)< 2 & amp; & amp;abs(iy-jy)<2) Sun[j].vx-=Sun[i].vx/10.0,Sun[j].vy-=Sun[i].vy/10.0, Sun[i].life=0;
        if(Sun[i].what==204 & amp; & amp;Sun[i].master!=j & amp; & amp;Sun[j].what<200) if(abs(ix-jx)< 2 & amp; & amp;abs(iy-jy)<2) Sun[j].vx + =Sun[i].vx/10.0,Sun[j].vy + =Sun[i].vy/10.0, Sun[i].life=0;

    }
    int i=0;
    if(m[ix][iy]>0 & amp; & amp;m[ix][iy]<100)
    {
        if(m[ix][iy]<=1) Blood-=1;
        else if(m[ix][iy]<=4) Blood-=2;
        else if(m[ix][iy]<=10) Blood-=3;
        else if(m[ix][iy]>10 & amp; & amp;m[ix][iy]<100) Blood-=4;
    }
    for(int i=1;i<=b;i + + ){
        if(Sun[i]. life==0) continue;
        Sun[i].x + =Sun[i].vx/Speedmore;Sun[i].y + =Sun[i].vy/Speedmore;///
        Balljump=-0.7;
        if(Sun[i].what==3) Balljump=-1;
        if(Sun[i].what==4) Balljump=-1;
        if(Sun[i].x>40) Sun[i].x=40,Sun[i].vx*=Balljump;///
        if(Sun[i].x<0) Sun[i].x=0,Sun[i].vx*=Balljump;if(Sun[i].y>40) Sun[i].y=40, Sun[i].vy*=Balljump;if(Sun[i].y<0) Sun[i].y=0,Sun[i].vy*=Balljump;
        if(Sun[i].what==1) {m[ix][iy] + =2;int R;R=rand(3);if(R==0 & amp; & amp;ix<40) m[ix + 1][iy] + + ;R=rand(3);if(R==0 & amp; & amp;ix>0) m[ix-1][iy] + + ;R=rand (3);if(R==0 & amp; & amp;iy<40) m[ix][iy + 1] + + ;R=rand(3);if(R==0 & amp; & amp ;iy>0) m[ix][iy-1] + + ;}
        if(Sun[i].what==2) {m[ix][iy] + =2;if(ix<40) m[ix + 1][iy] + =10;if(ix>0) m [ix-1][iy] + =10;if(iy<40) m[ix][iy + 1] + =10;if(iy>0) m[ix][iy-1] + =10; if(ix<40 & amp; & amp;iy<40) m[ix + 1][iy + 1] + =4;if(ix<40 & amp; & amp;iy>0) m[ix + 1 ][iy-1] + =4;if(ix>0 & amp; & amp;iy<40) m[ix-1][iy + 1] + =4;if(ix>0 & amp; & amp ;iy>0) m[ix-1][iy-1] + =4;m[ix][iy]=10086;}
        if(Sun[i].what==3) {if(abs(ix-Sun[0].x)<1 & amp; & amp;abs(iy-Sun[0].y)<1) Ba- -,Sun[i].life=0;else m2[ix][iy]=2;}
        if(Sun[i].what==4) {m2[ix][iy]=2;}
//Sun[b].what=100~200 : bullet
        if(Sun[i].what>=100 & amp; & amp;Sun[i].what<300)
        {
            if(Sun[i].x==0||Sun[i].y==0||Sun[i].x==40||Sun[i].y==40||(abs(Sun [i].vx)<=0.5 & amp; & amp;abs(Sun[i].vy)<=0.5)) Sun[i].life=0;
            if(Sun[i].what==203||Sun[i].what==204) {m[ix][iy]=Sun[i].what;if(ix<40) m[ix + 1 ][iy]=Sun[i].what;if(ix>0) m[ix-1][iy]=Sun[i].what;if(iy<40) m[ix][iy + 1] =Sun[i].what;if(iy>0) m[ix][iy-1]=Sun[i].what;}
            else m2[ix][iy]=Sun[i].what;
        }
    }
    if(Sun[0].life==1) m2[toint(Sun[0].x/1.0)][toint(Sun[0].y/1.0)]=1;//i
    Paint(a);
}
void Paint(int a){
for(int i=0;i<=40;i ++ ) for(int j=0;j<=40;j ++ ){
    if(a==0 & amp; & amp;Painting[i][j]!=0) continue;

    if(m2[i][j]!=n2[i][j]){n2[i][j]=m2[i][j];n[i][j]=0;Setpos(i, j);
    if(m2[i][j]==0) Color(0),cout<<" ";
    else if(m2[i][j]==1) Color(-1),cout<<"●";
    else if(m2[i][j]==2) Color(-3),cout<<"◎";
    else if(m2[i][j]==101) Color(-1),cout<<"☉";
    else if(m2[i][j]==102) Color(3),cout<<" ";
    continue;}
    if(m[i][j]!=n[i][j]){n[i][j]=m[i][j];n2[i][j]=0;Setpos(i, j);
    if(m[i][j]>=10086) Color(4),cout<<"●";
    else if(m[i][j]==203) Color(5),cout<<" ";
    else if(m[i][j]==204) Color(6),cout<<" ";
    else if(m[i][j]==0) Color(0),cout<<" ";else if(m[i][j]<=1) Color(1),cout<<" "; else if(m[i][j]<=4) Color(2),cout<<" ";else if(m[i][j]<=10) Color(3),cout<<" "; else if(m[i][j]>10 & amp; & amp;m[i][j]<100) Color(4),cout<<" ";
    else Color(0),cout<<"?!";}Color(0);
    }
}
void RandStart(int a) {for(int i=1;i<=a;i + + ) {b + + ;Sun[b].x=rand(41),Sun[b].y=rand(41 );Sun[b].vx=(rand(41)-20)/10.0,Sun[b].vy=(rand(41)-20)/10.0,Sun[b].m=1,Sun[b ].r=1,Sun[b].life=1,Sun[b].what=1;}}
void CornerStart(int a) {for(int i=1;i<=a;i + + ) {b + + ;int k=rand(4);if(k==0||k==2) Sun [b].x=rand(41);else Sun[b].y=rand(41);if(k==0) Sun[b].y=0;if(k==1) Sun[b ].x=0;if(k==2) Sun[b].y=40;if(k==3) Sun[b].x=40;Sun[b].vx=(rand(41) -20)/10.0,Sun[b].vy=(rand(41)-20)/10.0,Sun[b].m=1,Sun[b].r=1,Sun[b].life=1 ,Sun[b].what=1;}}
void SunStart(int x,int y,int r,int vx,int vy) {
b + + ;Sun[b].x=x,Sun[b].y=y;Sun[b].vx=vx,Sun[b].vy=vy,Sun[b].m=1000,Sun [b].r=1,Sun[b].life=1,Sun[b].what=2;
for(int i=x-r;i<=x + r;i + + ) for(int j=y-r;j<=y + r;j + + ){b + + ;Sun[b].x=i, Sun[b].y=j;Sun[b].vx=(rand(41)-20)/100.0 + vx,Sun[b].vy=(rand(41)-20)/100.0 + vy,Sun [b].m=1,Sun[b].r=1,Sun[b].life=1,Sun[b].what=1;}
for(float i=(int)(x-r/2)-0.5;i<=(int)(x + r/2) + 0.5;i ++ ) for(float j=(int)(y-r/2)- 0.5;j<=(int)(y + r/2) + 0.5;j + + ){b + + ;Sun[b].x=i,Sun[b].y=j;Sun[b]. vx=(rand(41)-20)/100.0 + vx,Sun[b].vy=(rand(41)-20)/100.0 + vy,Sun[b].m=1,Sun[b].r =1,Sun[b].life=1,Sun[b].what=1;}
}
void Shoot(int a, bool q)
{
    double Sunavx=Sun[a].vx,Sunavy=Sun[a].vy;
    if(Sun[a].vx==0 & amp; & amp;Sun[a].vy==0) Sunavx=-1;if(Sun[a].vy==0) Sunavy=0.001;
    if(Sun[a].gun>=1 & amp; & amp;Sun[a].gun<=4)
    {
        b + + ;Sun[b].x=Sun[a].x,Sun[b].y=Sun[a].y;double ac;
        if(Sun[a].gun==1) ac=3.0;//speed
        if(Sun[a].gun>=2 & amp; & amp;Sun[a].gun<=4) ac=7.0;
        double d=abs(Sunavx/Sunavy*1.0);Sun[b].vy=sqrt(ac/(1 + d*d))*1.0,Sun[b].vx=sqrt(ac/(1 + d* d))*d*1.0;
        if(Sunavx>0) Sun[b].vx*=-1;if(Sunavy>0) Sun[b].vy*=-1;if(q==1) Sun[b].vx*=- 1,Sun[b].vy*=-1;Sun[b].life=1;
        Sun[b].master=a;
        int bb=b;
        if(Sun[a].gun==1||Sun[a].gun==2) Sun[b].what=100 + Sun[a].gun,Sun[b].m=1;
        if(Sun[a].gun==3||Sun[a].gun==4) Sun[b].what=200 + Sun[a].gun,Sun[b].m=1;
        if(Sun[a].gun>=2 & amp; & amp;Sun[a].gun<=4){
    double kx=Sun[bb].x,ky=Sun[bb].y;
    for(int j=1;j<=7;j++)
    {
    kx-=Sun[bb].vx/3.5, ky-=Sun[bb].vy/3.5;
    if(kx<0||ky<0||kx>40||ky>40) continue;
    b + + ,Sun[b].x=kx,Sun[b].y=ky,Sun[b].vx=Sun[bb].vx,Sun[b].vy=Sun[bb].vy, Sun[b].what=Sun[bb].what,Sun[b].master=a,Sun[b].life=1;
    }
        }
    }
}
void Start(){
    for(int i=0;i<=40;i ++ ) for(int j=0;j<=40;j ++ ){if(Painting[i][j]==1) Setpos(i, j),Color(-2),cout<<"";if(Painting[i][j]==2) Setpos(i,j),Color(-2),cout<<"Author: Taishen Big ";if(Painting[i][j]==3) Setpos(i,j),Color(-2),cout<<"Press y to start the game!";if(Painting[i][j]= =4) Setpos(i,j),Color(-2),cout<<"Don't mistake it for pinyin input method!";if(Painting[i][j]==5) Setpos(i,j), Color(-2),cout<<"Three-Body STAR WARs!";}
    for(int i=1;i<=3;i + + ) SunStart(rand(31) + 5,rand(31) + 5,5,(rand(101)-50)/10.0,(rand(101) -50)/10.0);
    T=0;
    while (1) {
        T++;
        if(TP==0) CornerStart(1);
        if(kbhit()){char g=_getch();if(g=='y') break; }
        Move(0);
        Sleep(Speed);
    }
    Color(0);system("cls");
    Setpos(10,10);SlowDisplay(30,"Do you want a tutorial? (y/n)");
    char g=_getch();if(g!='y') return;Setpos(10,10);SlowDisplay(30,"Then let's start...");Sleep(500);
    system("cls");
    Setpos(1,10);SlowDisplay(50,"--- words written before the tutorial ---");Sleep(500);
    Setpos(3,2);SlowDisplay(2,"This is the second shooting game of Taishenda after "Little Tire of Vitality", and it also completed the infinite direction shooting game that was conceived at that time (Little Tire of Vitality Eight directions). The rough release of this game is because the operation is extremely complicated, and the game playability is extremely low if the complexity is added. Some things have been edited but are still being debugged, such as laser guns and gravitational beams (put Sun[0].gun is changed to 2,3,4), in short, it is more difficult, and the game is over.");
    Setpos(30,10);system("pause");system("cls");

    memset(Sun,0,sizeof(Sun));memset(m,0,sizeof(m));memset(m2,0,sizeof(m2));
    Sun[0].x=Sun[0].y=20;Sun[0].life=1;Sun[0].m=10;
    T=0;
    int step=0;
    while (1) {
        T++;
        if(T==2)
        {
        Setpos(10,10),SlowDisplay(30,"This is your spaceship, you can use the ↑↓←→ keys to control it.");Sleep(500);
        Setpos(12,10),SlowDisplay(30,"There is no resistance in space travel, which means your inertia will dominate everything.");Sleep(500);
        Setpos(14,10),SlowDisplay(30,"When you hit the boundary, your speed will be reduced to zero.");Sleep(1000);
        Setpos(16,10),SlowDisplay(30,"Try it.");
// T=201;step=1;//
        }
        if(T==200)
        {
        Setpos(10,10),SlowDisplay(30,"There are two small tricks in space travel: ");
        Setpos(12,10),SlowDisplay(30,"1, not too fast.");
        Setpos(14,10),SlowDisplay(30,"2. Sometimes turning is more useful than turning around.");Sleep(1000);
        Setpos(16,10),SlowDisplay(30,"Let's increase the difficulty a little bit! Please reach all target positions!");Sleep(500);
        for(int i=1;i<=10;i + + ) {b + + ;Sun[b].x=rand(40),Sun[b].y=rand(40);Sun[b]. vx=(rand(101)-50)/30.0,Sun[b].vy=(rand(101)-50)/30.0,Sun[b].life=1,Sun[b].what=3;Ba + + ;}
        Move(1);Sleep(1000);
        }
        if(Ba>0) Setpos(1,1),cout<<"Remaining target sites: "<<Ba<<' ';
        if(step>=1) Setpos(5,1),cout<<"Cooling time: "<<Hotguntime<<" ";
        if(T>200 & amp; & amp;Ba==0 & amp; & amp;step==0) T=201,step=1,Setpos(1,1),cout<<" ";
        if(T>300 & amp; & amp;Ba==0 & amp; & amp;step==1) T=201,step=2,Setpos(1,1),cout<<" ";
        if(T==202 & amp; & amp; step==1)
        {
        Setpos(10,10),SlowDisplay(30,"Good job! It seems that it's time to equip you with the initial weapon.");
        Setpos(12,10),SlowDisplay(50,"... The Railgun is equipped.");
        Setpos(14,10),SlowDisplay(30,"press w/s to fire the bullet!");
        Sun[0].gun=1;Hotguntime=0;
        }
        if(T==300 & amp; & amp; step==1)
        {
        Setpos(16,10),SlowDisplay(30,"Come on! Please destroy all target sites!");Sleep(500);
        for(int i=1;i<=10;i + + ) {b + + ;Sun[b].x=rand(40),Sun[b].y=rand(40);Sun[b]. vx=(rand(101)-50)/30.0,Sun[b].vy=(rand(101)-50)/30.0,Sun[b].life=1,Sun[b].what=4;Ba + + ;}
        Move(1);Sleep(1000); Ba=10;
        }
        if(T==202 & amp; & amp; step==2)
        {
        Setpos(10,10),SlowDisplay(30,"You have seen the sun before.");
        Setpos(12,10),SlowDisplay(30,"The fire wrapped around it will drain your blood.");
        Setpos(14,10),SlowDisplay(30,"You can accumulate 10 points for the target position, -1 point for firing bullets, and clear the level with 100 points, easy!");Sleep(1000);
        Setpos(16,10),SlowDisplay(60,"It's hard to kill you, hahahaha!! Let's start!!!");Sleep(1000);
        system("cls"); return;
        }
        double v=sqrt(Sun[0].vx*Sun[0].vx + Sun[0].vy*Sun[0].vy);
        if(GetAsyncKeyState(VK_UP) & amp;0x8000) {if(Sun[0].vx>=0) Sun[0].vx-=2*Fire; else if(v<4) Sun[0].vx- =Fire;}
        else if(GetAsyncKeyState(VK_DOWN) & amp;0x8000) {if(Sun[0].vx<=0) Sun[0].vx + =2*Fire; else if(v<4) Sun[0].vx + =Fire;}
        if(GetAsyncKeyState(VK_LEFT) & amp;0x8000) {if(Sun[0].vy>=0) Sun[0].vy-=2*Fire; else if(v<4) Sun[0].vy- =Fire;}
        else if(GetAsyncKeyState(VK_RIGHT) & amp;0x8000) {if(Sun[0].vy<=0) Sun[0].vy + =2*Fire; else if(v<4) Sun[0].vy + =Fire;}

        if(Hotguntime>0) Hotguntime--;
        if(kbhit()){
        char g=_getch();
        if(Hotguntime==0 & &g=='s')
        {
            if(abs(Sun[0].vx)>=0.01) Sun[0].vx*=0.7;
            if(abs(Sun[0].vy)>=0.01) Sun[0].vy*=0.7;
            Shoot(0,0);
            Hotguntime=Hotguntimemax;
        }
        if(Hotguntime==0 & &g=='w')
        {
            if(abs(Sun[0].vx)<=2) Sun[0].vx*=1.2;
            if(abs(Sun[0].vy)<=2) Sun[0].vy*=1.2;
            Shoot(0,1);
            Hotguntime=Hotguntimemax;
        }
        }
        Move(1);
        Sleep(Speed);
    }
}
int main()
{
    system("mode con cols=82 lines=43");
    CONSOLE_CURSOR_INFO cursor_info={1,0};
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
    srand((unsigned)time(NULL));
    Y:
    Start();
    memset(Sun,0,sizeof(Sun));memset(m,0,sizeof(m));memset(m2,0,sizeof(m2));
    YY:system("cls");
    Setpos(10,10),SlowDisplay(30,"Choose the difficulty, how many suns? (0~10, press Enter to confirm)");
    int i=10;while(dif[i]!=1 & amp; & amp;i>=0){i--;}
    Setpos(12,10);
    if(i==-1) printf("You are very good now, recommended difficulty: 0 suns.");
    else if(i<10) printf("Come on, recommended difficulty: %d suns.",i + 1);
    else if(i==10) printf("666666! You have passed the level! Choose whatever you want!",i);

    Setpos(15,10);
    int p;cin>>p;
    if(p<0||p>10) {SlowDisplay(150,"Are you kidding me? Input error!"),Sleep(1000);goto YY;}
    for(int i=1;i<=p;i + + ) SunStart(rand(31) + 5,rand(31) + 5,5,(rand(101)-50)/10.0,(rand(101) -50)/10.0);
    Sun[0].x=Sun[0].y=5;Sun[0].vx=0.1;Sun[0].life=1;Sun[0].m=10;
    T=0;
    Sun[0].gun=1;
    Blood=100;
    Score=0;Ba=0;
    for(int i=1;i<=10;i + + ) {b + + ;Sun[b].x=rand(40),Sun[b].y=rand(40);Sun[b]. vx=(rand(101)-50)/30.0,Sun[b].vy=(rand(101)-50)/30.0,Sun[b].life=1,Sun[b].what=4;Ba + + ;}
    while(Blood>0 & amp; & amp;Score<100){
        Setpos(1,1),cout<<"Blood: "<<Blood<<" ";
        Setpos(3,1),cout<<"Score: "<<Score<<" ";
        Setpos(5,1),cout<<"Cooling time: "<<Hotguntime<<" ";
        T++;
        if(T==1) Sleep(1000);
        if(TP==0) CornerStart(1);
        if(T0==0 & amp; & amp;Ba<5) {b + + ;Sun[b].x=rand(40),Sun[b].y=rand(40);Sun[b]. vx=(rand(101)-50)/30.0,Sun[b].vy=(rand(101)-50)/30.0,Sun[b].life=1,Sun[b].what=4;Ba + + ;}
        if(T@==0 & amp; & amp;Blood<100) Blood ++ ;

        double v=sqrt(Sun[0].vx*Sun[0].vx + Sun[0].vy*Sun[0].vy);
        if(GetAsyncKeyState(VK_UP) & amp;0x8000) {if(Sun[0].vx>=0) Sun[0].vx-=2*Fire; else if(v<4) Sun[0].vx- =Fire;}
        else if(GetAsyncKeyState(VK_DOWN) & amp;0x8000) {if(Sun[0].vx<=0) Sun[0].vx + =2*Fire; else if(v<4) Sun[0].vx + =Fire;}
        if(GetAsyncKeyState(VK_LEFT) & amp;0x8000) {if(Sun[0].vy>=0) Sun[0].vy-=2*Fire; else if(v<4) Sun[0].vy- =Fire;}
        else if(GetAsyncKeyState(VK_RIGHT) & amp;0x8000) {if(Sun[0].vy<=0) Sun[0].vy + =2*Fire; else if(v<4) Sun[0].vy + =Fire;}

        if(Hotguntime>0) Hotguntime--;
        if(kbhit()){
        char g=_getch();
        if(Hotguntime==0 & &g=='s')
        {
            if(abs(Sun[0].vx)>=0.01) Sun[0].vx*=0.7;
            if(abs(Sun[0].vy)>=0.01) Sun[0].vy*=0.7;
            Shoot(0,0);
            Score=max(Score-1,0);
            Hotguntime=Hotguntimemax;
        }
        if(Hotguntime==0 & &g=='w')
        {
            if(abs(Sun[0].vx)<=2) Sun[0].vx*=1.2;
            if(abs(Sun[0].vy)<=2) Sun[0].vy*=1.2;
            Shoot(0,1);
            Score=max(Score-1,0);
            Hotguntime=Hotguntimemax;
        }
        }Move(1);
        Sleep(Speed);
    }
    system("cls");
    if(Score<100) Setpos(10,10),SlowDisplay(150,"It's over, you know.");
    else Setpos(10,10),SlowDisplay(10,"6666666666666666666666666!!!Win! Go and challenge the next difficulty!"), dif[p]=1;
    Sleep(1000);
    goto Y;
    return 0;
}