/* ============== Program Description ============= */ /* ball moving application. */ /* ================================================== */ #include #include void main() { int driver = DETECT,mode; int i,x = 100, y = 160, radius = 20, xdir=4; initgraph(&driver,&mode,"a:\\bgi"); rectangle(79,139,521,181); for(i=100; i<=500;i=i+4) { setcolor(BLACK); circle(x,y,radius); // if ( x == 500 ) /* touch the rightmost */ // xdir = -4; // else if ( x == 100 ) /* touch the leftmost */ // xdir = 4; x += xdir; setcolor(WHITE); circle(x,y,radius); delay(50); } getch(); closegraph(); }