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

Home » C Home » Games and Graphics Home » Egg Game in C

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

Search Projects & Source Codes:

Title Egg Game in C
Author Varun Kumar Sonker
Author Email vksonker_is04 [at] iiita.ac.in
Description This is a game, where there are no. of eggs falling from the top of the screen randomly.
The player just have to save them from falling on the ground.
Category C » Games and Graphics
Hits 396869
Code Select and Copy the Code
#include"dos.h" #include"graphics.h" #include<stdio.h> #include<conio.h> #include<process.h> #include<dos.h> #include<stdlib.h> #include<iostream.h> union REGS i,o; main() { int initmouse(); int restrictmouseptr(int,int,int,int); int getmousepos(int *,int *,int *); int showmouseptr(); int gd=DETECT,gm,maxx,maxy,x,y,button; initgraph(&gd,&gm,""); int count=0; maxx=getmaxx(); maxy=getmaxy(); setbkcolor(1); setviewport(0,0,maxx,maxy,1); gotoxy(26,1); if(initmouse()==0) { closegraph(); restorecrtmode(); //to go back to normal graphics mode or deleting viewport. printf(" mouse driver not loaded"); exit(1); } restrictmouseptr(0,getmaxy()-20,maxx,getmaxy()-15); int a=30;int b=0; setcolor(0); setfillstyle(1,15); int score=0; count=20; int s=5; int level=0; char name[40]; gotoxy(5,2); cout<<"PLEASE ENTER YOUR SWEET NAME::-"; gets(name); gotoxy(5,2); cout<<" "; while(!kbhit()) { getmousepos(&button,&x,&y); setcolor(15); setfillstyle(1,15); fillellipse(a,b,10,15); if((b>getmaxy()-20)&&(b<=getmaxy()-15)) // For checking the egg position. { if(a>=(x-20)&&(a<=(x+60))) { score+=10; gotoxy(320,2); textcolor(13); cout<<"your score: "<<score; } } if(b>getmaxy()+40) { b=0; a=random(getmaxx()); gotoxy(10,2); cout<<"eggs left: "<<count; count--; if(count==-1) { gotoxy(32,10); cout<<"LEVEL COMPLETED."; level++; if(level==4) { goto varun; } count=10; s++; getch(); gotoxy(32,10); cout<<" "; } } setcolor(10); line(x,getmaxy(),x+40,getmaxy()); line(x,getmaxy(),x-20,getmaxy()-20); line(x+40,getmaxy(),x+60,getmaxy()-20); line(x-20,getmaxy()-20,x+60,getmaxy()-20); delay(10); setcolor(0); line(x,getmaxy(),x+40,getmaxy()); line(x,getmaxy(),x-20,getmaxy()-20); line(x+40,getmaxy(),x+60,getmaxy()-20); line(x-20,getmaxy()-20,x+60,getmaxy()-20); setfillstyle(1,0); fillellipse(a,b,10,15); b+=s; } varun: gotoxy(30,12); cout<<"EXCELLENT WORK "<<name; gotoxy(33,15); cout<<"GAME OVER. "; gotoxy(32,18); cout<<"YOUR SCORE:"<<score; gotoxy(58,24); cout<<"COMPOSED BY:"; gotoxy(55,25); cout<<"VARUN KUMAR SONKER"; gotoxy(30,10); cout<<"GREATEST SCORE::"<< 540; getch(); getch(); } initmouse() { i.x.ax=0;//for initialising mouse. int86(0x33,&i,&o); return(o.x.ax); } showmouseptr() { i.x.ax=1; // for displaying mouse pointer. int86(0x33,&i,&o); } restrictmouseptr(int x1,int y1,int x2,int y2) { i.x.ax=7; //to define the upper left boundry of mouse. i.x.cx=x1; i.x.dx=x2; int86(0x33,&i,&o); i.x.ax=8; //to define the bottom right boundry of mouse. i.x.cx=y1; i.x.dx=y2; int86(0x33,&i,&o); } getmousepos(int *button,int *x, int *y) { i.x.ax=3; //to move mouse. int86(0x33,&i,&o); *button=o.x.bx; *x=o.x.cx; *y=o.x.dx; }

Related Source Codes

Script Name Author
The Game Opposite as seen on Nokia 2300 Mobile Manikanta
RECURSIVE BALANCED QUICK SORT ashish
Radix Sort ashish
Change your mouse pointer Ashim
The blinking star Shashank
Data Validation Crylittlebaby
To search a file by giving file type like mp3 or mpeg or doc Prashanth SR
Menus Demonstration B.Chidhambaram
Employee Database Project Using C. Reenku Raman Nayak
Creating a Lexical Analyzer in c fahad bader al-buhairi ¦Õ¤ ?¤Ð Ãß??ÝÐÝ
Calendar Program Omkar & Devendra
Stop double Process for start in C Cedrik Jurak
Stop double Process for start in C Cedrik Jurak
Time Scheduler Atiq Anwar
A timepass game between atmost two players Rahul Roy

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=749


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