Mega Code Archive
Egg Game in C
#include"dos.h"
#include"graphics.h"
#include
#include
#include
#include
#include
#include
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: "<getmaxy()+40)
{
b=0;
a=random(getmaxx());
gotoxy(10,2);
cout<<"eggs left: "<