#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
int xmid,ymid,xb,yb;
int a=300,b=120;
void initialize()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tcc");
cleardevice();
xmid=getmaxx()/2;
ymid=getmaxy()/2;
}
void ground()
{
setcolor(LIGHTBLUE);
line(0,ymid+100,640,ymid+100);
}
void lighthouse()
{
setcolor(BROWN);
line(xmid-40,ymid+99,xmid+40,ymid+99);
line(xmid-25,ymid-100,xmid+25,ymid-100);
line(xmid-40,ymid+99,xmid-25,ymid-100);
line(xmid+40,ymid+99,xmid+25,ymid-100);
rectangle(xmid-10,ymid-115,xmid+10,ymid-100);
}
void karakkam()
{
int angle,x,y,c=0;
float angle_rad;
xb=xmid,yb=ymid-107;
angle=0;
while(!kbhit())
{
lighthouse();
angle_rad=(3.14/180)*angle;
//parametric equation of ellipse
x=xb+a*cos(angle_rad);//a=xmajor
y=yb-b*sin(angle_rad);//b=yminor
setcolor(YELLOW);
line(xb,yb,x,y);
delay(30);
if(c>=20)
{
lighthouse();
angle_rad=(3.14/180)*(angle-20);
x=xb+a*cos(angle_rad);
y=yb-b*sin(angle_rad);
setcolor(BLACK);
line(xb,yb,x,y);
}
else
c++;
angle++;
}
}
void main()
{
initialize();
ground();
lighthouse();
karakkam();
getch();
closegraph();
}
No comments:
Post a Comment