Jump to content

help me with this c graphics program


Recommended Posts

hello

i have got a c graphics program of a demonstration of a flying kite.i have to alter this program to make a user input of the rope of kite.For example when when the program start it will be asking for a user input length of the rope of the kite.so that we can adjust the height of the kite...please kindly help...

this is the original program can you please alter this with my requirement

my requirement is to set a user input for the height of the kite while flying

Note:i am a new to the c language.i ma doing this for my friend.

#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;
}

Link to comment
Share on other sites


Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...