/* This is the code for bouncing ball.Very simple application of Graphics.I think it is helpful for freshers to understand graphics.*/
#include #include #include main() { int gm,x,y,gd=DETECT,i; initgraph(&gd,&gm,"z:\\tc\\bgi");// This is to initialise graphics x=getmaxx(); y=getmaxy(); setcolor(3);
line(0,470,650,470);
for(i=0;i<150;i=i+10)// this is the for loop for continuing bouncing of ball { setcolor(5); circle(2+i,310+i,20);//for balls size delay(300);// by hoe much speed the ball will bounce setcolor(0); circle(2+i,310+i,20); } for(i=0;i<=150;i=i+10) { setcolor(10); circle(140+i,450-i,20); delay(100); setcolor(0); circle(140+i,450-i,20); }
for(i=0;i<150;i=i+10) { setcolor(10); circle(300+i,310+i,20); delay(100); setcolor(0); circle(300+i,310+i,20); } for(i=0;i<=150;i=i+10) { setcolor(10); circle(450+i,450-i,20); delay(100); setcolor(0); circle(450+i,450-i,20); } getch(); closegraph(); }
|
No responses found. Be the first to respond and make money from revenue sharing program.
|