Thread: Hard program? Need Help.. who can?

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    4

    Hard program? Need Help.. who can?

    hi ,
    im asked to do this program but I dont know how to keep the track of the movement of the ball(point) inside the circle ,
    the circle environment is given as n
    the details is here with this file .

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    struct coordinate
    {
        int xcoord, ycoord;
    };
    That'll suffice for tracking location. You could do it a few ways. Track coordinate on a grid based with a 0,0 as the center of the circle, using +/-X and +/-Y for the distance and direction from center. Or you could map the circle to a grid, so some place outside the circle to the upper left would be 0,0 and down to the right of the circle would be N,N.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    4
    thanx Quzah for your reply..
    please see these details in this attached file .

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    4
    guys ,,
    I didnt ask you to give me the solution,,
    I just want to ask about the general idea .. how to
    move this point with a specified direction from the user as as input..
    so the inputs are :
    point position and its direction
    ???

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    So what's your problem? Do you not know how to get input? Do you not know how to plot your circle to a grid? Do you not know how to plot a line for movement? What exactly?

    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    Nov 2003
    Posts
    4
    thank you quzah very much for your help
    my problem now is how to implement the speed of the point?
    in the question above , every point has a speed and weight ..
    how to do the speed thing?

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,657
    Here's one way
    Code:
    struct particle
    {
        int xcoord, ycoord;
        int dx, int dy;
    };
    Each time around the loop, its
    pt.xcoord += dx;

    Every time the particle bounces, change dx,dy
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. This site is as hard to use as c is to program
    By wurzull in forum C Programming
    Replies: 3
    Last Post: 04-07-2007, 11:28 AM
  2. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  3. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  4. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM
  5. Replies: 2
    Last Post: 05-10-2002, 04:16 PM