bouncing,ball
Quick Search for: in language:   
bouncing,ball
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 342,436 lines
 Jobs: 945 postings

 

You are in:

 
Login


Latest Code Ticker for C/ C++
Computing very long Fibonacci numbers
By Alex Vinokur on 3/18


Flexible Vector and Matrix
By Alex Vinokur on 3/18


Windows ASM Program
By Kain on 3/18


C/C++ Program Perfometer
By Alex Vinokur on 3/18


n-ary Huffman Template Algorithm
By Alex Vinokur on 3/18


cryptsolver
By dhritimaan shukla on 3/17


Post - It
By Massimiliano Tomassetti on 3/17


JACKPOT GAME
By Gurjit Singh Wadhwa on 3/17


ROYAL COMPUTERS DATABASE
By Gurjit Singh Wadhwa on 3/17


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 

 
 

   

bouncing a ball

Print
Email
 
VB icon
Submitted on: 2/25/2002 8:04:27 AM
By: Rakshit Desai 
Level: Beginner
User Rating: Unrated
Compatibility:C, C++ (general)

Users have accessed this code 480 times.
 
 
     bouncing a ball
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: bouncing a ball
// Description:bouncing a ball
// By: Rakshit Desai
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/xq/ASP/txtCod
//     eId.3360/lngWId.3/qx/vb/scripts/ShowCode
//     .htm//for details.//**************************************
//     

#include<graphics.h>
#include<alloc.h>
    main(){
    int changedirnx(int xcur);
    int changedirny(int ycur);
    int gd=DETECT,gm,area,m,n,xmin=0,xmax=630,ymin=0,ymax=470,xcur=300,ycur=30;
    char *buff;
    int xch,ych,ini=0;
    //if(registerbgidriver(EGAVGA_driver)<
    //     ;0)exit();
    initgraph(&gd;,&gm;," ");
    cleardevice();
    setcolor(3);
    outtextxy(225,185,"B O U N C I N G B A L L");
    getch();
    cleardevice();
    setcolor(7);
    rectangle(2,2,630,479);
    rectangle(3,3,629,478);
    setcolor(13);
    circle(7,7,3);setfillstyle(SOLID_FILL,13);floodfill(7,7,13);
    area=imagesize(4,4,11,11);
    buff=malloc(area);
    getimage(4,4,11,11,buff);
    setcolor(0);
    circle(7,7,3);setfillstyle(SOLID_FILL,0);floodfill(7,7,0);
        while(!kbhit()){
        delay(200);if(ini!=0)putimage(m,n,buff,XOR_PUT);
        m=xcur;n=ycur; ini=1;
        putimage(xcur,ycur,buff,XOR_PUT);
        if(xcur>xmax || xcur<xmin)xch=changedirnx(xcur);
        if(ycur>ymax || ycur<ymin)ych=changedirny(ycur);
        if(xch==1)xcur++;else xcur--;
        if(ych==1)ycur++;else ycur--;}
        closegraph();restorecrtmode();
        clrscr();printf("Thank You.\n");
        getch();
    }

/*-----------------end of main()-------------------*/ changedirnx(int xcur){ int xch; if(xcur>630)xch=0; if(xcur<0)xch=1; sound(100);delay(80);nosound(); return(xch);} changedirny(int ycur){ int ych; if(ycur>460)ych=0; if(ycur<0)ych=1; sound(100);delay(80);nosound(); return(ych); }


Other 3 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The codewith your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
3/9/2002 2:48:22 PM:MikeD
Hi, I am a newbie C++ programmer, and 
trying to learn some graphics.  When I 
copythe bouncing ball code, and build 
it, I get 1 error: 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/9/2002 2:51:16 PM:this is the error
C:\MyProjects\bouncingball\bouncingball.
cpp(15) : fatal error C1083: Cannot 
open include file: 'graphics.h': No 
such file or directory
Error executing 
cl.exe.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.