Thread: bouncing ball

  1. #1
    Registered User planet_abhi's Avatar
    Join Date
    Oct 2002
    Posts
    92

    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.
    AbHHinaay

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    What happens when you run it?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User planet_abhi's Avatar
    Join Date
    Oct 2002
    Posts
    92
    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
    AbHHinaay

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to create a bouncing ball?
    By Swerve in forum C++ Programming
    Replies: 7
    Last Post: 09-12-2008, 03:41 AM
  2. The Old Bouncing Ball
    By bartybasher in forum Game Programming
    Replies: 3
    Last Post: 08-19-2003, 03:06 AM
  3. Simple bouncing ball program
    By funkydude9 in forum Game Programming
    Replies: 3
    Last Post: 08-18-2003, 10:00 PM
  4. Bouncing ball
    By SKINp in forum Game Programming
    Replies: 4
    Last Post: 01-13-2003, 02:26 PM
  5. Bouncing ball - help ??
    By Gugge in forum C Programming
    Replies: 7
    Last Post: 04-13-2002, 02:34 PM