kite – Programmerbay https://programmerbay.com A Tech Bay for Tech Savvy Sat, 20 Aug 2022 18:25:07 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://programmerbay.com/wp-content/uploads/2019/09/cropped-without-transparent-32x32.jpg kite – Programmerbay https://programmerbay.com 32 32 C Program to Show a Kite is Flying https://programmerbay.com/c-program-to-show-a-kite-is-flying/ https://programmerbay.com/c-program-to-show-a-kite-is-flying/#respond Wed, 03 Aug 2022 08:46:20 +0000 https://www.programmerbay.com/?p=1969 The program uses translation transformation to implement flying kite in C. In computer graphics, translation allows reposition of an object. We can create an illusion of flying kite by frequently changing the object’s position.

C Program to show a kite is flying

Program:

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
void main()
{
int gm,gd=DETECT;
int i= 0,j=0,rnd_x=0,rnd_y,stop_me=0;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
srand(time());
while(stop_me<=1000)
{

if(i>=180 &&j>=100 ) // controlling kite, so that it wouldn't disappear from screen
{
rnd_x=rand()%4 -3;
rnd_y=rand()%5 -4;
}
else{
rnd_x=rand()%3;
rnd_y=rand()%3;
}
line(200+i,200-j,250+i,250-j);
line(200+i,200-j,150+i,250-j);
line(150+i,250-j,200+i,350-j);
line(200+i,350-j,250+i,250-j);
line(200+i,200-j,200+i,350-j);
arc(200+i,275-j,25,155,50);
line(0,500,200+i,225-j);
i=i+rnd_x;
j=j+rnd_y;
stop_me=5+stop_me;
delay(100);
clearviewport(); // clearing image which would make illusion of flying kite

}
getch();
closegraph();

}

Output:

]]>
https://programmerbay.com/c-program-to-show-a-kite-is-flying/feed/ 0