Draw A Kite In C language
Post date: Jan 10, 2012 6:15:21 PM
#include<stdio.h>
#include<graphics.h>
#include<alloc.h>
int main(void)
{
void *kite;
int s,x,y,gd=DETECT,gm,r;
initgraph(&gd,&gm,"c:\tc");
setcolor(10);
moveto(100,100);
lineto(125,75);
lineto(150,100);
lineto(120,130);
lineto(130,130);
lineto(125,125);
lineto(100,100); //this completes the outline design of kite
setfillstyle(SOLID_FILL,BLUE);
floodfill(125,100,10);
floodfill(125,127,10);
arc(125,120,40,140,31);
line(125,125,125,75);
line(125,110,150,130);
line(125,94,150,130);
s=imagesize(100,75,150,130);
kite=(void*)malloc(s);
getimage(100,75,150,130,kite);
putimage(100,75,kite,XOR_PUT);
x=100,y=75;
while(!kbhit())
{
setcolor(10);
putimage(x,y,kite,XOR_PUT);
setcolor(YELLOW);
line(x+50,y+55,639,479);
delay(100);
putimage(x,y,kite,XOR_PUT);
setcolor(0);
line(x+50,y+55,639,479);
r=rand();
switch(r%4)
{
case 0:x=x+10; break;
case 1:x=x-10; break;
case 2:y=y+10; break;
case 3:y=y-10;break;
}
if(x>640) x-=40;
if(x<40) x+=40;
if(y>479) y-=40;
if(y<40) y+=40;
}
getch();
closegraph();
return 0;
}