pls modify for me

Discussion in 'C' started by raymacsor, Mar 13, 2006.

  1. raymacsor

    raymacsor New Member

    Joined:
    Mar 13, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    plz help me guyzz....pls modify this....this code should have two balls and wen they bump each other they go in separate ways....
    i need it as soon as possible guyzz help...thanx
    Code:
    #include<conio.h>
    #include<graphics.h>
    #include<dos.h>
    #include<stdlib.h>
    main()
    {
     int gdriver=DETECT, gmode, r, col, row, pathx, pathy,speed;
     int forecolor, bkcolor, linecolor;
     initgraph(&gdriver,&gmode,"C:\\TCLITE\\BGI");
     randomize();
     r=random(40)+10;
     col=r+random(640-2*r);
     row=r+random(480-2*r);
     forecolor=random(14)+1;
     bkcolor=random(14)+1;
     linecolor=random(14)+1;
     speed=random(5)+1;
     pathx=(pathy=speed);
     setbkcolor(bkcolor);
     while (!kbhit())
     {
    	  col+=pathx;
    	  row+=pathy;
    	  setcolor(linecolor);
    	  circle(col,row,r);
    	  setfillstyle(SOLID_FILL,forecolor);
    	  floodfill(col,row,linecolor);
    	  delay(10);
    	  setfillstyle(SOLID_FILL,bkcolor);
    	  floodfill(col,row,linecolor);
    	  setcolor(bkcolor);
    	  circle(col,row,r);
    	  col+=pathx;
    	  row+=pathy;
    	  if (col+r>640) pathx=-(speed);
    	  if (row+r>480) pathy=-(speed);
    	  if (col-r<0) pathx=speed;
    	  if (row-r<0) pathy=speed;
     }
     closegraph();
    
    }
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,374
    Likes Received:
    388
    Trophy Points:
    83
    I edited the code to put the syntax highlighting syntax. Reading http://www.go4expert.com/showthread.php?t=168 will help you.

    Also regarding your query it looks like you are looking for a solution but did not mention where exactly the problem you are facing or what is the nature of the problem. Please clarify on this so that we can help you in this regard.
     
  3. raymacsor

    raymacsor New Member

    Joined:
    Mar 13, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    i need a code dat has 2 balls coz this code has only one ball and when the 2 balls bump each other they will go in separate way...
     
  4. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28
    We cannot give you the complete program for you but if you are stuck at any point then we can help.
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,374
    Likes Received:
    388
    Trophy Points:
    83
    exactly.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice