Code:
/* press Esc key to quit */
#include<stdio.h>
#include<graphics.h>
#include<alloc.h>
#define UP 0x48
#define DOWN 0x50
#define ESC 27
int main(void) {
void *kite;
int ch, s,x,y,gd=DETECT,gm,r, offy;
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 = malloc(s);
getimage(100,75,150,130,kite);
putimage(100,75,kite,XOR_PUT);
x=100,y=75;
offy = 10;
while(1) {
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(kbhit()) {
offy=getch();
if(offy == UP) y -= 30;
if(offy == DOWN) y+= 30;
if(offy == ESC) break;
}
if(x>640) x-=40;
if(x<40) x+=40;
if(y>490) y-=40;
if(y<40) y+=40;
}
closegraph();
return 0;
}
Enjoy!