/* ============== Program Description ============= */ /* program name : ch24_30.c */ /* ball moving application. */ /* ================================================== */ #include #include void main() { int driver = DETECT,mode; int x = 100, y = 160, radius = 20, xdir; initgraph(&driver,&mode,"G:\\APPS\\BC31.WIN\\bgi"); rectangle(79,139,521,181); while ( !kbhit() ) { 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(); }