<> It was another quiet afternoon , therefore , The story begins

Maybe we all played such a game when we were young :

Open a bird , equipment ... Well, it's far away ..

There is such a crazy bird , Flying in the streets , Without flapping your wings , Will fall down at a certain speed , When you hit an obstacle ahead , Will die,
So let's call him stupid bird , So the name of the game is stupid birds fly first ( funny )

Make a general frame
#include<iostream> #include<cstdlib> #include<conio.h> #include<windows.h> //
gotoxy and HideCursor Header file for
show Function to initialize
void show()// Initial initialization ( Achieve the purpose of cyclic display ) { gotoxy(0,0) ; HideCursor() ; for(int i=1;i<y;
++i) { for(int j=1;j<x;++j) { if(j==birdx&&i==birdy) { cout<<"\b"<<" bird ";
//\b The function of is because the output Chinese characters occupy more space of one size ,\b Delete output from previous location } else if(j==xx&&(i>=1&&i<=yy)||j==xx&&(
i>=yy+5&&i<=y)) cout<<"*" ; else cout<<" "; } cout<<endl; } cout<<" score :"<<count/6
<<endl; }
\b The function of is because the output Chinese characters occupy more space of one size ,\b Deleting the output in the previous position is to delete the space of multiple outputs

Input related , Just a stupid bird controlled by a space flapping its wings (hhh)
void in() { if(kbhit()) { string ss; ss=getch(); if(ss==" ") { if(birdy>3)birdy
-=3; } } }
The bird's whereabouts and the speed at which obstacles steal are placed in a function independent of the input

void notin() // Change the position of birds and obstacles { if (birdx==xx&& (birdy>=yy&&birdy<=yy+5)) count
+=1; if(speed!=3) { speed++; } if(birdy!=y&&speed==3) { birdy+=1; speed=0; } if(
speed2!=5) { speed2++; } else if(speed2==5) { if(xx>0) { xx--; } if(xx==0) { xx=
x/2;// Obstacle x coordinate yy= rand()%(y/2); while(yy==0) { yy= rand()%(y/2); } } speed2=0; }

speed and speed2 Control the falling speed of birds and the speed of obstacles respectively , An operation is carried out by a loop to a certain value , Then reset speed and speed2 To control speed , It's more ingenious ( funny )
and `
void gotoxy(int x,int y) { HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos; pos.X=x; pos.Y =y; SetConsoleCursorPosition(handle,pos); } void
HideCursor() { CONSOLE_CURSOR_INFO cursor_info={1,0}; SetConsoleCursorInfo(
GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info); }
gotoxy Respectively used to control the cursor of the command line ( Clear screen ) And hide cursor ( That is, the cursor does not flash ) Role of

So so , The complete program is :
#include<iostream> #include<cstdlib> #include<conio.h> #include<windows.h>
using namespace std; int x=50; // Borderline x and y int y=20; int birdx=x/5; int birdy=y/4;
int speed=0;// Control speed int speed2=0;// Control the approaching speed of obstacles int xx=x/2;// Obstacle x coordinate int yy= rand()
%(y/2); int count=0;// Record the score of stupid bird void notin(); void in(); void gotoxy(int x,int y)
{ HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); COORD pos; pos.X=x; pos.Y =y;
SetConsoleCursorPosition(handle,pos); } void HideCursor() { CONSOLE_CURSOR_INFO
cursor_info={1,0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&
cursor_info); } void show()// Initial initialization ( Achieve the purpose of cyclic display ) { gotoxy(0,0) ; HideCursor() ;
for(int i=1;i<y;++i) { for(int j=1;j<x;++j) { if(j==birdx&&i==birdy) { cout<<
"\b"<<" bird "; //\b The function of is because the output Chinese characters occupy more space of one size ,\b Delete output from previous location } else if(j==xx&&(i>=1&&i<=yy
)||j==xx&&(i>=yy+5&&i<=y)) cout<<"*" ; else cout<<" "; } cout<<endl; } cout<<
" score :"<<count/6<<endl; } void in() { if(kbhit()) { string ss; ss=getch(); if(ss==
" ") { if(birdy>3)birdy-=3; } } } void notin() // Change the position of birds and obstacles { if (birdx==xx
&& (birdy>=yy&&birdy<=yy+5)) count+=1; if(speed!=3) { speed++; } if(birdy!=y&&
speed==3) { birdy+=1; speed=0; } if(speed2!=5) { speed2++; } else if(speed2==5)
{ if(xx>0) { xx--; } if(xx==0) { xx=x/2;// Obstacle x coordinate yy= rand()%(y/2); while(yy==0)
{ yy= rand()%(y/2); } } speed2=0; } } int main() { while(yy==0) { yy= rand()%(y/
2); } while(1) { show(); notin(); in() ; if(birdx==xx&&(((birdy>1&&birdy<yy))||(
birdy>yy+5&&birdy<y))) { cout<<"YOU ARE FILLED!!"<<endl; break; } } return 0; }
Running results of the program :

Of course, there are many areas for improvement , For example, many obstacles can be made , We just need to ensure that the distance between each obstacle is the same , Generate several more obstacles , Or you can join wsad To control silk peeling ( Fart ) Position of the bird , To increase some playability , Try it quickly hhh( It is recommended to eat in full screen yes)

Technology