C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Graphics »

Bouncing ball


Posted Date: 14 Jun 2009    Resource Type: Code Snippets    Category: Graphics
Author: PoojaMember Level: Silver    
Rating: 1 out of 5Points: 10 (Rs 5)



/* 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();
}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Bouncing ball  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Handle Click Event for Eclipse:Window Application
Previous Resource: C++ Code to Draw a Hut using "graphics.h" header
Return to Discussion Resource Index
Post New Resource
Category: Graphics


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use