Friday, June 6, 2008

A RUNNING PEACOCK


#include stdio.h
#include conio.h
#include graphics.h

///WRITE stdio.h, conio.h , graphics.h inside this type of brackets < >
int maxx,maxy;
void main()
{
int gmode,gdri,xmid,ymid,a,b,x,y,c;
void far *ptr[4];
gdri=DETECT;
initgraph(&gdri,&gmode,"c:\\tc\\bgi");
maxx=getmaxx();
maxy=getmaxy();
//xmid=xmax/2;
//ymid=ymax/2;
//putpixel(400,440,2);
line(310,370,550,180);
line(160,260,310,370);
line(160,260,448,260);
setfillstyle(1,9);
floodfill(320,300,15);
line(260,290,340,290);
line(260,290,300,320);
line(300,320,340,290);
setfillstyle(1,12);
floodfill(300,300,15);
line(160,260,160,155);
line(200,260,200,130);
line(200,130,160,110);
line(160,110,110,130);
line(110,130,160,155);
line(160,240,200,240);
setfillstyle(1,10);
floodfill(180,245,15);
line(126,139,126,123);
setfillstyle(1,6);
floodfill(125,130,15);
setfillstyle(1,14);
floodfill(180,200,15);
circle(160,130,5);
setfillstyle(1,0);
floodfill(160,130,15);
b=440;
a=220;
c=400;
x=15;
y=15;
while(!kbhit())
{
drawleg(a,b,c);
delay(100);
eraseleg(a,b,c);
a+=x;
c-=y;
if(a>400^a<220)
{
x*=-1;
y*=-1;
}

}
getch();
closegraph();
}
drawleg(int p,int q,int r)
{
setcolor(15);
line(310,370,p,q);
line(310,370,r,q);
return(0);
}

eraseleg(int p,int q,int r)
{
setcolor(0);
line(310,370,p,q);
line(310,370,r,q);
return(0);
}







SAVE IT AS .C FILE
RUN IT USING TC APPLICATION