Resources » Code Snippets » Graphics

Bouncing ball


Posted Date:     Category: Graphics    
Author: Member Level: Silver    Points: 10



 


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





Did you like this resource? Share it with your friends and show your love!


Responses to "Bouncing ball"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Handle Click Event for Eclipse:Window Application
    Previous Resource: C++ Code to Draw a Hut using "graphics.h" header
    Return to Resources
    Post New Resource
    Category: Graphics


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Bouncing ball  .  
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.