# bouncing ball

• 11-10-2003
planet_abhi
bouncing ball
I made a bouncing ball with collision but it can't work
what is problem
here is the code

Code:

# include<iostream.h>
# include <conio.h>
# include <dos.h>
# include <math.h>
# include <graphics.h>
# define pi 3.14
# define m 1.3
int main()
{
int r=0;
float y0,t;
int i;
int gd=0,gm=0;
initgraph(&gd,&gm,"c\\tc\\bgi");
rectangle(0,10,637,478);
setfillstyle(1,WHITE);
for(i=1;i<=635;i=i+10)
{
setfillstyle(1,WHITE);
t  = m-pi * (2 * m-pi * 100 + m-pi /2) / 180;
y0 = abs (200 * sin(t) * exp (-1 * 0.004 * i ) );
setcolor(WHITE);
fillellipse(i,470-(int)y0,r,r);
delay(5);
setfillstyle(1,BLACK);
setcolor(BLACK);
fillellipse(i,470-(int)y0,r,r);
delay(5);
}
setfillstyle(1,WHITE);
t=m-pi*(2*m-pi*i*100+m-pi/2)/180;
y0=abs(200*sin(t)*exp(-1*0.004*i));
setcolor(WHITE);
fillellipse(i,470-(int)y0,r,r);
getch();
closegraph();
restorecrtmode();
return(0);
}

the equation is sin trignometric function.
• 11-10-2003
XSquared
What happens when you run it?
• 11-10-2003
planet_abhi
it can't collide it just rolls on screen

actulally i want the follwing output http://www.phy.ntnu.edu.tw/java/boun...ncingBall.html