Code:
#include<graphics.h>
#include<conio.h>
#include<dos.h>
int i,j,k=240,l=265,gm,gd=DETECT,scor1=0,scor2=0;
int y1=61,y=61,y2=439,x=100,x1=50,x2=630;
void main()
{clrscr();
initgraph(&gd,&gm,"c:\\borlandc\\bgi");
line(0,50,640,50);
line(0,450,640,450);
bar(10,240,15,265);
bar(625,240,630,265);
x=x1;
y=y1;
while(scor1!=2)
{scor1=0;
setcolor(0);
circle(x,y,10);
x=x+j;
y=y+i;
setcolor(15);
circle(x,y,10);
delay(10);
if (y==y1)
i=1;
if (y==y2)
i=-1;
if (x==x1)
j=1;
if (x==x2)
j=-1;
}
getch();
closegraph();
}
So far i have this. I know that by what i have done the ball just moves around on the monitor but i plan to work on that after i am able to move the bars.
Oh and the parameters for while are useless. I was just toying around.