#include  <math.h>
#include<dos.h>
#include<stdio.h>
#include  <graphics.h>
#include<iostream.h>
#include<conio.h>
void show(int i,float h, float v);
void erease(int i, float h, float v);
void planeshow(int i,int k);
void ereasep(int i, int k);

void main(void)
{
    int   driver = DETECT,mode;
    int   i,j,i1,s1,k;
    int   y=1,xx;
    char x;
    int a[100];
       for(i=0; i<=99; i++)
       a[i]=0;
    initgraph(&driver,&mode,"D:\\bc31\\bgi");

      setcolor(WHITE);
      line(1,400,400,400);
      j=1;
    for ( i = 0; i < 80; i++ )
     {
	 setcolor(BLUE);  planeshow(5*i, 5);

	show(i, 5.0, 9.0);
	  y=1;
	_AH=0x01;
	 geninterrupt(0x16);
	  y=_FLAGS&0x40;

	if(y == 0)
	{
	_AH=0x00;
	 geninterrupt(0x16);
	 x=_AL;
	  if (x == 'a') {j=j+1;a[j]=i;}
	  if (x =='u' ) xx=xx+5;
	  if (x == 'i') xx=xx-5; }
	  setcolor(YELLOW);  planeshow(5*(i-8), xx);
	 for (k=2; k<=j; k++)
	if (a[k]!=0) {show(i-a[k], 10.0+0.5*k, 8.0+0.1*k); }
	delay (300);
	ereasep(5*i, 5); ereasep(5*(i-8), 0);
	erease(i, 5.0, 9.0);
	 for (k=2; k<=j; k++)
	if (a[k]!=0) {erease(i-a[k], 10.0+0.5*k, 8.0+0.1*k); }

     }

    closegraph();
}
void show(int i, float h, float v)
{    int x, y;

    x=h*i;
    y=v*i-0.15*i*i;
    setcolor(RED);
    circle(400-x,400-y,2);

}
void erease(int i, float h, float v)
{
   int x, y;
    x=h*i;
    y=v*i-0.15*i*i;
   setcolor(BLACK);
   circle(400-x,400-y,2);
}
void planeshow(int i,int k)
{
    int j;

    circle(i+5, 202+k, 2);
    circle(i+3, 204+k, 2);

    for (j=0; j<=8; j++)
    circle(i+j, 200+k, 2);

    circle(i+5, 198+k, 2);
    circle(i+3, 196+k, 2);
}
void ereasep(int i, int k)
{
    int j;
     setcolor(BLACK);
    circle(i+5, 202+k, 2);
    circle(i+3, 204+k, 2);

    for (j=0; j<=8; j++)
    circle(i+j, 200+k, 2);

    circle(i+5, 198+k, 2);
    circle(i+3, 196+k, 2);
}