# Flying Bird using Computer graphics in C/C++

• Last Updated : 12 Oct, 2021

In computer graphic, C++ provide graphic.h through which objects can be created and by using this objects flying bird can be created in C++ program.

Functions used in this program are as follows:

Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for the language and STL. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
• line(): The line function is used to draw a line.
Syntax:

line(x1, y1, x2, y2);
where, (x1, y1) (x2, y2) are end points of the line.

• arc(): The arc function is used to draw an arc.
Syntax:

arc(x, y, start_angle, end_angle, r);
where, (x, y) are centre of the arc, start_angle is the starting angle, end_angle is the ending angle and r is the radius of angle.

• circle(): The circle function is used to draw a circle.
Syntax:

circle(x, y, r);
where, (x, y) is the centre points and r is the radius of the circle.

• delay(): The delay function is used to stop the screen for a certain time as the execution of program is very fast.
Syntax:

delay(n);
where, n is number of seconds you want to stop the screen.

• cleardevice(): The cleardevice function is used to clear the screen.
• closegraph(): The closegraph function is used to close the graph.

Below is the C++ program implementing flying bird using graphics.h:

## C++

 `// C++ program implementing flying bird using graphics.h` `#include ``#include ``#include ``#include ` `// Wings``void` `handDown(``int` `i)``{``    ``line(85 + i, 155, 45 + i, 185);``    ``line(85 + i, 155, 115 + i, 195);``    ``arc(90 + i, 130, 228, 292, 70);``}` `void` `handUp(``int` `i)``{``    ``line(85 + i, 155, 125 + i, 115);``    ``line(85 + i, 155, 55 + i, 118);``    ``arc(90 + i, 177, 60, 122, 70);``}` `// Driver code``void` `main()``{``    ``int` `gd = DETECT, gm;` `    ``// Path of the BGI folder``    ``initgraph(&gd, &gm, ``"C:\\TURBOC3\\BGI"``);``    ``int` `i = 0;` `    ``for` `(i = 0; i < 400; i++) {``        ``// Body``        ``circle(150 + i, 150, 20);``        ``arc(90 + i, 190, 50, 145, 60);``        ``arc(87 + i, 117, 220, 320, 60);` `        ``// Beak``        ``line(170 + i, 147, 180 + i, 153);``        ``line(180 + i, 153, 170 + i, 156);` `        ``// Eye``        ``circle(162 + i, 150, 2);` `        ``// Tail``        ``line(10 + i, 155, 40 + i, 155);``        ``line(10 + i, 145, 40 + i, 155);``        ``line(10 + i, 165, 40 + i, 155);` `        ``// Move hands``        ``if` `(i % 2 == 0)``            ``handUp(i);``        ``else``            ``handDown(i);` `        ``// Stop the screen for 10 secs``        ``delay(10);` `        ``// Clear the screen``    ``}``    ``cleardevice();` `    ``getch();` `    ``// Close the graph``    ``closegraph();``}`

Output:

My Personal Notes arrow_drop_up