masre 0 Newbie Poster

hey everyone,
m doing an assignment on bouncing ball,my code below doesn't bounce the ball,it just makes it move when the enter button is used,what can I do to make the ball bounce?

#include<alloc.h>
#include<graphics.h>
#include<conio.h>
#include<stdlib.h>
#include<dos.h>

void main()
{
    int d=DETECT,m;
    initgraph(&d,&m,"H:\\tc\\bgi");
    int l=getmaxx()/2,t=0;
    int x=1,y=1;
    int xstep=1,ystep=1;
    while(!kbhit())
    {
    cleardevice();
    circle(l,t,18);
      delay(5);
     circle(l,t,18);
    if(l>=getmaxx()||l<=0)
      {
	x*=-1;
	xstep=x*(random(4)+1);
	ystep=y*(random(3)+1);

      if (l<=0)
       t=0;
     else
      l=getmaxx();
       }
       if(t>=getmaxy()||t<=0)
       {
	 y*=-1;
	 ystep=(y*random(4)+1);
	 xstep=(x*random(3)+1);
       if(t<=0)
	 t=0;
       else
	 t=getmaxy();
      }
	l+=x+xstep;
	t+=y+ystep ;
	getch();

	}
	closegraph();

}

pls help urgently

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.