C Program to Show a Kite is Flying

Share

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:

This post was last modified on August 20, 2022

Sandeep Verma

Published by
Sandeep Verma
Tags: c program computer graphics kite Transformation translation