Add to Favorites    Make Home Page 2385 Online  
 Language Categories  
 Our Services  

Home » C++ Home » Computer Graphics Home » Moving ball screen saver

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Moving ball screen saver
Author karlmarx
Author Email karl_balan [at] yahoo.co.in
Description It i a simple moving ball screensaver, in which two balls are bounchback from the wall of the console.
Category C++ » Computer Graphics
Hits 518891
Code Select and Copy the Code
PROGRAMMERS DETAILS Name : Nadar Karlmarx Rajabalan Date Of Birth : 04-05-1985 Qualification : T.E. Computer College : A. C. Patil College Of Engg., Kharghar, Navi-mumbai. E-Mail Id : [email protected] [email protected] [email protected] */ #include"graphics.h" #include"dos.h" #include"conio.h" #include"stdlib.h" #define DELAY 1 #define SOUND 3500 void state(int x,int y,int mode); int i; void *ptr1[4],*ptr2[4]; /* 3d Ball */ char ball[20][20]= { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,12,12,12,12,12,12,12,12,0,0,0,0,0,0}, {0,0,0,0,12,12,12,12,12,12,12,12,12,12,12,12,0,0}, {0,0,0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0,0,0}, {0,0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0,0}, {0,0,12,12,12,12,12,15,15,12,12,12,12,12,12,12,12,12,0,0}, {0,12,12,12,12,12,15,12,12,12,12,12,12,12,12,12,12,12,12,0}, {0,12,12,12,12,15,12,12,12,12,12,12,12,12,12,12,12,12,12,0}, {0,12,12,12,15,15,12,12,12,12,12,12,12,12,12,12,12,12,12,0}, {0,12,12,12,15,15,12,12,12,12,12,12,12,12,12,12,12,12,12,0}, {0,12,12,12,15,15,12,12,12,12,12,12,12,12,12,12,12,12,12,0}, {0,12,12,12,12,15,12,12,12,12,12,12,12,12,12,12,12,12,12,0}, {0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0}, {0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0}, {0,0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0,0}, {0,0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0,0}, {0,0,0,12,12,12,12,12,12,12,12,12,12,12,12,12,12,0,0,0}, {0,0,0,0,12,12,12,12,12,12,12,12,12,12,12,12,0,0,0,0}, {0,0,0,0,0,0,12,12,12,12,12,12,12,12,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; /* Condition to check out of range */ int COND(int x,int y) { if (x>10 && x<getmaxx()-10 && y>10 && y<getmaxy()-10) return 1; else return 0; } /* This sub-routine will check which path to follow on stiking the wall of the container */ void state(int x,int y,int mode) { while(COND(x,y)&&!kbhit()) { putimage(x,y,ptr1[4],COPY_PUT); putimage(getmaxx()-x,getmaxy()-y,ptr1[4],COPY_PUT); switch(mode) { case 0: x++; y++; break; case 1: x++; y--; break; case 2: x--; y++; break; case 3: x--; y--; break; } delay(DELAY); nosound(); putimage(x,y,ptr2[4],COPY_PUT); putimage(getmaxx()-x,getmaxy()-y,ptr2[4],COPY_PUT); } cleardevice(); if(x>=(getmaxx()-10)||x<=10) { sound(SOUND); switch(mode) { case 0: state(--x,--y,2); break; case 1: state(--x,++y,3); break; case 2: state(++x,--y,0); break; case 3: state(++x,++y,1); break; } } else if(y>=getmaxy()-10||y<=10) { sound(SOUND); switch(mode) { case 0: state(--x,--y,1); break; case 1: state(--x,++y,0); break; case 2: state(++x,--y,3); break; case 3: state(++x,++y,2); break; } } else exit(0); } void main() { int gm,gd=DETECT; int i,j; initgraph(&gd,&gm,"\tc\tc\bgi"); for(i=0;i<20;i++) for(j=0;j<20;j++) if(ball[i][j]!='0') putpixel(10+i,10+j,ball[j][i]); getimage(10,10,30,30,ptr1[4]); cleardevice(); getimage(10,10,30,30,ptr2[4]); /* start with (20,20) */ state(20,20,0); getch(); }

Related Source Codes

Script Name Author
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi
Animated 3D car Aayush Awasthi,Delhi

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptId=1251


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review