C/C++ graphics program to make a INSECT


C/C++ graphics program to make a INSECT











#include <graphics.h>
#include <conio.h>

void main()
{
int d;
int m;
d=DETECT; //detect for driver
int midx;
int midy;


initgraph(&d,&m,"d:\\tc\\bgi"); //initialize the graphics

midx=getmaxx()/2; //get mid horizontal point
midy=getmaxy()/2; //get mid vertical point

setfillstyle(2,6);
fillellipse(midx,midy,100,50); //Insect body

//Creating insects 6 feets :

setfillstyle(1,6);
fillellipse(midx,midy-70,20,20);

setfillstyle(1,6);
fillellipse(midx-60,midy-61,20,20);

setfillstyle(1,6);
fillellipse(midx+60,midy-61,20,20);

setfillstyle(1,6);
fillellipse(midx,midy+70,20,20);

setfillstyle(1,6);
fillellipse(midx-60,midy+61,20,20);

setfillstyle(1,6);
fillellipse(midx+60,midy+61,20,20);

//creating insect's face

setfillstyle(1,6);
fillellipse(midx-100,midy,40,40);

//creating insects eyes

setfillstyle(1,8);
fillellipse(midx-120,midy-20,7,7);

setfillstyle(1,8);
fillellipse(midx-120,midy+20,7,7);

getch();

closegraph();
}

Output :














Moving this insect :

In the next programm you will learn how to move this insect.

0 comments:

Post a Comment