Saturday, June 11, 2011

Source Code For "The Egg Pass Game" done in WinBGIm Graphics Library and CodeBlocks IDE

Project Type : Game
Graphics  Library :WinBgi
Development Environment : Codeblocks 




 
//------------------------------------------------------------------------------------------//
//-----------------------------------NOTE------------------------------------------------//
//----------------- ALL  files and  the headers could not be included -----------------------//
//--------- .You must visit download link below to view all the codes and resources --------//
//---------------------------needed to run the code-----------------------------------------//
//------------------------------------------------------------------------------------------//




http://www.4shared.com/file/mFZvkcfz/The_Egg-Pass_2.html


1. main.cpp


 #include <graphics.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <fstream>
#include <time.h>
#include "mainmenu.h"
#include "metallic.h"
#include "classes.h"
#include "playerinfo.h"


#define lightblue COLOR(135,230,220)
#define headercolor COLOR(50,255,200)
#define barcolor COLOR(236,233,216)
#define tcolor COLOR(250,250,250)
#define bcolor COLOR(182,178,163)
#define random(range) rand()%range
using namespace std;


void soundplay(int);
void click_handler(int x,int y);
void btnrelease_handler(int x,int y);
int showmenulink(int xpos,int ypos);
int checklink();
void showmsg(int x,int y,int width,int height,int bkcol);
void border3d(int l,int t,int r,int b,int topcolor,int bottomcolor);
class buton;
class egg;
class foodstatus;
#define ran(range) (rand() % (range))
void StatusLine(char c[]);
int    ErrorCode;
int    midx, midy,MaxX,MaxY,gmfldxmax,gmfldxmin,missmax=6,level=1;
int    MaxColors;
int    jmpsnd[3][2]={900,20,0,20,1500,20},stpt[2][2]={1500,50,500,100},obstclsnd[5]={100,50,170,30,200},snd[7][2]={200,100,0,1000,200,200,0,1500,900,200,0,2500,700,200};
bool ato,down,up,fire,jump = false,jmp=false,jumpok=false,mark=false,pause=false,sound=true,canstop=false,dobs=false,activeAI=false,hyperj=false;
float  Tfactor=1;
int dhila=int(5*Tfactor);
player nowplayer;
boundbtn sbtn[4];
Tbasket basket[5];
Dbasket dbas;
startin circl;
food fod[2];
egg egg1;
obstcl obs[2];
timer tcount;
player playr[10];
//here goes the classes used...................................................
//Tbasket.....................................................................................................
             Tbasket::Tbasket():x(midx),alt(0),y(500),xmn(gmfldxmin+24),xmx(gmfldxmax-24),spd(0),width(24){}
             void Tbasket::constructor(){
                //seting initials......(like in constructor).............
                x=midx;
                alt=0;
                y=500;
                yo=100;
                xmn=gmfldxmin+24;
                xmx=gmfldxmax-24;
                spd=0;
                width=24;
                wid=gmfldxmax-gmfldxmin;
                }
             void Tbasket::draw(){
                int size;
                int xt=100,yt=500;
                int widt=24;
                int clearance=2;
                int hi=rand()%500+100;
                  //gradient colouring.............
                  int r=0,g=0,b=0;
                  int c=0;
                  if(baskcolor[0]>baskcolor[1]&&baskcolor[0]>baskcolor[2])
                    r=1;
                  else if(baskcolor[2]>baskcolor[1]&&baskcolor[2]>baskcolor[1])
                    b=1;
                  else
                    g=1;
                  for(int k=0;k<25;k++){
                          int colour =COLOR(baskcolor[0]*(25-k)/(25+20*r)+100*r,baskcolor[1]*(25-k)/(25+20*g)+100*g,baskcolor[2]*(25-k)/(25+20*b)+100*b);//baskcolor[0]-(c*51)/5;//(255-c*51/5);//+70;//+60;
                          setcolor(colour);
                          setfillstyle(1,colour);
                          bar(xt+k,yt-widt,xt+(50-k),yt+widt+2*clearance);
                   }
                  setcolor(0);
                  moveto(xt,yt);
                  lineto(xt+50,yt);
                  arc(xt+widt+clearance/2,yt,180,0,widt);
                  setfillstyle(1,COLOR(0,0,0));
                  floodfill(xt+5,yt-clearance,0);
                  floodfill(xt+45,yt-clearance,0);
                  floodfill(xt+45,yt+widt+clearance,0);
                  floodfill(xt+5,yt+widt+clearance,0);
                  size = imagesize(xt,yt-clearance,xt+50,yt+widt+clearance); /*measure size*/
                  bask = malloc(size);                  /*allocate memory space*/
                  getimage(xt,yt-clearance,xt+50,yt+widt+clearance,bask);      /* grab the image */
                  yt=300;
                  }
             void Tbasket::set(int ap,int xp,int yp,int speed){
                        int xcom;
                        int xid=(xp-gmfldxmin-wid/2);
                        if(xid==0)
                            xcom=0;
                        else
                            xcom=xid/abs(xid);
                  if(ap!=0)
                         alt=ap;
                  if(alt==13 || alt==14)
                        x=gmfldxmin+wid/2;
                  if(alt==17){
                        yo=200;
                        y=int(yo-10*sin((x-(gmfldxmin+width/2))*8*M_PI/wid));
                    }
                  else if(alt==24){
                            yo=150;
                            y=int(.2*(x-gmfldxmin)+yo);
                        }
                  else if(alt==26){
                        yo=400;
                        y=int(yo-200*sqrt(1-4*pow((x-gmfldxmin-wid/2),2)/(wid*wid)));
                    }
                  else if(alt==29){
                        yo=200;
                        y=int(yo-30*sin((x-(gmfldxmin+width))*2*M_PI/(wid-46)));
                    }
                  else if(alt==31){
                        yo=200;
                        y=int(yo-30*pow(sin((x-(gmfldxmin+width))*2*M_PI/(wid-46)),3));
                    }
                  else if(alt==33){
                        yo=150;
                        y=int(yo+19*(1+xcom)*(1+1)-xcom*.3*(1+1)*((x-xmn)%(wid/2-width)-2*int((x-xmn)/(wid/2-width))*(width)));
                        y=(y>270)?150:y;
                    }
                 else if(alt==35){
                        yo=250;
                        y=int(yo-19*(1+xcom)*(1+spd/(abs(spd)))+xcom*.3*(1+spd/(abs(spd)))*((x-xmn)%(wid/2-width)-2*int((x-xmn)/(wid/2-width))*(width)));
                        y=(y<130)?250:y;
                    }
                 else if(alt==39){
                        yo=50;
                            if(y<200)
                                y=int(yo-10*sin((x-xmn)*8*M_PI/wid));
                            else
                                y=350;
                    }
                 else if(alt==40){
                        yo=255;
                        y=int(yo-.2*(x-xmn));
                    }
                 else if(alt==41){
                        yo=50;
                        if(y<200)
                            y=int(yo-spd/(abs(spd))*30*sin((x-(gmfldxmin+width))*2*M_PI/(wid-46)));
                        else
                            y=350;
                    }
                 else if(alt==42){
                        yo=200;
                        y=int(yo-abs(int(30*cos((x-xmn)*2*M_PI/(wid-46)))));
                    }
                 else if(alt==43){
                        yo=100;
                       if(y<250)
                            y=int(yo*(1-.75*sqrt(1-4*pow(xid,2)/(wid*wid))));
                       else
                            y=350;
                    }
                 else if(alt==44){
                        yo=250;
                        y=int(yo-19*(1+xcom)*(1+spd/(abs(spd)))+xcom*.3*(1+spd/(abs(spd)))*((x-xmn)%(wid/2-width)-2*int((x-xmn)/(wid/2-width))*(width)));
                        y=(y<130)?250:y;
                    }
                  else
                        y=yp;
                  yspd=5;
                  ang=0;
                  }
             void Tbasket::setspd(int sp)
                 {
                    spd=sp;
                 }
             void Tbasket::setap(int ap){
                  alt=ap;
                  }
             void Tbasket::sety(int ap){
                    if(alt==43 || alt==44)
                        y=ap-4;
                    else
                        y=ap;
                  }
             void Tbasket::setyo(int yos)
             {
                    yo=yos;
             }
             void Tbasket::loadesp(){
                  int cases;
                  if(alt==1||alt==12||alt==4)
                       cases=1;//stop
                  else if(alt==2||alt==3||alt==9||alt==18||alt==27||alt==28)
                       cases=2;//normal
                  else if(alt==7||alt==16||alt==22)
                       cases=3;//slow
                  else if(alt==6||alt==15||alt==20||alt==21||alt==30||alt==32||alt==34||alt==36||alt==38)
                       cases=4;//fast
                  else if(alt==5||alt==8||alt==10||alt==11||alt==19||alt==23||alt==25||alt==37)
                       cases=5;//|----!-------!--------|
                  else if(alt==13||alt==14)
                       cases=6;//samex
                  else if(alt==17||alt==24||alt==26||alt==29||alt==31||alt==33||alt==35||alt==39||alt==40||alt==41||alt==42||alt==43||alt==44||alt==45)
                       cases=7;//extra
                  switch(cases){
                        case 1://stop
                            spd=0;
                            xmn=gmfldxmin+width;
                            xmx=gmfldxmax-width;
                            x=gmfldxmin+wid/2;
                            break;
                        case 2://normal
                            spd=2+random(level);
                            xmn=gmfldxmin+width;
                            xmx=gmfldxmax-width;
                            if(alt%2)
                                x=xmn+50;
                            else
                                x=xmx-50;
                            break;
                        case 3://slow
                            spd=2*int(pow(-1,(random(2))));
                            xmn=gmfldxmin+width;
                            xmx=gmfldxmax-width;
                            x=gmfldxmin+wid/2;
                            break;
                        case 4://fast
                            spd=3+random(level+1)%3;
                            if(alt==21)
                                spd=-spd;
                            xmn=gmfldxmin+width;
                            xmx=gmfldxmax-width;
                            x=gmfldxmin+wid/2;
                            break;
                        case 5://-----!-!------/
                            if(alt==23)
                            {
                                spd=2+random(level);
                                xmn=gmfldxmin+width+wid/2;
                                xmx=gmfldxmax-width;
                                x=xmn;
                            }
                            else if(alt==8||alt==25)
                            {
                                spd=2+random(level);
                                xmn=gmfldxmin+width;
                                xmx=gmfldxmax-width-wid/2;
                                x=xmn+100;
                            }
                            else if(alt==10)
                            {
                                spd=3;
                                xmn=gmfldxmin+width;
                                xmx=gmfldxmax-width-wid/3;
                                x=xmn;
                            }
                            else if(alt==11)
                            {
                                spd=-3;
                                xmn=gmfldxmin+width+wid/3;
                                xmx=gmfldxmax-width;
                                x=xmn;
                            }
                            else if(alt==5||alt==19 || alt==37)
                            {
                                spd=2+random(level);
                                xmn=gmfldxmin+width+wid/5;
                                xmx=gmfldxmax-width-wid/5;
                                x=xmn;//**
                            }
                            else{
                                spd=2+random(level);
                                xmn=gmfldxmin+width+wid/5;
                                xmx=gmfldxmax-width-wid/5;
                                x=xmn;
                            }
                            break;
                        case 6:
                            spd=3+random(level%3);
                            xmn=gmfldxmin+width;
                            xmx=gmfldxmax-width;
                            //x=gmfldxmin+100;
                            break;
                        case 7:
                            spd=3;
                            xmn=gmfldxmin+width;
                            xmx=gmfldxmax-width;
                            if(alt==26 || alt==43){
                                yo=(alt<43)?400:100;
                                x=xmn;
                                }
                            else if(alt==17 || alt==29||alt==31|| alt==39 || alt==41){
                                yo=(alt<39)?200:50;
                                x=(alt<39)?(xmn+wid/2-width):xmn;
                                }
                            else if(alt==42){
                                yo=200;
                                x=xmn+wid/4-width;
                                }
                            else if(alt==24 || alt==40){
                                yo=(alt<40)?150:255;
                                x=275+xmn;
                                }
                            else if(alt==35 || alt==44){
                                yo=250;
                                x=524;
                                }
                            else
                                x=xmn;
                            break;
                        default:
                            spd=3+random(level);
                            xmn=gmfldxmin+width;
                            xmx=gmfldxmax-width;
                            x=xmn+50;
                        }
                      spd=(spd<5)?spd:5;
                    }


             int Tbasket::_x(){
                 return(x);
                 }
             int Tbasket::_y(){
                 return(y);
                 }
             int Tbasket::_spd(){
                 return(spd);
                 }
             int Tbasket::_alt(){
                 return alt;
                  }
             int Tbasket::_xmn(){
                 return xmn;
                  }
             int Tbasket::_xmx(){
                 return xmx;
                  }
             void Tbasket::show(int xs,int ys,bool forced){
                  if(!forced){
                        int xcom;
                        int xid=(xs-gmfldxmin-wid/2);
                        if(xid==0)
                            xcom=0;
                        else
                            xcom=xid/abs(xid);
                  if(alt==24)
                      ys=int(.2*(xs-gmfldxmin)+yo);
                  else if(alt==26)
                      ys=int(yo*(1-0.5*sqrt(1-4*pow((xs-gmfldxmin),2)/(wid*wid))));
                  else if(alt==29)
                        ys=int(yo-spd/(abs(spd))*30*sin((xs-(gmfldxmin+width))*2*M_PI/(wid-46)));
                  else if(alt==31)
                        ys=int(yo-spd/(abs(spd))*30*pow(sin((xs-(gmfldxmin+width))*2*M_PI/(wid-46)),3));
                  else if(alt==33){
                        ys=int(yo+19*(1+xcom)*(1+spd/(abs(spd)))-xcom*.3*(1+spd/(abs(spd)))*((xs-xmn)%(wid/2-width)-2*int((xs-xmn)/(wid/2-width))*(width)));
                        ys=(ys>(yo+120))?yo:ys;
                    }
                 else if(alt==35 || alt==44){
                        ys=int(yo-19*(1+xcom)*(1+spd/(abs(spd)))+xcom*.3*(1+spd/(abs(spd)))*((xs-xmn)%(wid/2-width)-2*int((xs-xmn)/(wid/2-width))*(width)));
                        ys=(ys<(yo-120))?yo:ys;
                    }
                 else if(alt==39){
                            if(y<200)
                                ys=int(yo-10*sin((xs-xmn)*8*M_PI/wid));
                            else
                                ys=350;
                    }
                 else if(alt==40){
                        ys=int(yo-.2*(xs-xmn));
                    }
                 else if(alt==41){
                        if(y<200)
                            ys=int(yo-spd/(abs(spd))*30*sin((xs-(gmfldxmin+width))*2*M_PI/(wid-46)));
                        else
                            ys=350;
                    }
                 else if(alt==42){
                        ys=int(yo-abs(int(30*cos((xs-xmn)*2*M_PI/(wid-46)))));
                    }
                 else if(alt==43){
                       if(y<250)
                            ys=int(yo*(1-.75*sqrt(1-4*pow(xid,2)/(wid*wid))));
                       else
                            ys=350;
                    }
                }
                else
                      ys=ys;
                putimage(xs-24,ys,bask,XOR_PUT);
             }
             void Tbasket::show(int xs,int ys){
                  show(xs,ys,true);
                  }
             void Tbasket::move(){
                  putimage(x-24,y,bask,XOR_PUT);
                  if(x>xmx){
                        spd=-1*abs(spd);
                        x=xmx;
                    }
                  else if(x<xmn){
                        spd=abs(spd);
                        x=xmn;
                        }
                  //if(alt!=17 && alt!=24 && alt!=26 && alt!=29 && alt!=31 && alt!=33 && alt!=35 && alt!=39 && alt!=40 && alt!=41 && alt!=42 && alt!=43 && alt!=44){
                        x+=spd;
                        int xcom=1;
                        int xid=(x-gmfldxmin-wid/2);
                        if(xid==0){
                            xcom=-1;
                            }
                        else
                            xcom=xid/abs(xid);
                  //          }
                  if(alt==17){
                            y=int(yo-10*sin((x-(gmfldxmin+width))*8*M_PI/wid));
                            }
                  else if(alt==24){
                        y=int(.2*(x-gmfldxmin)+yo);
                    }
                  else if(alt==26){
                       y=int(yo*(1-0.5*sqrt(1-4*pow(xid,2)/(wid*wid))));
                       }
                  else if(alt==29){
                        y=int(yo-spd/(abs(spd))*30*sin((x-(gmfldxmin+width))*2*M_PI/(wid-46)));
                    }
                  else if(alt==31){
                        y=int(yo-spd/(abs(spd))*30*pow(sin((x-(gmfldxmin+width))*2*M_PI/(wid-46)),3));
                    }
                  else if(alt==33){
                        y=int(yo+19*(1+xcom)*(1+spd/(abs(spd)))-xcom*.3*(1+spd/(abs(spd)))*((x-xmn)%(wid/2-width)-2*int((x-xmn)/(wid/2-width))*(width)));
                        y=(y>(yo+120))?yo:y;
                    }
                 else if(alt==35 || alt==44){
                        y=int(yo-19*(1+xcom)*(1+spd/(abs(spd)))+xcom*.3*(1+spd/(abs(spd)))*((x-xmn)%(wid/2-width)-2*int((x-xmn)/(wid/2-width))*(width)));
                        y=(y<(yo-120))?yo:y;
                    }
                 else if(alt==39){
                            if(y<200)
                                y=int(yo-10*sin((x-xmn)*8*M_PI/wid));
                            else
                                y=350;
                    }
                 else if(alt==40){
                        y=int(yo-.2*(x-xmn));
                    }
                 else if(alt==41){
                        if(y<200)
                            y=int(yo-spd/(abs(spd))*30*sin((x-(gmfldxmin+width))*2*M_PI/(wid-46)));
                        else
                            y=350;
                    }
                 else if(alt==42){
                        y=int(yo-abs(int(30*cos((x-xmn)*2*M_PI/(wid-46)))));
                    }
                 else if(alt==43){
                       if(y<250)
                            y=int(yo*(1-.75*sqrt(1-4*pow(xid,2)/(wid*wid))));
                       else
                            y=350;
                    }
                  putimage(x-24,y,bask,XOR_PUT);
                  }
            void Tbasket::slidedown()
            {
                 putimage(x-24,y,bask,XOR_PUT);
                 y+=yspd;
                 putimage(x-24,y,bask,XOR_PUT);
            }
             int Tbasket::getxauto(int times){
                 int spdt=spd;
                 int xtemp=x;
                 for(int k=1;k<times;k++){
                 if(xtemp>xmx)spdt=-1*abs(spdt);
                 else if(xtemp<xmn)spdt=abs(spdt);
                 xtemp+=spdt;
                 }
                 return(xtemp);
                 }
             int Tbasket::getyauto(int eg_x){
                    int xcom;
                    int xid=(eg_x-gmfldxmin-wid/2);
                    if(xid==0)
                        xcom=0;
                    else
                        xcom=xid/abs(xid);
                 int tspd=abs(spd);
                 tspd=(x>eg_x)?(-tspd):tspd;
                 if(alt==17)
                        return(int(yo-10*sin((eg_x-gmfldxmin)*8*M_PI/wid)));
                 else if(alt==24){
                        return int(.2*(eg_x-gmfldxmin)+yo);
                    }
                 else if(alt==26){
                        return int(yo-200*sqrt(1-4*pow(xid,2)/(wid*wid)));
                    }
                 else if(alt==29){
                        return int(yo-tspd/(abs(tspd))*30*sin((eg_x-(gmfldxmin+width))*2*M_PI/(wid-46)));
                    }
                else if(alt==31){
                        return int(yo-tspd/(abs(tspd))*30*pow(sin((eg_x-(gmfldxmin+width))*2*M_PI/(wid-46)),3));
                    }
                else if(alt==33){
                        int tmpy=int(yo+19*(1+xcom)*(1+tspd/(abs(tspd)))-xcom*.3*(1+tspd/(abs(tspd)))*((eg_x-xmn)%(wid/2-width)-2*int((eg_x-xmn)/(wid/2-width))*(width)));
                        return (tmpy>270)?150:tmpy;
                    }
                else if(alt==35||alt==44){
                        int tmpy=int(yo-19*(1+xcom)*(1+tspd/(abs(tspd)))+xcom*.3*(1+tspd/(abs(tspd)))*((eg_x-xmn)%(wid/2-width)-2*int((eg_x-xmn)/(wid/2-width))*(width)));
                        return (tmpy<130)?yo:tmpy;
                    }
                 else if(alt==39){
                            if(y<200)
                                return int(yo-10*sin((eg_x-xmn)*8*M_PI/wid));
                            else
                                return 350;
                    }
                 else if(alt==40){
                        return int(yo-.2*(eg_x-xmn));
                    }
                 else if(alt==41){
                        if(y<200)
                            return int(yo-spd/(abs(spd))*30*sin((eg_x-(gmfldxmin+width))*2*M_PI/(wid-46)));
                        else
                            return 350;
                    }
                 else if(alt==42){
                        return int(yo-abs(int(30*cos((eg_x-xmn)*2*M_PI/(wid-46)))));
                    }
                 else if(alt==43){
                       if(y<250)
                            return int(yo*(1-.75*sqrt(1-4*pow(xid,2)/(wid*wid))));
                       else
                            return 350;
                    }
                 else
                     return(y);
             }
             int Tbasket::foodx(int tim,int i){
                    if(alt==1||alt==12||alt==4){
                        return x;
                    }
                    else{
                    if(i==0){
                        return (xmn+(tim-3)*abs(spd));
                    }
                    else {
                        return (xmx-(tim-3)*abs(spd));
                    }
                    }
                }


/*void demobasket::next(int ap){
            alt=ap;
        }
void demobasket::move(){
            Tbasket::move();
            putpixel(x,y,COLOR(50,255,10));
        }*/
//Dbasket.....................................................................................................


Dbasket::Dbasket():x(50),y(500),turnplus(0),imgmx(4),width(24){}
Dbasket::Dbasket(int xp,int yp):x(xp),y(yp){}
void Dbasket::draw()
{
                  int xt=150,yt=500,widt=24;
                  int size;
                  int clearance=2;
                  int offset=50;
                  for(int fade=0;fade<4+1;fade++)
                  {                                     //4=imgmx...................
                      xt+=offset;
                                        //gradient colouring.............
                      int r=0,g=0,b=0;
                      int c=0;
                      if(dcolor[0]>dcolor[1]&&dcolor[0]>dcolor[2])
                           r=1;
                      else if(dcolor[2]>dcolor[1]&&dcolor[2]>dcolor[1])
                           b=1;
                      else
                          g=1;
                      for(int k=0;k<25;k++)
                      {
                          int colour =COLOR((fade+1)*(dcolor[0]*(25-k)/(25+20*r)+100*r)/5,(fade+1)*(dcolor[1]*(25-k)/(25+20*g)+100*g)/5,(fade+1)*(dcolor[2]*(25-k)/(25+20*b)+100*b)/5);
                          setcolor(colour);
                          setfillstyle(1,colour);
                          bar(xt+k,yt-widt,xt+(50-k),yt+widt+2*clearance);
                      }
                      setcolor(0);
                      moveto(xt,yt);
                      lineto(xt+50,yt);
                      arc(xt+widt+clearance/2,yt,180,0,widt);
                      setfillstyle(1,COLOR(0,0,0));
                      floodfill(xt+5,yt-clearance,0);
                      floodfill(xt+45,yt-clearance,0);
                      floodfill(xt+45,yt+widt+clearance,0);
                      floodfill(xt+5,yt+widt+clearance,0);
                      size = imagesize(xt,yt-clearance,xt+50,yt+widt+clearance); /*measure size*/
                      Dbask[fade] = malloc(size);                  /*allocate memory space*/
                      getimage(xt,yt-clearance,xt+50,yt+widt+clearance,Dbask[fade]);      /* grab the image */
                 }
}
void Dbasket::setroll(int xp,int rol,int yp){
                  x=xp+roll*50;
                  y=yp;
                  }
void Dbasket::setspace(int spac){
                  space = spac;
                  }
int Dbasket::getspace(){
                  return(space);
                  }
void Dbasket::rest(int xs,int ys){
                  putimage(xs-24,ys,Dbask[imgmx],XOR_PUT);
                  }
void Dbasket::shift(int sp){
                  putimage(x-24,y,Dbask[img],XOR_PUT);
                  x+=sp;
                  putimage(x-24,y,Dbask[img],XOR_PUT);
                  }
void Dbasket::prepare(int fall_x,int tp){
                  tempx=fall_x-imgmx*15;
                  turn = 0;
                  turnplus=tp;
                  img=0;
                  putimage(tempx-24,y,Dbask[img],XOR_PUT);
                  }
void Dbasket::fadeout(){
                    if(img>0){
                  putimage(x-24,y,Dbask[img],XOR_PUT);
                  if(turn>5){
                     if(img>0)
                            img-=turnplus;
                     else
                            img=0;
                            }
                  else
                      turn+=turnplus;
                  x+=10;
                  if(img>0)
                  putimage(x-24,y,Dbask[img],XOR_PUT);
                  }
                  }
void Dbasket::resque(){
                  x=tempx+(img)*15;
                  if(img>imgmx)img=imgmx;
                  putimage(x-24,y,Dbask[img],XOR_PUT);
                  if(img<imgmx){
                  img+=turnplus;
                  turn=0;
                  }
                  else if(turn<1)
                      turn+=turnplus;
                  x=tempx+(img)*15;
                  if(img>imgmx)img=imgmx;
                  putimage(x-24,y,Dbask[img],XOR_PUT);
                  }
int Dbasket::_x(){
                 return(x);
                 }
int Dbasket::_y(){
                 return(y);
                 }






//starting circle......................................................................
startin::startin():x(50),y(450),radmin(10),radmax(40),color(0),t(10),imag(0),trn(0),dr(3),showed(false){}
void startin::draw(){
                  setlinestyle(0,0,4);
                  int j=0;
                  for(int i=radmin;i<radmax+1;i+=dr){
                          color=int(100*sin(M_PI*(i-radmin)/(radmax-radmin)));
                          setcolor(COLOR(color*2,color*2,0));
                          if(i==radmax)
                          {
                            size = imagesize(x-(1),y-(1),x+(1),y+(1));
                            cir[j] = malloc(size);             /*allocate memory space*/
                            getimage(x-(1),y-(1),x+(1),y+(1),cir[j]);/* grab the image */
                            continue;
                          }


                          circle(x,y,i);
                          size = imagesize(x-(i+1),y-(i+1),x+(i+1),y+(i+1));
                          cir[j] = malloc(size);             /*allocate memory space*/
                          getimage(x-(i+1),y-(i+1),x+(i+1),y+(i+1),cir[j]);/* grab the image */
                          j++;
                          x+=2*(i+3);
                          }
            }
void startin::strt(){
                         showed=false;
                         x=-20;
                         y=-20;
                         }
void startin::show(int xp,int yp){
                          if(imag>t)imag=0;
                          putimage(x-(10+imag*dr),y-(10+imag*dr),cir[imag],XOR_PUT);
                          imag++;
                          x=xp;
                          y=yp;
                          if(imag>t)imag=0;
                          putimage(x-(10+imag*dr),y-(10+imag*dr),cir[imag],XOR_PUT);
                          if(imag==t)
                             showed = true;
                          else
                             showed = false;
            }




obstcl::obstcl():x(50),y(midy-90),xmn(gmfldxmin+wid+spkwid/2),xmx(gmfldxmax-wid-spkwid/2),wid(20),hig(10),spkwid(90-30),img(0),imgx(0),limit(3),turn(0),base(0){}
void obstcl::constructor(){
                  x=50;
                  y=midy-90;
                  xmn=gmfldxmin+wid+spkwid/2;
                  xmx=gmfldxmax-wid-spkwid/2;
                  wid=20;
                  hig=10;
                  spkwid=90-30;
                  img=0;
                  imgx=0;
                  limit=3;
                  turn=0;
                  base=0;
                  }
void obstcl::draw(){
                  //setting initaials.........
                  x=50;
                  y=350;
                  xmn=gmfldxmin+wid+spkwid/2;
                  xmx=gmfldxmax-wid-spkwid/2;
                  wid=20;
                  hig=10;
                  spkwid=90-30;
                  img=0;
                  imgx=0;
                  limit=3;
                  turn=0;
                  base=0;
                  int clearance=2;
                  int col;
                  for(int i=wid;i>0;i--){
                          col=int(255*sin(i*M_PI/wid));
                          setfillstyle(1,COLOR(0,col,col));//8,9
                          bar(x,y,x+i,y+hig);
                          }
                  size=imagesize(x-clearance,y-clearance,x+wid+clearance,y+hig+clearance);
                  obs=malloc(size);
                  getimage(x-clearance,y-clearance,x+wid+clearance,y+hig+clearance,obs);
                  x+=150;y-=20;
                  for(int j=25;j>0;j-=1){
                          col=255*(25-j)/25;
                          setcolor(COLOR(col,col,col));
                          setfillstyle(1,COLOR(col,col,col));
                          fillellipse(x,y,j*4/5,j);
                          }
                  setcolor(0);
                  int xr=15,yr=20,pan=15;
                  ellipse(x+xr+clearance,y+yr+clearance,90-pan,180+pan,xr,yr);
                  ellipse(x+xr+clearance,y-yr-clearance,180-pan,270+pan,xr,yr);
                  ellipse(x-xr-clearance,y+yr+clearance,0-pan,90+pan,xr,yr);
                  ellipse(x-xr-clearance,y-yr-clearance,270-pan,360+pan,xr,yr);
                  setfillstyle(1,0);
                  floodfill(x+12,y+12,0);
                  floodfill(x-12,y-12,0);
                  floodfill(x-12,y+12,0);
                  floodfill(x+12,y-12,0);
                  size=imagesize(x-20-clearance,y-25-clearance,x+20+clearance,y+25+clearance);
                  bnch=malloc(size);
                  getimage(x-20-clearance,y-25-clearance,x+20+clearance,y+25+clearance,bnch);
                  x=600;
                  y=300;
                //electric spark.......................
                int color[5];
                int noise=5,n=0;
                color[0]=COLOR(50,90,180);//COLOR(0,255,100);
                color[1]=COLOR(255,255,0);
                color[2]=COLOR(255,0,0);
                color[3]=COLOR(100,255,0);//COLOR(50,90,255);
                color[4]=COLOR(100,200,255);//COLOR(0,0,255);//
                setlinestyle(0,0,1);
                for(int j=0;j<8;j++){
                    setcolor(color[j/4*(j%4+1)]);
                    if(j>3&&j%2==0)
                        setlinestyle(0,0,2);
                    else
                        setlinestyle(0,0,1);
                    moveto(x,y);
                    for(int i=0;i<180;i+=1){
                        n=rand()%(abs(int(noise*sin(i*M_PI/180)))+1);
                        lineto(x+i*spkwid/180,int(y+pow(-1,(rand()%2))*n));
                    }
                    pic[j]=malloc(imagesize(x,y-noise,x+spkwid,y+noise));
                    getimage(x,y-noise,x+spkwid,y+noise,pic[j]);
                    y+=30;
                    }
                          x=midx;
                          showin=false;
                          }
void obstcl::set(int ys,int speed,bool sho){
                  xmn=(gmfldxmin+wid+spkwid/2);
                  xmx=(gmfldxmax-wid-spkwid/2);
                  y=ys;
                  spd=speed;
                  spds[0]=speed;
                  spds[1]=speed;
                  spds[2]=speed;
                  if(x<xmn)x=xmn;
                  else if(x>xmx)x=xmx;
                  showin=sho;
                  if(showin){
                  putimage(x-wid-spkwid/2,y-hig/2,obs,XOR_PUT);
                  putimage(x-spkwid/2,y-hig/2,pic[img],XOR_PUT);
                  putimage(x+spkwid/2,y-hig/2,obs,XOR_PUT);
                  }
}
void obstcl::remove(){
                  putimage(x-wid-spkwid/2,y-hig/2,obs,XOR_PUT);
                  putimage(x-spkwid/2,y-hig/2,pic[img],XOR_PUT);
                  putimage(x+spkwid/2,y-hig/2,obs,XOR_PUT);
                  showin=false;
}
void obstcl::show(int xs,int ys){
                  imgx=1;
}
void obstcl::settime(int a){
                  time=a;
}
void obstcl::sety(int b){
                  yini=b;
}
int obstcl::_y(){
                  return(y+hig/2);
}
int obstcl::_x(){
                 return (x+wid/2);
}
int obstcl::_wid(){
                  return(spkwid);
}
int obstcl::_hig(){
                  return(hig);
}
void obstcl::move(){
                  putimage(x-wid-spkwid/2,y-hig/2,obs,XOR_PUT);
                  putimage(x-spkwid/2,y-hig/2,pic[base+img],XOR_PUT);
                  putimage(x+spkwid/2,y-hig/2,obs,XOR_PUT);
                  if(x>xmx){
                        spd=-abs(spds[(++s)%3]);
                        x=xmx;
                    }
                  if(x<xmn){
                        spd= abs(spds[(++s)%3]);
                        x=xmn;
                    }
                  x+=spd;
                  putimage(x-wid-spkwid/2,y-hig/2,obs,XOR_PUT);
                  if(imgx>0){
                    base=4;
                    if(turn>8){
                        turn=0;
                        imgx=0;
                    }
                    else
                        turn++;
                    }
                  else
                    base=0;
                  img=(img+1)%limit;
                  putimage(x-spkwid/2,y-hig/2,pic[base+img],XOR_PUT);
                  putimage(x+spkwid/2,y-hig/2,obs,XOR_PUT);
}
int obstcl::getxauto(int times){
                  int ts=s;
                  int tspd=spd;
                  int tx=x;
                  for(int i=0;i<times;i++){
                  if(tx>xmx)tspd=-abs(spds[(++ts)%3]);
                  if(tx<xmn)tspd= abs(spds[(++ts)%3]);
                  tx+=tspd;
                  }
                  return(tx);
}








timer::timer(){
    x=midx;
    y=midy;
    imgx=10;
    wid=50;
    }
void timer::draw(){
    x=100;
    y=300;
    wid=50;
    imgx=10;
    setcolor(COLOR(50,255,0));
    setfillstyle(1,COLOR(50,255,0));
    bar(x,y,x+wid,y+5);
    for(int i=0;i<imgx;i++){
        size=imagesize(x,y,x+wid-i*(wid/imgx),y+5);
        timebar[i]=malloc(size);
        getimage(x,y,x+wid-i*(wid/imgx),y+5,timebar[i]);
        }
    }
void timer::initialize(int xs,int ys){
    strtime=300;
    y=ys;
    x=xs;
    //y=200;
    img=0;
    show=true;
    putimage(xs-wid/2,ys+26,timebar[img],XOR_PUT);
    }
void timer::move(int xs,int ys){
    if(show){
    if(img<10 && strtime>0);
        putimage(x-wid/2,y+26,timebar[img],XOR_PUT);
    x=xs;
    y=ys;
    img=(strtime>0)?int(9-round((strtime*9)/300)):0;
    if(strtime>0)
        putimage(x-wid/2,y+26,timebar[img],XOR_PUT);
    else{
        down=true;
        show=false;
        }
        }
    }
void timer::del(int xs,int yx){
    putimage(x-wid/2,y+26,timebar[img],XOR_PUT);
    }
void timer::del(){
    del(x,y);
    }
int timer::_x(){
    return x;
    }
int timer::_y(){
    return y;
    }


void *Tbasket::bask;
int Tbasket::baskcolor[3]={255,0,0};
int Dbasket::dcolor[3]={0,100,150};
void *Dbasket::Dbask[10];
void *food::fud[4];
void *food::blast[10];
void *obstcl::obs;
void *obstcl::bnch;
void *obstcl::pic[8];
void *timer::timebar[10];


foodstatus fdstat;
//here goes the functions......................................................




void Initialize(void)
{
  //initialize graphics............
  //int xasp, yasp;                       /* Used to read the aspect ratio*/
  initwindow(800,600,"",getmaxwidth()/2-400,getmaxheight()/2-295,false,false);  /*intilize the window as widwer screen*/
  MaxColors = getmaxcolor() + 1;        /* Read maximum number of colors*/
  MaxX = getmaxx(); /* Read size of screen          */
  MaxY = getmaxy();
  midx = MaxX/2;
  midy = MaxY/2;
  gmfldxmax=630;
  gmfldxmin=230;
  for(int i=0;i<5;i++){
     basket[i].constructor();
     if(i<2)
        obs[i].constructor();
    }
  ato = false;
  down = false;
  up = false;
  fire = false;
  srand(time(NULL));
  setcolor(15);
      fstream file;
    try
    {
        file.open("scoreboard.txt",ios::in);
        if(!file)
            throw int();
        file.close();
    }
    catch(int)
    {
        //cout<<"File doesnot exist";
        file.clear();
        file.open("scoreboard.txt",ios::out|ios::binary);
        if(file)
        {
            for(int i=0;i<10;i++)
                playr[i].updaterank(i+1);
            file.write((char*)playr,sizeof(playr));
        }
        file.close();
    }
}
void MainWindow( char *header )
{
  metalbar m1;
  cleardevice();                        /* Clear graphics screen        */
  setcolor( MaxColors - 1 );            /* Set current color to white   */
  setviewport( 0, 0, MaxX, MaxY, 1 );   /* Open port to full screen     */
  settextstyle( DEFAULT_FONT, HORIZ_DIR, 0 );
  settextjustify( LEFT_TEXT, TOP_TEXT );
  m1.drawbar(0,0,MaxX);
  m1.embedboxntext(MaxX/2-textwidth(header)/2,textwidth(header)+8,headercolor,header);
}
void StatusLine( char *msg )
{
    int height;
    setviewport( 0, 0, MaxX, MaxY, 1 );   /* Open port to full screen     */
    setcolor( MaxColors - 1 );            /* Set current color to white   */
    setbkcolor(0);
    settextstyle( 3, HORIZ_DIR, 1 );
    settextjustify( CENTER_TEXT, TOP_TEXT );
    setlinestyle( SOLID_LINE, 0, NORM_WIDTH );
    setfillstyle( EMPTY_FILL, 0 );


    height = textheight( "H" );           /* Detemine current height      */
    outtextxy( midx, MaxY-(height+2), msg );
}
void DrawBorder(void)
{
  setcolor(15);            /* Set current color to white   */
  setlinestyle( SOLID_LINE, 0, NORM_WIDTH );
  settextstyle( 3, HORIZ_DIR, 1);
  setviewport(1, 36+2, MaxX-2, MaxY-textheight("h")-2, 1 );
}
void soundplay(int inpt){
     if(inpt<500||inpt>5000)
        inpt=2000;
        Beep(inpt,50);
     for(int fre=inpt-100;fre<inpt;fre+=50){
        Beep(fre,50);
        delay(1);
        }
        }


void fillgradient(int px=40,int py=200){
     for(int jk=0;jk<100;jk++){
        if(px>140){px=40;py++;}
        putpixel(px++,py,COLOR((px-40)*225/100,(px-40)*225/100,(px-40)*225/100));
      }
     }


bool collision(egg &eg,Tbasket &bask)
{
    int dy=5;
    if(bask._alt()==17||bask._alt()==24||bask._alt()==26){
        dy=int(eg._u()*3);
        }
    else
        dy=int(eg._u()*3);
    dy+=bask._alt()%2*3;
    if(abs(eg._x()-bask._x())<20 && abs(eg._y()-bask._y())<dy)
    {
        return true;
    }
    else
        return false;
}
bool collision(egg e,Dbasket c){
     if((c._y()-e._y())<e._u()*3){
           return true;
        }
     else
         return false;
     }
bool collision(egg &e,obstcl &ob){
     if(abs(e._x()-ob._x())<ob._wid()/2 && abs(e._y()-ob._y())<ob._hig()/2){
        return true;
        }
    else
        return false;
        }
bool isKeyDown(int akey)
{
    int keyt=GetAsyncKeyState(akey);
    if(keyt==-32767 || keyt==-32768 || keyt==1)
        return true;
    else
        return false;
}


void gameplay(){
   clearviewport();
   level=nowplayer._level();


   bool enterlist=false;
   int climb=0,col=0;
   int gap=150;
   jump = false;
   jmp=false;
   jumpok=false;
   mark=true;
   pause=false;
   sound=true;
   canstop=false;
   dobs=false;
   activeAI=false;
   hyperj=false;
   circl.showed=false;
   egg1.stop=true;
   int sndcur=0;
   bool saved=false,thro=false,ready=false,gameover=false,first=true,next=false,crossed1=false;
   int x,y,spd,tempx,current=0,miss=0;
   int pausex=gmfldxmax+50,pausey=200;
   int tm,dist,xspd;
   x=gmfldxmin;
   y=350;
   int stp;
   int score=nowplayer._score();
   int playernum=0;
    fstream file;
    try
    {
        file.open("scoreboard.txt",ios::in);
        if(!file)
            throw int();
        else
        {
            file.read((char*)playr,sizeof(playr));
            for(int i=0;i<10;i++)
                playr[i].show();
        }
        file.close();
    }
    catch(int)
    {
        file.clear();
        file.open("scoreboard.txt",ios::out|ios::binary);
        if(file)
        {
            for(int i=0;i<10;i++)
                playr[i].updaterank(i+1);
            file.write((char*)playr,sizeof(playr));
        }
        file.close();
    }
    file.open("gamedata.txt",ios::out|ios::app);
    if(file)
    {
        file.close();
        file.open("gamedata.txt",ios::out|ios::in|ios::binary);
        file.seekg(0,ios::end);
        int endpos=file.tellg();
        playernum=endpos/sizeof(nowplayer);
        file.close();
    }
   clearmouseclick(WM_LBUTTONDOWN);


   //===temporary--------------------------------------------
   void *msgbox;
   setcolor(0);
   setbkcolor(15);
   setfillstyle(SOLID_FILL,15);
   settextstyle(0,HORIZ_DIR,0);
   settextjustify(LEFT_TEXT,TOP_TEXT);
   bar(100,100,400,180);
   outtextxy(110,135,"Do you want to SAVE ? (y/n)");
   int size=imagesize(100,100,400,180);
   msgbox=malloc(size);
   getimage(100,100,400,180,msgbox);
   setbkcolor(0);
   //==========================================================
   clearviewport();


   setactivepage(0);
   setvisualpage(0);
   clearviewport();
   //MainWindow("The Egg-Pass");
   //StatusLine( "Egg Pass Game" );
   //DrawBorder();
   /*checking altitudes...................................*/


   metalbar mbar1,mbar2,mbar3;                              //for game screen
   mbar3.drawbar(2,10,200);
   mbar1.drawbar(2,10+36+10,200);
   mbar2.drawbar(2,10+2*(36+10),200);


   settextstyle(3,HORIZ_DIR,1);
   settextjustify(LEFT_TEXT,TOP_TEXT);
   mbar1.embedboxntext(10,textwidth("Player")+10,11,"Player");
   mbar2.embedboxntext(10,textwidth("player")+10,11,"Score");
   mbar3.embedboxntext(10,textwidth("player")+10,11,"Level");


   mbar1.embedboxntext(10+textwidth("player")+10+10,120,11,nowplayer._name());//250+10
   mbar2.embedboxntext(10+textwidth("player")+10+10,120,11,"0");
   mbar2.changescore(10+textwidth("player")+10+10,11,nowplayer._score());




   mbar3.embedboxntext(10+textwidth("player")+10+10,120,11,"1");
   mbar3.changescore(10+textwidth("player")+10+10,11,nowplayer._level());
   showmenulink(655,230);
   int l,t,r,b,h;
    l=645;
    t=10;
    r=645+140;
    b=10+100;
    h=textheight("h")+6;
    showmsg(l-4,t-4,(r-l)+8,(b-t)+8,lightblue);
    setfillstyle(1,COLOR(100,100,100));
    bar(l,t,r,b);


    border3d(l+5,t+3,r-5,t+3+h,BLACK,bcolor);
    setfillstyle(1,15);
    bar(l+7,t+5,r-6,t+2+h);


    setcolor(0);
    setbkcolor(15);
    outtextxy(l+10,t+3+3,"Top Score :");
    bgiout<<playr[0]._score();
    outstreamxy(l+10+textwidth("top score : ")+5,t+3+3);


    //border3d(l+5,t+3+h+5,r-5,t+3+5+2*h,BLACK,bcolor);
    //setfillstyle(1,COLOR(250,250,200));
    //bar(l+7,t+3+h+7,r-6,t+3+4+2*h);




    setcolor(COLOR(100,255,0));
    setbkcolor(COLOR(100,100,100));
    outtextxy(l+10,t+3+h+5+3,"Scored by :");


    border3d(l+5,t+3+2*h+2*5,r-5,t+3+2*5+3*h,BLACK,bcolor);
    setfillstyle(1,COLOR(250,250,200));
    bar(l+7,t+3+2*h+2*5+2,r-6,t+3+2*4+3*h);
    setcolor(0);
    setbkcolor(COLOR(250,250,200));
    outtextxy(645+10,t+3+2*5+3+2*h,playr[0]._name());


   setbkcolor(0);


   clearmouseclick(WM_LBUTTONDOWN);
   /*checking altitudes...................................*/
   setcolor(15);
   rectangle(gmfldxmin,5,gmfldxmax,535);


   //setting initials baskets..............
   for(int count=0;count<4;count++){
       basket[count].setap(count+1+(level-1)*9);
       basket[count].loadesp();
       basket[count].set(count+1+(level-1)*9,0,y-count*gap,0);
       if(count>1)
       basket[count].sety(y-count*gap);
   }
   obs[0].set(230,4,false);
   obs[1].set(80,4,false);
   for(int i=0;i<2;i++){
                    if(basket[i+1]._alt()==15||basket[i+1]._alt()==21||basket[i+1]._alt()==26||basket[i+1]._alt()==35||basket[i+1]._alt()==39||basket[i+1]._alt()==42){//if(2+climb*2+(level-1)*9==15||21||){
                        obs[i].set(230-i*150,3,true);
                        obs[i].showin=true;
                        }
                    }


                    tcount.initialize(1000,1000);
   for(int pix=0;pix<200;pix++)
       putpixel(rand()%(gmfldxmax-gmfldxmin)+gmfldxmin,rand()%545+10,rand()%8+7);
   bird(75,470);
   dbas.rest(106,500);
   settextstyle(1,0,1);
   setcolor(COLOR(255,50,50));
   outtextxy(80,480,"Chances left");
   settextstyle(1,0,2);
   outtextxy(140,500,"X");
   bgiout<<missmax-miss;
   outstreamxy(180,dbas._y());


   registermousehandler(WM_LBUTTONDOWN,click_handler);


   int obssnd=0,blink=0;
   int colorchk1,colorchk2;
   int currentcol=COLOR(200,255,10);
   int statbkcol=COLOR(20,90,50);//getpixel(fdstat.statx(1)-2,fdstat.staty(1)-2);
   int blnkcol=statbkcol+currentcol;
       currentcol=statbkcol;
   int clok=0,sprk[2]={0,1};


   //tcount.initialize(gmfldxmin,200);
   fdstat.initialize();
   fdstat.refresh();
   canstop=true;
   dobs=false;
   dhila=int(5*Tfactor);
   do{
   if(kbhit()){
      setcolor(0);
      outtextxy(pausex,pausey,"Paused!");
      int c=getch();
      if(c==27)
         pause=!pause;
      else if(c==32)
         dhila+=2;
      else if(c==9&&dhila>3)
         dhila-=2;
      else if(c==96)
      {
            dhila=int(5*Tfactor);
      }
      while(kbhit())getch();
    }
   if(!pause){


   //safety...........
   if(egg1._y()>MaxY){
      jump=false;
      jmp=false;
      egg1.move(basket[current]._x(),basket[current]._y());
      saved=false;
      thro=false;
      egg1.stop=true;
      ready=false;
      }
      if(isKeyDown(VK_SHIFT))
            canstop=true;
      else
            canstop=false;
       //basket move ...........................
        for(int step=0;step<3;step++){
            if(current==step&&!jump && !saved){
                if(canstop && fdstat.getstat(2)>0){
                    fdstat.dec(2);
                    continue;
                    }
            }
            if(basket[step]._spd()==0)
                    continue;
            basket[step].move();
        }


        if(basket[2]._alt()==45){
               if(sprk[1]>2){
                    //finis.flow(gmfldxmax,basket[2]._y());
                   sprk[1]=0;
                    }
                else
                    sprk[1]++;
                }
        if(basket[current]._alt()==15||basket[current]._alt()==22||basket[current]._alt()==35||basket[current]._alt()==38||basket[current]._alt()==42){
                if(jump&&tcount.show){
                    tcount.del();
                    tcount.show=false;
                }
                else{
                     tcount.move(basket[current]._x(),basket[current]._y());
                     tcount.strtime--;
                    }
        }
        if(!jump && !saved && !thro && fdstat.getstat(3)>0 && hyperj){//&& isKeyDown('B')
                    colorchk1=getpixel(fdstat.statx(0)-3,fdstat.staty(0)-7);
                    colorchk2=getpixel(fdstat.statx(3)-3,fdstat.staty(3)-3);
                    if(colorchk1==colorchk2){
                        egg1.hyperjump();
                        fdstat.dec(3);
                        }
                    else{
                        egg1.normal();
                    }
                    setlinestyle(0,0,2);
                    setcolor(blnkcol-colorchk2);
                    rectangle(fdstat.statx(3)-3,fdstat.staty(3)-3,fdstat.statx(3)-2+36,fdstat.staty(3)-2+36);
                    hyperj=false;
                }
        //first (only once)..........
        if(first){
                 current=0;
                 egg1.move();
                 egg1.move(basket[0]._x()-basket[0]._spd(),basket[0]._y());
                 saved=false;
                 egg1.stop=true;
                 for(stp=0;stp<3;stp++){
                 basket[stp].show(basket[stp]._x()-basket[stp]._spd(),basket[stp]._y(),false);//getch();
                    }
                 do{
                     basket[current].move();
                     egg1.move(basket[current]._x(),basket[current]._y());
                     delay(dhila*4);
                     }while(basket[current]._x()<basket[current]._xmx()&& level!=1);//getch();
                 for(stp=0;stp<2;stp++){
                    obs[stp].settime(egg1.gettimes(basket[stp]._y(),obs[stp]._y(),true)*5);
                    obs[stp].sety(basket[stp]._y());
                    fod[stp].initim=stp*5000+clock();
                    }
                first=false;


        }


//food status showing.................
    if(ato){
        int i=2;
        if(dobs && up){
            i=1;
        }
        else if(!dobs && up){
            i=0;
        }
        else
            i=2;
        if(blink>5&&i<2){
           currentcol=blnkcol-currentcol;
           setlinestyle(0,0,3);
           setcolor(currentcol);
           rectangle(fdstat.statx(i)-3,fdstat.staty(i)-3,fdstat.statx(i)-2+36,fdstat.staty(i)-2+36);
           setcolor(statbkcol);
           rectangle(fdstat.statx(1-i)-3,fdstat.staty(1-i)-3,fdstat.statx(1-i)-2+36,fdstat.staty(1-i)-2+36);
           blink=0;
           }
        else {
                blink++;
            }
        }
    else{
        setlinestyle(0,0,3);
        setcolor(statbkcol);
        rectangle(fdstat.statx(0)-3,fdstat.staty(0)-3,fdstat.statx(0)-2+36,fdstat.staty(0)-2+36);
        rectangle(fdstat.statx(1)-3,fdstat.staty(1)-3,fdstat.statx(1)-2+36,fdstat.staty(1)-2+36);
        }


//Artificial intelligence..........................
 if(ato && !saved && !mark){
        if(up){
           //down=false;
           if(dobs){
           int k=current+1;
           for(int i=current;i<k;i++){
               if(obs[i].showin){
                  if(abs(egg1._x()-obs[i].getxauto(egg1.gettimes(basket[i]._y(),obs[i]._y(),false)))<(obs[i]._wid()/2+7)){
                    jumpok=false;
                    break;
                    }
                  else
                    jumpok=true;
                    }
                else
                    jumpok=true;
              }
           }
           else{
               jumpok=true;
               }
            if(!jump && jumpok && (basket[current+1].getyauto(basket[current]._x())-egg1.getmaxy())>2 && abs(basket[current+1].getxauto(egg1.gettimes(egg1._y(),basket[current+1].getyauto(basket[current]._x()),true))-egg1._x())<5){
                      jump=true;
                      jmp=true;
                      if(dobs)
                        fdstat.dec(1);
                      else
                        fdstat.dec(0);
                      dobs=false;
                      up=false;
                      ato=false;
                      setlinestyle(0,0,3);
                      setcolor(statbkcol);
                      rectangle(fdstat.statx(0)-3,fdstat.staty(0)-3,fdstat.statx(0)-2+36,fdstat.staty(0)-2+36);
                      rectangle(fdstat.statx(1)-3,fdstat.staty(1)-3,fdstat.statx(1)-2+36,fdstat.staty(1)-2+36);
                    }
                }
           }
  if(down){
           if(!jump&&abs(basket[0].getxauto(egg1.gettimes(basket[0]._y()))-egg1._x())<5){
           //more acccurate......but...basket[current-1].getxauto(egg1.gettimes(egg1._y(),basket[current-1].getyauto(basket[current]._x()),true))-egg1._x())<5)){
                     jump=true;
                     jmp=true;
                     tcount.show=false;
                     //ato=false;
                     down=false;
                      }
        }
//player's jump................
  if(jump){
     if(jmp){
           egg1.jumpfirst();
           jmp=false;
           }
           egg1.jump();
           }
  else if(!saved && egg1.stop){
       if(mark && !circl.showed){
              circl.show(basket[current]._x(),basket[current]._y());
              }
       else
           mark=false;
       egg1.move(basket[current]._x(),basket[current]._y());
       }
   //food and obstacles..............
   for(int i=0;i<2;i++){
     //obstacles.....................
     if(i==sprk[0]){
        if(obs[i].showin)
            obs[i].move();
        sprk[0]=1-sprk[0];
    }
     //foods.........................
     if(fod[i].showin){
           if(fod[i].eaten){
           if(!fod[i].erased){
                 fod[i].del();
                 }
              fod[i].blst();
           if(fod[i].blstnum==7){
              fod[i].initim=clock();
              fdstat.inc(fod[i].foodnum());
              if(fod[i].foodnum()==2)
                 canstop=true;
                }
              }
           else{
              fod[i].timeout++;
              if(fod[i].timeout>200&&fod[i].timeout<210)
                 fod[i].del();
              else if(fod[i].timeout>210){
                 fod[i].clear();
                 fod[i].initim=clock();
                }
              else
                 fod[i].eaten=egg1.eat(fod[i]);
              }
           }
      else if(!jump && clock()-fod[i].initim>30*1000 && basket[i]._alt()!=16 && basket[i]._alt()!=23 && basket[i]._alt()!=25 && basket[i]._alt()!=28 && basket[i]._alt()!=30 && basket[i]._alt()!=32 && basket[i]._alt()!=33 && basket[i]._alt()!=34 && basket[i]._alt()<38){
            if(i>=current){
            fod[i].clear();
            int ran=random(8);
            ran=(ran<4)?ran:2;
            fod[i].setfood(ran,basket[i].foodx(int(egg1.gettimes(350,350,true)/2),random(2)),280-i*150);
            fod[i].initim=i*15000+clock();
            }
        }
      else{
            }
     }
   //superjump........
   if(saved){
       if(collision(egg1,dbas)&&!ready){
          egg1.normal();
          setlinestyle(0,0,3);
          setcolor(statbkcol);
          rectangle(fdstat.statx(3)-3,fdstat.staty(3)-3,fdstat.statx(3)-2+36,fdstat.staty(3)-2+36);
          egg1.move(dbas._x(),dbas._y());
          if(egg1.stop)
          ready=true;delay(dhila);
          egg1.stop=true;
          jump=false;
          current=0;
          tm=egg1.gettimes(dbas._y(),basket[0]._y());
          dist=(basket[0].getxauto(tm)-dbas._x());
          dbas.setspace(dist/tm);
          xspd=dbas.getspace();


            settextstyle(1,0,2);
            setcolor(COLOR(255,100,50));
            bgiout<<"    ";
            outstreamxy(180,dbas._y());
            setcolor(15);
            bgiout<<missmax-miss;
            outstreamxy(180,dbas._y());
            bgiout<<missmax-miss;
            outstreamxy(180,dbas._y());
          }
       else if(ready){
            mark=true;
            circl.strt();
            if(thro){
                egg1.superjump(dbas._x(),dbas._y(),xspd);
                dbas.fadeout();
                settextstyle(1,0,2);
                setcolor(COLOR(255,100,50));
                bgiout<<"    ";
                outstreamxy(180,dbas._y());
                bgiout<<missmax-miss;
                outstreamxy(180,dbas._y());
                }
            else{
                egg1.move(dbas._x(),dbas._y());
                if(abs(xspd*tm-dist)<10){
                  thro=true;
                  egg1.jumpfirst();
                }
                else if(basket[0]._alt()==1||basket[0]._alt()==12){
                    dbas.shift(1);
                    dist=(basket[0].getxauto(tm)-dbas._x());
                    dbas.setspace(dist/tm);
                    xspd=dbas.getspace();
                }
                else{
                  dist=(basket[0].getxauto(tm)-dbas._x());
                  dbas.setspace(dist/tm);
                  xspd=dbas.getspace();
                    }
                 }
                }
   else{
       if(miss<=missmax)
            dbas.resque();
       else{
          if((egg1._y()-basket[0]._y())>100){
                gameover=true;
                delay(500);
                }
            }
        }
    }
      if(current==2){
            //erase obstacles...............................
            for(int i=0;i<2;i++){
                    if(obs[i].showin){
                        obs[i].remove();
                    }
                    }
            if(climb<3){
               climb++;
               int corr;
               while(abs(basket[2]._y()-50)>3 || abs(basket[1]._y()-200)>3){
                        if(abs(basket[2]._y()-50)>3)
                            basket[2].move();
                        if(abs(basket[1]._y()-200)>3)
                            basket[1].move();
                        egg1.move(basket[2]._x(),basket[2]._y());
                        delay(dhila*3);
                    }
                corr=basket[2]._y()-50;
               do
               {
                   for(int j=0;j<4;j++)
                   {
                            basket[j].slidedown();
                       if(j<2 && fod[j].showin)
                            fod[j].slidedown();
                       }
                   egg1.move(basket[current]._x(),basket[current]._y());
                   if(basket[3]._y()>(y-2*gap-5)&& !crossed1)
                   {
                       basket[0].show(basket[0]._x(),basket[0]._y());
                       basket[0].set(climb*2+3+(level-1)*9,0,y-3*gap,4);
                       basket[0].sety(y-3*gap);
                       basket[0].loadesp();
                       crossed1=true;
                       }
                   if(basket[3]._y()>=(y-1*gap-5))
                   {
                       basket[1].show(basket[1]._x(),basket[1]._y());
                       basket[1].set(climb*2+4+(level-1)*9,0,y-3*gap,4);
                       basket[1].sety(y-3*gap);
                       basket[1].loadesp();
                       }
                   }while(basket[2]._y()<350+corr);
               if(fod[1].showin)
                            fod[1].del();
               basket[4]=basket[3];
               basket[3]=basket[1];
               basket[1]=basket[4];
               basket[4]=basket[0];
               basket[0]=basket[2];
               basket[2]=basket[4];
               crossed1=false;
               current=0;
               for(int coun=1;coun<4;coun++){
                   basket[coun].setap(coun+climb*2+1+(level-1)*9);
                   basket[coun].sety(y-coun*gap);
                   basket[coun].loadesp();
                   }
               for(int i=0;i<2;i++){
                    if(basket[i+1]._alt()==15||basket[i+1]._alt()==21||basket[i+1]._alt()==26||basket[i+1]._alt()==35||basket[i+1]._alt()==39||basket[i+1]._alt()==42){//if(2+climb*2+(level-1)*9==15||21||){
                        obs[i].set(230-i*150,3,true);
                        obs[i].showin=true;
                        }
                    fod[i].sety(basket[i]._y());
                    fod[i].clear();
                    }
                /*if(basket[2]._alt()==45){
                    finis.initialise(gmfldxmax,basket[2]._y());
                }*/
                }


         else{
                  basket[current].setspd(abs(basket[current]._spd()));
                  do{
                     basket[current].move();
                     egg1.move(basket[current]._x(),basket[current]._y());
                     delay(dhila*2);
                     }while(basket[current]._x()<basket[current]._xmx());


                    if(level<5)
                    {
                    int l,t,r,b;
                    l=gmfldxmin+10;
                    t=150;
                    r=gmfldxmax-10;
                    b=300;
                    int bwid=60;// actually 80.  60+20
                    int size=imagesize(l,t,r,b);
                    void *msgbx=malloc(size);
                    getimage(l,t,r,b,msgbx);
                    int gc=getcolor();
                    int bg=getbkcolor();
                    int bgcol=COLOR(0,65,255);
                    showmsg(l,t,r-l,b-t,bgcol);
                    boundbtn msgbtn[2];         //class boundbtn
                    setcolor(15);
                    setbkcolor(bgcol);
                    settextjustify(LEFT_TEXT,TOP_TEXT);
                    settextstyle(3,0,1);
                    msgbtn[0].set(l+80,b-60,bwid,textheight("M"));
                    msgbtn[0].outtext("Yes",15);
                    setlinestyle(0,0,1);
                    msgbtn[1].set(r-bwid-80,b-60,bwid,textheight("M"));
                    msgbtn[1].outtext("No",15);
                    settextjustify(CENTER_TEXT,TOP_TEXT);
                    //settextstyle(GOTHIC_FONT,0,2);
                    outtextxy(l+(r-l)/2,t+15,"Level      Complete");
                    bgiout<<level;
                    outstreamxy(l+(r-l)/2-textwidth("Level      Complete")/2+textwidth("level")+20,t+15);
                    outtextxy(l+(r-l)/2,t+textheight("h")+30,"Do you want to save?");
                    registermousehandler(WM_LBUTTONDOWN,0);
                    bool yesclick=false,noclick=false;
                    do
                    {
                        for(int i=0;i<2;i++)
                        {
                            if(msgbtn[i].ismouseover())
                            {
                                if(msgbtn[i].rollover)
                                {
                                    msgbtn[i].drawborder(tcolor,COLOR(20,20,20));
                                    msgbtn[i].rollover=false;
                                }
                                 else if(ismouseclick(WM_LBUTTONDOWN))
                                {
                                    msgbtn[i].drawborder(COLOR(20,20,20),tcolor);
                                    msgbtn[i].click=false;
                                    clearmouseclick(WM_LBUTTONDOWN);
                                    if(i==0)
                                        yesclick=true;
                                    else
                                        noclick=true;
                                }
                            }
                            if(msgbtn[i].rollout)
                            {
                                msgbtn[i].drawborder(bgcol,bgcol);
                                msgbtn[i].rollout=false;
                            }
                        }
                        clearmouseclick(WM_LBUTTONDOWN);
                        delay(100);
                    }while(!yesclick && !noclick);


                    setcolor(gc);
                    setbkcolor(bg);
                    settextjustify(LEFT_TEXT,TOP_TEXT);


                    registermousehandler(WM_LBUTTONDOWN,click_handler);
                    if(yesclick)
                        {
                            nowplayer.updatescore(score);
                            nowplayer.updatelevel(level+1);
                            file.open("gamedata.txt",ios::out|ios::in|ios::binary|ios::ate);
                            //file.seekp(playernum*sizeof(nowplayer),ios::beg);
                            //file.write((char*)&nowplayer,sizeof(nowplayer));
                            if(playernum>9)
                            {
                                player tmp;
                                for(int i=0;i<9;i++)
                                {
                                    file.seekp((i+1)*sizeof(nowplayer),ios::beg);
                                    file.read((char*)&tmp,sizeof(tmp));
                                    file.seekp(i*sizeof(nowplayer),ios::beg);
                                    file.write((char*)&tmp,sizeof(tmp));
                                    tmp.show();
                                }
                                playernum=9;
                            }
                            file.seekp(playernum*sizeof(nowplayer),ios::beg);
                            file.write((char*)&nowplayer,sizeof(nowplayer));
                            file.seekg(0,ios::end);
                            int endpos=file.tellg();
                            playernum=endpos/sizeof(nowplayer);
                            file.close();
                            file.open("scoreboard.txt",ios::out|ios::binary);
                            file.write((char*)playr,sizeof(playr));
                            file.close();
                        }
                    putimage(l,t,msgbx,0);


                  //reset 1 & 2.............
                  for(int i=1;i<4;i++){
                      basket[i].show(basket[i]._x(),basket[i]._y());
                      basket[i].set(i+1+level*9,0,y-i*gap,0);
                      basket[i].sety(y-i*gap);
                      basket[i].loadesp();
                      basket[i].show(basket[i]._x(),basket[i]._y());
                      }
                  basket[0].show(basket[0]._x(),basket[0]._y());
                  basket[0].set(1+level*9,gmfldxmin,y,3);
                  basket[0].loadesp();
                  basket[0].show(basket[0]._x(),basket[0]._y());
                  current=0;
                  for(int j=0;basket[0]._x()<basket[0]._xmx();j++){
                      basket[current].move();
                      egg1.move(basket[current]._x(),basket[current]._y());
                      delay(dhila*1);
                      }
                  for(int coun=1;coun<4;coun++){
                   basket[coun].setap(coun+1+level*9);
                   basket[coun].sety(y-coun*gap);
                   basket[coun].loadesp();
                   }
                   level++;
                  climb=0;
                  mbar3.changescore(10+textwidth("player")+10+10,11,level);
                }
                else
                {
                    break;
                }
            }


         }
//sound........................
  if(sound){
            if(jump||thro)
            {
                    if(sndcur<3){
                                 Beep(jmpsnd[sndcur][0],jmpsnd[sndcur][1]);
                                 sndcur++;
                                 }
            }
            else if(mark&&egg1.stop&&egg1._y()==basket[current]._y()){
                          if(sndcur<2){
                                 Beep(stpt[sndcur][0],stpt[sndcur][1]);
                                 sndcur++;
                          }
                          else if(sndcur>2){
                               sndcur=0;
                            }
            }
            if(obssnd>0){
                    Beep(obstclsnd[random(5)],20);
                    obssnd--;
                }
            }
//testing the collision.................
        if(jump||thro){
           if(egg1.fall){
           for(int test=0;test<3;test++){
            if(collision(egg1,basket[test])){
                egg1.stop=true;
                egg1.normal();
                setlinestyle(0,0,3);
                setcolor(getpixel(fdstat.statx(0)-3,fdstat.staty(0)-5));
                rectangle(fdstat.statx(3)-3,fdstat.staty(3)-3,fdstat.statx(3)-2+36,fdstat.staty(3)-2+36);
                if((test-current)>0)
                    score+=10;
                nowplayer.updatescore(score);


                setcolor(15);
                settextstyle(3,HORIZ_DIR,1);
                settextjustify(LEFT_TEXT,TOP_TEXT);
                mbar2.changescore(10+textwidth("player")+10+10,11,nowplayer._score());
                if(!enterlist && nowplayer._score()>playr[9]._score())
                        {
                            enterlist=true;
                            nowplayer.updaterank(10);
                            playr[9]=nowplayer;
                        }
                    if(enterlist)
                        {
                            if(nowplayer._rank()>1)
                            {
                                for(int rank=nowplayer._rank()-1;rank>=1;rank--)
                                {
                                    if(nowplayer._score()>playr[rank-1]._score())
                                        {
                                            player tmp=playr[rank-1];
                                            playr[rank-1]=nowplayer;
                                                playr[rank]=tmp;
                                            nowplayer.updaterank(rank);
                                            playr[rank-1].updaterank(rank);
                                                playr[rank].updaterank(rank+1);
                                        }
                                        else
                                        {
                                            playr[nowplayer._rank()-1].updatescore(nowplayer._score());
                                        }
                                    }
                            }
                            else
                            {
                                playr[0].updatescore(nowplayer._score());
                            }
                            file.open("scoreboard.txt",ios::out|ios::binary);
                            file.write((char*)playr,sizeof(playr));
                            file.close();
                        }
                if(current!=test){
                current=test;


                down=false;
                //refreshing highscore
                settextstyle(3,0,1);
                settextjustify(LEFT_TEXT,TOP_TEXT);
                setcolor(0);
                setbkcolor(15);
                bgiout<<playr[0]._score();
                outstreamxy(738,16);
                setbkcolor(COLOR(250,250,200));
                setfillstyle(1,COLOR(250,250,200));
                bar(652,77,779,99);
                setcolor(0);
                outtextxy(655,78,playr[0]._name());
                }
                     jump=false;
                     jmp=false;
                     saved=false;
                     thro =false;
                     ready=false;
                     activeAI=false;
                egg1.move(basket[current]._x(),basket[current]._y());
                if(basket[current]._alt()==15||basket[current]._alt()==22||basket[current]._alt()==35||basket[current]._alt()==38||basket[current]._alt()==42){
                    tcount.initialize(basket[current]._x(),basket[current]._y());
                    tcount.show=true;
                }
                break;
                }
            else{
                activeAI=true;
                }
            }
            //special test............
            if(activeAI){
            if(abs(egg1._x()-basket[0]._x())<(basket[0]._spd()+1)*3){
                if(abs(egg1._y()-basket[0]._y())<15){
                egg1.stop=true;
                jump=false;
                jmp=false;
                saved=false;
                thro =false;
                ready=false;
                activeAI=false;
                current=0;
                egg1.move(basket[current]._x(),basket[current]._y());
                }
                }
            else{
            if(egg1._y()>(basket[0]._y())&&!saved){
                miss++;
                dbas.prepare(egg1._x(),1);
                saved=true;
                ato=false;
                down=false;
                up=false;
                dobs=false;
                      }
                }
                }
                }
            //collision with obstacle......
            else{
                for(int i=current;i<2;i++){
                    if(obs[i].showin){
                        if(collision(egg1,obs[i])){
                        egg1.normal();
                        setlinestyle(0,0,3);
                        setcolor(getpixel(fdstat.statx(0)-3,fdstat.staty(0)-5));
                        rectangle(fdstat.statx(3)-3,fdstat.staty(3)-3,fdstat.statx(3)-2+36,fdstat.staty(3)-2+36);
                        egg1.setTnY(obs[i].time,obs[i].yini);
                        obs[i].show(egg1._x(),egg1._y());
                        obssnd=7;
                    }
                    }
                }
                }
            }
      delay(dhila);
      }
    //for pause.........
    else{
        col=1-col;
        setcolor(col*14);
        outtextxy(pausex,pausey,"Paused!");
        delay(500);
        }
    setbkcolor(0);
    if(mousex()>gmfldxmax)
    {
        checklink();
    }
    }while(!gameover);
    registermousehandler(WM_LBUTTONDOWN,0);
    struct viewporttype vp;
    getviewsettings(&vp);
    int bgcolor;
    boundbtn bok;
    if(gameover){
        clearviewport();


        settextjustify(CENTER_TEXT,TOP_TEXT);


        bgcolor=COLOR(120,120,110);
        showmsg(midx-250,midy-200,500,300,bgcolor);
        setbkcolor(bgcolor);


        setcolor(COLOR(255,0,0));
        settextstyle(BOLD_FONT,0,5);
        outtextxy(midx,midy-170,"GAME OVER");


        settextstyle(3,0,1);
        setcolor(15);
        outtextxy(midx,midy-150+textheight("h")+20,"Your total score :");
        bgiout<<nowplayer._score();
        outstreamxy(midx+textwidth("Your total score :")/2+30,midy-150+textheight("h")+20);
        setcolor(COLOR(0,255,0));
        outtextxy(midx,midy+50,"Best of luck for next try");


        bok.set(midx-60,midy-50,100,textheight("M"));//(100+20)/2=60
        bok.outtext("OK",15);
        bok.drawborder(COLOR(220,220,210),0);
    }
    else
    {
        clearviewport();
        bgcolor=COLOR(65,65,200);
        showmsg(midx-250,midy-200,500,300,bgcolor);




        setviewport(midx-250+4,midy-200+vp.top+4,midx+250-4,midy+100+vp.top-4,1);//vp.left+(vp.right-vp.left)/2-textwidth("   ok   ")/2
        struct viewporttype vp2;
        getviewsettings(&vp2);
        setbkcolor(bgcolor);
        int yy=200;
        int bwid=80;// actual 100. look in class 80+20
        bok.set((vp2.right-vp2.left)/2-bwid/2,yy,bwid,textheight("M"));
        bok.outtext("OK",15);
        bok.drawborder(tcolor,COLOR(50,50,50));
        int size=imagesize((vp2.right-vp2.left)/2-bwid/2+1,yy+1,vp2.left+(vp2.right-vp2.left)/2+bwid/2,yy+textheight("M")+10);
        void* bt=malloc(size);
        getimage((vp2.right-vp2.left)/2-bwid/2+1,yy+1,vp2.left+(vp2.right-vp2.left)/2+bwid/2,yy+textheight("M")+10,bt);
        clearviewport();


        setcolor(COLOR(50,255,50));
        setbkcolor(bgcolor);
        setfillstyle(1,bgcolor);


        settextjustify(CENTER_TEXT,TOP_TEXT);
        settextstyle(GOTHIC_FONT,0,1);


        int y=300;
        int x=250;
        int height=textheight("h");
        int k=1;
        int gap=10;
        do
        {
            k=1;
            settextstyle(GOTHIC_FONT,0,1);
            settextjustify(CENTER_TEXT,TOP_TEXT);
            setfillstyle(1,bgcolor);
            outtextxy(x,y,"Congratulations!");
            bar(x-textwidth("Congratulations!")/2,y+height,x+textwidth("Congratulations!")/2,y+height+gap);


            outtextxy(x,y+k*height+k*gap,"******************************");k++;
            bar(x-textwidth("******************************")/2,y+k*height+(k-1)*gap,x+textwidth("******************************")/2,y+k*height+k*gap);


            outtextxy(x,y+k*height+k*gap,"You are successful");k++;
            bar(x-textwidth("You are successful")/2,y+k*height+(k-1)*gap,x+textwidth("You are successful")/2,y+k*height+k*gap);


            outtextxy(x,y+(k*height)+(k*gap),"to attain the objective");k++;
            bar(x-textwidth("to attain the objective")/2,y+k*height+(k-1)*gap,x+textwidth("to attain the objective")/2,y+k*height+k*gap);


            outtextxy(x,y+k*height+k*gap,"of");k++;
            bar(x-textwidth("of")/2,y+k*height+(k-1)*gap,x+textwidth("of")/2,y+k*height+k*gap);


            outtextxy(x,y+k*height+k*gap,"the game");k++;
            bar(x-textwidth("tha game")/2,y+k*height+(k-1)*gap,x+textwidth("the game")/2,y+k*height+k*gap);


            k++;
            putimage(bok._x(),y+k*height+k*gap,bt,0);
            bar(bok._x(),y+k*height+k*gap+bok._height(),bok._x()+bok._width(),y+k*height+k*gap+bok._height()+gap);


            y-=3;
            delay(100);
        }while(y>50);
        bok.set(bok._x(),(y+3)+k*height+k*gap,bwid,textheight("h"));
    }
    do
        {
            if(bok.ismouseover())
            {
                if(bok.rollover)
                {
                    int g=getcolor();
                    setcolor(15);
                    setlinestyle(1,0,1);
                    rectangle(bok._x()+4,bok._y()+4,bok._x()+bok._width()-6,bok._y()+bok._height()-6);
                    bok.rollover=false;
                    setlinestyle(0,0,1);
                    setcolor(g);
                }
                else if(ismouseclick(WM_LBUTTONDOWN))
                {
                    int g=getcolor();
                    setcolor(bgcolor);
                    setlinestyle(1,0,1);
                    rectangle(bok._x()+4,bok._y()+4,bok._x()+bok._width()-6,bok._y()+bok._height()-6);
                    setlinestyle(0,0,1);
                    setcolor(g);
                    bok.drawborder(COLOR(20,20,20),tcolor);
                    bok.click=true;
                    clearmouseclick(WM_LBUTTONDOWN);
                    delay(100);
                }
            }
            if(bok.rollout)
            {
                int g=getcolor();
                setcolor(bgcolor);
                setlinestyle(1,0,1);
                rectangle(bok._x()+4,bok._y()+4,bok._x()+bok._width()-6,bok._y()+bok._height()-6);
                setlinestyle(0,0,1);
                setcolor(g);
                bok.rollout=false;
            }
            delay(10);
        }while(!bok.click);
    clearmouseclick(WM_LBUTTONDOWN);
    setviewport(vp.left,vp.top,vp.right,vp.bottom,1);
    clearviewport();
    showmenu();
}


void scene1(void)
{
   clearviewport();
   int x,y;
   y=getmaxy()/3;
   x=MaxX/3;
   setbkcolor(0);
   setcolor(15);
   settextstyle(0,4,2);
   fadetext(0,1,1,"OPEN SOURCE & WORLD","Presents");
   while(kbhit())getch();
   char txt[33];
   strcpy(txt,"A Program by OPEN SOURCE LOVER");
   char message[33];
   int f=0,a=0,turn=0;
   int r=0,g=5,b=0;
   int tb=0;
/*..............tempararily "scene1"......................*/
   int timstart=clock();
   while (!kbhit()&&(clock()-timstart)<15000) {
         setcolor(COLOR(100,255,50));
         settextstyle( DEFAULT_FONT, HORIZ_DIR , 3 );
         settextjustify( LEFT_TEXT,TOP_TEXT );
         if(f<=strlen(txt)){
            for(int i=0;i<=f;i++)
                message[i]=txt[i];
         message[f+1]='\0';
        if(turn>1){
            turn=0;
            f++;
        }
        else
            turn++;
        outtextxy(midx-textwidth("A Program by OPEN SOURCE LOVER")/2,midy+50,message);
        outtextxy(midx-textwidth("A Program by OPEN SOURCE LOVER")/2+textwidth(message),midy+50,"_");
        }
      else{
        outtextxy(midx+textwidth("A Program by OPEN SOURCE LOVER")/2-2,midy+50,"  ");
        fadetext(getmaxx()*2/3,440,COLOR(r,g,b),"ENJOY");
        fadetext(getmaxx()*2/3,490,COLOR(r,g,b),"LOVE OPEN SOURCE");
            r=(r<90)?(10+r):100;
            g=(g<245)?(10+g):255;
            b=(b<40)?(10+b):50;
      }
        fadetext(midx,150,COLOR(0,tb,tb),"The Egg-Pass");
        fadetext(midx,200,COLOR(0,tb,tb),"Game");
        tb=(tb<245)?(5+tb):250;
      //flag.draw2();
      if(a<120)a++;
      delay(2);
   }
}




void click_handler(int x,int y)
{
   setcolor(5);
   y-=38;
   setlinestyle(0,0,3);
   if(x>(fdstat.statx(0))&&x<(fdstat.statx(0)+32)&&y>(fdstat.staty(0))&&y<(fdstat.staty(0)+32))
    {
        if(dobs){
                dobs=false;
            }
        if(fdstat.getstat(0)>0){
                up=true;
            }
        else{
            up=false;
        }
        ato=up;
   }
   else if(x>(fdstat.statx(1))&&x<(fdstat.statx(1)+32)&&y>(fdstat.staty(1))&&y<(fdstat.staty(1)+32))
    {
        if(fdstat.getstat(1)>0){
        dobs=!dobs;
        }
        ato=dobs;
        up=dobs;
   }
   else if(x>(fdstat.statx(3))&&x<(fdstat.statx(3)+32)&&y>(fdstat.staty(3))&&y<(fdstat.staty(3)+32))
    {
        if(fdstat.getstat(3)>0){
            hyperj=true;
        Beep(1000,30);
        }
   }
   else if(x>(sbtn[0]._x()) && x<(sbtn[0]._x()+sbtn[0]._width()) && y>(sbtn[0]._y()) && y<(sbtn[3]._y()+ sbtn[3]._height()))
   {
        for(int i=0;i<4;i++)
        {
            if(sbtn[i].ismouseover())
            {
                sbtn[i].click=true;
                break;
            }
        }
    }
    else
    {
        if(!jump && !mark && x>gmfldxmin && x<gmfldxmax && y>5 && y<535){
            jump=true;
            jmp=true;
            }
    }
    clearmouseclick(WM_LBUTTONDOWN);
}




int main()
{
   //HWND wnc=GetForegroundWindow();
   //ShowWindow(wnc,SW_HIDE);
   Initialize();                    //initialize graphics............  (above)
   setvisualpage(1);                //makes page the visual graphics page
   MainWindow("The Egg-Pass");
   StatusLine( "Egg Pass Game" );
   DrawBorder();                    //makes page the active graphics page
   setvisualpage(0);
   outtextxy(200,100,"Loading...........");
   int t1=clock();
   delay(100);
   Tfactor=(clock()-t1)/100;
   setactivepage(1);
   //setvisualpage(1);
   clearviewport();
   basket[0].draw();dbas.draw();egg1.draw();obs[0].draw();circl.draw();fod[0].draw();tcount.draw();
   showmenu();                           //draw mainmenu items 1st
   EnterInfo();


   clearviewport();
   //MainWindow("The Egg-Pass");
   StatusLine( "Egg Pass Game" );
   DrawBorder();
   setactivepage(0);
   //setvisualpage(0);
   scene1();                //names and other
   while(kbhit())getch();
   showmenu();              // show main menu
   system("pause");
   closegraph();
   return 0;
}
void btnrelease_handler(int x,int y)
{
    for(int i=0;i<4;i++)
    {
        if(sbtn[i].ismouseover())
        {
            sbtn[i].release=true;
            break;
        }
    }
}
int showmenulink(int xpos,int ypos)
{
    //registermousehandler(WM_LBUTTONDOWN,btnclick_handler);
    registermousehandler(WM_LBUTTONUP,btnrelease_handler);
    settextstyle(3,0,1);
    setfillstyle(1,barcolor);
    setbkcolor(barcolor);
    int width=120;
    int height=200;
    showmsg(xpos-4,ypos-4,width+8,height+8,0);
    bar(xpos,ypos,xpos+width,ypos+height);
    sbtn[0].set(xpos+width/2-textwidth("MainMenu")/2-10,ypos+15,textwidth("MainMenu"),textheight("M"));
    sbtn[0].outtext("MainMenu");


    sbtn[1].set(xpos+width/2-textwidth("Pause")/2-10,sbtn[0]._y()+sbtn[0]._height()+10,textwidth("pause"),textheight("M"));
    sbtn[1].outtext("Pause");


    sbtn[2].set(xpos+width/2-textwidth("mute")/2-10,sbtn[1]._y()+sbtn[1]._height()+10,textwidth("mute"),textheight("M"));
    sbtn[2].outtext("Mute");


    sbtn[3].set(xpos+width/2-textwidth("exit")/2-10,sbtn[2]._y()+sbtn[2]._height()+10,textwidth("exit"),textheight("M"));
    sbtn[3].outtext("Exit");
}
int checklink()
    {
        for(int i=0;i<4;i++)
        {
            if(sbtn[i].ismouseover())
            {
                if(sbtn[i].rollover)
                {
                    if(i==2 && !sound)
                        sbtn[2].drawborder(bcolor,tcolor);
                    else
                        sbtn[i].drawborder(tcolor,bcolor);
                    sbtn[i].rollover=false;
                }
                else if(sbtn[i].click)
                {
                    sbtn[i].drawborder(bcolor,tcolor);
                    if(sound)
                    {
                        for(int j=1;j<5;j++)
                            Beep(600*j*j,20);
                    }
                    sbtn[i].click=false;
                    if(i==0)
                    {


                        setactivepage(1);
                        clearviewport();
                        setvisualpage(1);
//                        setactivepage(0);
                        showmenu(1);
                        registermousehandler(WM_LBUTTONDOWN,click_handler);
                        setvisualpage(0);
                        setactivepage(0);
                        return 1;


                    }
                    else if(i==1)
                    {
                        setfillstyle(1,0);
                        bar(gmfldxmax+20,200,gmfldxmax+140,225);
                        pause=!pause;
                    }
                    else if(i==2)
                    {
                        sound=!sound;
                    }
                    else if(i==3)
                        exit(0);
                }
                else if(sbtn[i].release)
                {
                    if(i==2 && !sound)
                        sbtn[2].drawborder(bcolor,tcolor);
                    else
                        sbtn[i].drawborder(tcolor,bcolor);
                    sbtn[i].release=false;
                }
            }
            else if(sbtn[i].rollout)
            {
                if(i==2 && !sound)
                    sbtn[2].drawborder(bcolor,tcolor);
                else
                    sbtn[i].drawborder(barcolor,barcolor);
                sbtn[i].rollout=false;
                break;
            }


        }
    return 0;
}
void showmsg(int x,int y,int width,int height,int bkcol)
{
    int gc=getcolor();
    int bg=getbkcolor();
    struct fillsettingstype fil;
    getfillsettings(&fil);




    int t=1;
    setfillstyle(1,COLOR(236,233,216));
    bar(x+2*t,y+2*t,x+width-2*t,y+height-2*t);


    setfillstyle(1,bkcol);
    bar(x+3*t,y+3*t,x+width-3*t,y+height-3*t);


    setfillstyle(1,COLOR(255,255,255));
    bar(x+t,y+t,x+t+t,y+height-2*t);
    bar(x+t,y+t,x+width-2*t,y+t+t);


    setfillstyle(1,COLOR(236,233,216));
    bar(x,y,x+t,y+height-t);
    bar(x,y,x+width-t,y+t);


    setfillstyle(1,COLOR(172,168,153));
    bar(x+width-2*t,y+t,x+width-t,y+height-2*t);
    bar(x+t,y+height-2*t,x+width-t,y+height-t);


    setfillstyle(1,COLOR(113,111,100));
    bar(x+width-t,y,x+width,y+height);
    bar(x,y+height-t,x+width,y+height);


    setcolor(gc);
    setbkcolor(bg);
    setfillstyle(fil.pattern,fil.color);




}
void border3d(int l,int t,int r,int b,int topcolor,int bottomcolor)
{
            setlinestyle(SOLID_LINE, 0, 1);
            setcolor(topcolor);
            moveto(l,b);
            lineto(l,t);
            lineto(r,t);
            setcolor(bottomcolor);
            lineto(r,b);
            lineto(l,b);
            setlinestyle(SOLID_LINE, 0, 1);
}




 


2. credits.cpp


#include<iostream>
#include<graphics.h>
#include<string.h>
#include<math.h>
#include "classes.h"
#include "mainmenu.h"
#include "credits.h"


#define red COLOR(255,0,0)
#define green COLOR(0,255,0)
#define blue COLOR(0,100,255)
#define lightblue COLOR(95,112,220)
using namespace std;


class title
{
    private:
        char text[20];
        int startx,starty;
        int x,y;
        bool slidey;
        int k;
        int leastfactor;
        int loop;


    public:
        title(){}
        bool stop;
        void set(int finalx,int finaly,bool ch,int looop,int inc,char txt[])
        {
            leastfactor=inc;
            loop=looop;
            if(!ch)
                startx=finalx-int(((loop*leastfactor*1.0)/2)*(loop+1));
            else
                starty=finaly-int(((loop*leastfactor*1.0)/2)*(loop+1));
            x=finalx;
            y=finaly;
            slidey=ch;
            strcpy(text,txt);
            k=0;
            setfillstyle(1,0);
            stop=false;
        }
        void show()
        {
            if(!slidey && (x-startx)*(leastfactor/abs(leastfactor))>=0)
            {
                outtextxy(startx,y,text);
                if(leastfactor<0)
                {
                    bar(startx+textwidth(text),y,startx+textwidth(text)+50,y+textheight("h")); //150 is just a erase width
                }
                else
                    bar(0,y,startx,y+textheight("h"));
                startx+=k*leastfactor;
                k++;
            }
            else if(slidey && (y-starty)*(leastfactor/abs(leastfactor))>=0)
            {
                outtextxy(x,starty,text);
                if(leastfactor<0)
                {
                    bar(x,starty+textheight("h")+60,x+textwidth(text),starty+textheight("h")-2);//100 is a approx width 50 is a trial random height
                }
                else
                    bar(x,0,x+textwidth(text),starty);
                starty+=k*leastfactor;
                k++;
            }
            else
                stop=true;
        }
        void show(int color)
        {
            setcolor(color);
            outtextxy(x,y,text);
        }
};
TButton creditok;
bool steady=false;
int showCredits()
{
    clearviewport();
    creditok.settextpara("  OK  ",400-textwidth("  OK  ")/2,350);
    registermousehandler(WM_LBUTTONDOWN,creditsclick_handler);
    settextstyle(3,0,1);
    title tytl[4],developer[3];
    tytl[0].set(200,100,0,25,1,"Concept ,");
    tytl[1].set(280,100,1,30,1,"Programming ,");
    tytl[2].set(400,100,0,40,-1,"Graphics  &");
    tytl[3].set(500,100,1,50,-1,"Development");
    settextstyle(GOTHIC_FONT,0,5);
    developer[0].set(200,180,0,30,1,"OPEN");
    developer[1].set(200,280,0,30,-1,"WORLD");
    developer[2].set(200,230,1,30,-1,"SOURCE");
    bool go=false;
    setcolor(15);
    //setfillstyle(1,getbkcolor());
    clearviewport();


    fadetext(1,1,0,"ORIGINAL CONCEPT BUILDER");


    settextstyle(3,HORIZ_DIR,1);
    settextjustify(LEFT_TEXT,TOP_TEXT);
    setfillstyle(1,0);
    setcolor(15);
    int j=1;
        while(!tytl[3].stop)
        {
            for(int i=0;i<4;i++)
            {
                tytl[i].show();
                delay(10);
            }
        }
        settextstyle(GOTHIC_FONT,0,5);
        int xl=400,yl=150,k=1;
        while(!developer[0].stop)
        {
            setcolor(15);
            for(int i=0;i<3;i++)
            {
                developer[i].show();
            }
            setcolor(COLOR(80,170,240));
            for(int n=0;n<7;n++)
            {


                moveto(xl,yl);
                lineto(xl+k*1,yl);
                moveto(xl,yl);
                lineto(xl-k*1,yl);
                k++;
            }
        delay(10);
        }
    settextstyle(BOLD_FONT,HORIZ_DIR,5);
    creditok.display(blue);




    int i=0,a=2;
    int r=255,g=255,b=0;
    int ph1=0,ph2=0;


    do
    {
        settextstyle(GOTHIC_FONT,HORIZ_DIR,5);
        r=abs((int)(sin(i*M_PI/180)*255));
        g=abs((int)(cos(i*M_PI/180+ph1)*255));
        b=abs((int)(sin(i*M_PI/180+ph2)*255));
        for(int n=0;n<3;n++)
            developer[n].show(COLOR(r,g,b));
        i+=a;
        if(i>359)
        {
            i=0;
            ph1=rand()%180;
            ph2=rand()%180;
        }
        delay(20);
        if(creditok.ismouseover())
            creditok.onmouseover();
        if(creditok.rollout && !creditok.mouseover)
               creditok.onrollout();
        if(creditok.click)
        {
            creditok.onclick();
            break;
        }
    }while(!creditok.click);


    return 0;
}
void creditsclick_handler(int x, int y)
{
    creditok.isclick();
}




3.mainmenu.cpp


#include <cstdlib>
#include <iostream>
#include <graphics.h>
#include "mainmenu.h"
#include "playerinfo.h"
#include "loadgame.h"
#include "instructions.h"
#include "highscores.h"
#include "credits.h"
#include "classes.h"


#define red COLOR(255,0,0)
#define green COLOR(0,255,0)
#define blue COLOR(0,65,255)
#define lightblue COLOR(135,230,220)
using namespace std;


void slidemenu();
void* eraser;
bool menuinitial=false;
bool end=false;
class arrow
{
      private:
              int x,y,pts[14],max,tempxl,tempxr;


              int wid,hig,thick,speed,bre;
              int size;
      public:
             arrow():x(150),y(310),max(15),wid(40),hig(50),thick(15){}
             bool ready;
             void *arr[2];
             void sketch(int d,int i){
                  pts[0]=x-d*wid;
                  pts[1]=y-hig/2;
                  pts[2]=x-d*wid+d*thick;
                  pts[3]=pts[1];
                  pts[4]=x;
                  pts[5]=y;
                  pts[6]=pts[2];
                  pts[7]=y+hig/2;
                  pts[8]=pts[0];
                  pts[9]=pts[7];
                  pts[10]=x-d*thick;
                  pts[11]=y;
                  pts[12]=pts[0];
                  pts[13]=pts[1];
                  setcolor(COLOR(int((max-i)*255/max),int(i*255/max),0));//int(i*25.5),0));
                  //setlinestyle(0,0,1);
                  //drawpoly(7,pts);
                  setfillstyle(1,COLOR(int((max-i)*255/max),int(i*255/max),0));
                  fillpoly(7,pts);
                  }
                  void draw(){
                  int clearance=2;
                  for(int i=0;i<max;i++){
                          sketch(1,i);
                          //rectangle(x-wid-clearance,y-hig/2-clearance,x+clearance,y+hig/2+clearance);
                          x+=4;
                  }
                  size=imagesize(x-4*(max+1)-wid,y-hig/2-clearance,x+clearance,y+hig/2+clearance);
                  arr[0]=malloc(size);
                  getimage(x-4*(max+1)-wid,y-hig/2-clearance,x+clearance,y+hig/2+clearance,arr[0]);
                  //ctangle(x-4*(max+1)-wid,y-hig/2-clearance,x+clearance,y+hig/2+clearance);
                  y+=hig+15;
                  x=100;
                  for(int i=0;i<max;i++){
                          sketch(-1,i);
                          x-=4;
                        }
                          //rectangle(x-clearance,y-hig/2-clearance,x+wid+clearance,y+hig/2+clearance);
                          size=imagesize(x,y-hig/2-clearance,x+4*(max+1)+wid,+hig/2+clearance);
                          arr[1]=malloc(size);
                          getimage(x,y-hig/2-clearance,x+4*(max+1)+wid,y+hig/2+clearance,arr[1]);
                  }
                void show(int xx,int yy,int bb)
                {
                    putimage(xx-4*16-wid,yy-hig/2,arr[0],XOR_PUT);
                    putimage(xx+bb,yy-hig/2,arr[1],XOR_PUT);
                }
                int _wid()
                  {
                        return wid;
                    }
                int _hig()
                  {
                        return hig;
                    }
};
arrow arro;
TButton::TButton()
{
    mouseover=false;
    rollout=false;
    click=false;
    stop=false;
    showarrow=false;
}
void TButton::settextpara(char n[],int xx,int yy)
{
    strcpy(txt,n);
    x=xx;
    y=yy;
    mouseover=false;
    rollout=false;
    click=false;
    stop=false;
    showarrow=false;
    r=0;
    g=65;
    b=255;
    k=0;
    width=textwidth(n);
    height=textheight("h");
    cpart=-10+height/2+6;
    drawbox();
    int size=imagesize(x-20,y-10,x+width+20,y+height+10);
    btnbound=malloc(size);
    getimage(x-20,y-10,x+width+20,y+height+10,btnbound);
}
void TButton::reset()
{
    r=0;
    g=65;
    b=255;
    mouseover=false;
    rollout=false;
    stop=false;


}


void TButton::drawbox()
{
    int xdisp=10;
    int tcolor=getcolor();
    setcolor(lightblue);
    setlinestyle(0,1,3);
    arc(x+xdisp,y+height/2,90,270,height/2+6);


    moveto(x+xdisp,y-6);
    lineto(x+width-xdisp,y-6);
    arc(x-xdisp+width,y+height/2,270,90,height/2+6);


    moveto(x-xdisp+width,y+height+4);
    lineto(x+xdisp,y+height+4);


    setlinestyle(SOLID_LINE,0,1);
    setcolor(green);


            //rectangle(x,y,x+width,y+height);
            //rectangle(x-20,y-10,x+width+20,y+height+10);
    setcolor(tcolor);
}
void TButton::setstartx(int loop,int leastfactor)
{
    startx=x+int(((loop*leastfactor*1.0)/2)*(loop+1));
    inc_factor=leastfactor;
}
void TButton::arrowvisibility(bool arr_visible)
{
    showarrow=arr_visible;
}
bool TButton::ismouseover()
{
    struct viewporttype vp;
    getviewsettings(&vp);
    if((mousex()-vp.left)>x-13 && (mousex()-vp.left)<(x+width)+13 && (mousey()-vp.top)>(y-5) && (mousey()-vp.top)<(y+height+5))
    {
        if(!mouseover)
        {
            rollover=true;
        }
        mouseover=true;
        return true;
    }
    else
    {
        if(mouseover)
            {
                firstroll=true;
                rollout=true;
            }
        mouseover=false;
        return false;
    }
}


void TButton::display(int color)
{




    drawbox();
            //putimage(x-height/2,y-height/4,btnbound,0);
    settextstyle(BOLD_FONT,HORIZ_DIR,5);
    setcolor(color);
    outtextxy(x,y,txt);
}
void TButton::displaynorm()
{
    drawbox();
    setfillstyle(1,0);
    setbkcolor(0);
    floodfill(x-8,y+height/2,lightblue);
    settextstyle(BOLD_FONT,HORIZ_DIR,5);
    setcolor(blue);
    outtextxy(x,y,txt);
    mouseover=false;
    rollout=false;


}
void TButton::slide()
{
    if((startx-x)>0)
    {
        stop=false;
        startx-=k*inc_factor;
        k+=1;
    }
    else
    {
        k=0;
        stop=true;
    }
    putimage(startx-height/2,y-height/4,btnbound,0);
    outtextxy(startx,y,txt);
    putimage(startx+height/2+width,y-height/4,eraser,0);
}
void TButton::onmouseover()
{
            r=0;
            g=255;
            b=0;
            int tbk=getbkcolor();
            setbkcolor(red);
            if(rollover)
            {
                setfillstyle(1,red);
                floodfill(x-8,y+height/2,lightblue);
                Beep(1000,30);
                if(showarrow)
                {
                    arro.show(x-cpart,y+height/2,width+2*cpart);
                }
                rollover=false;
            }
            display(COLOR(r,g,b));
            setbkcolor(tbk);




}
void TButton::onrollout()
{
           if(firstroll)
            {
                setfillstyle(1,0);
                setbkcolor(0);
                floodfill(x-8,y+height/2,lightblue);
                if(showarrow)
                {
                   arro.show(x-cpart,y+height/2,width+2*cpart);
                }
                firstroll=false;
            }
            if(g>8)
            {


                g-=int((255-65)/30);
                b+=int(255/60);
            }
            else
            {
                b+=int((255)/60);
            }
            display(COLOR(r,g,b));
            if(b>240)
                rollout=false;
}
bool TButton::isclick()
{
            if(ismouseover())
            {
                click=true;
                return true;
            }
            else
                return false;
}
void TButton::onclick()
{
            settextstyle(10,HORIZ_DIR,5);
            settextjustify(LEFT_TEXT,TOP_TEXT);
            settextstyle(BOLD_FONT,HORIZ_DIR,5);
            int tbk=getbkcolor();
            setbkcolor(green);
            setfillstyle(1,green);
            floodfill(x-8,y+height/2,lightblue);
            display(red);
            delay(200);
            setbkcolor(red);
            setfillstyle(1,red);
            floodfill(x-8,y+height/2,lightblue);
            display(green);
            setbkcolor(tbk);
            for(int i=1;i<7;i++)
                Beep((500*i),50);
            click=false;
}


TButton btn[8];
void menuclick_handler(int x, int y)
{
        for(int i=0;i<8;i++)
        btn[i].isclick();


}


int res;


int showmenu(int a)
{
    registermousehandler(WM_LBUTTONDOWN,menuclick_handler);
    settextstyle(10,HORIZ_DIR,5);
    settextjustify(LEFT_TEXT,TOP_TEXT);
    //setactivepage(0);
    if(!menuinitial)
    {
        //setactivepage(1);
        clearviewport();
        arro.draw();                   // arrow of main menu<both side>  mainmenu.cpp class of arrow arro
        int midx=getmaxx()/2;
        int size=imagesize(10,10,10+textwidth("controls")+10,10+textheight("h")+20);
        eraser=malloc(size);
        getimage(10,10,10+textwidth("controls")+10,10+textheight("h")+20,eraser);
        putimage(400,10,eraser,0);
        clearviewport();
        int gap=25;
        btn[0].settextpara("NEW",midx-textwidth("new")/2,90);
        btn[1].settextpara("LOAD",midx-textwidth("load")/2,90+textheight("h")+gap);
        btn[2].settextpara("INSTRUCTIONS",midx-textwidth("instructions")/2,90+2*textheight("h")+2*gap);
        btn[3].settextpara("HIGHSCORES",midx-textwidth("highscores")/2,90+3*textheight("h")+3*gap);
        //btn[4].settextpara("SETTINGS",midx-textwidth("settings")/2,50+4*textheight("h")+4*gap);
        btn[4].settextpara("CREDITS",midx-textwidth("credits")/2,65+4*textheight("h")+5*gap);
        btn[5].settextpara("EXIT",midx-textwidth("exit")/2,65+5*textheight("h")+6*gap);
        btn[6].settextpara("RESUME",MaxX-textwidth("resume")-30,50+0*textheight("h")+0*gap);
        for(int i=0;i<6;i++)
            btn[i].arrowvisibility(true);
        menuinitial=true;
        return 0;
    }
    //setactivepage(0);
    res=a;
    slidemenu();       //slides menu to appear


    setcolor(15);
    for(int i=0;i<6;i++)
        btn[i].stop=false;


    do
    {
        if(ismouseclick(WM_MOUSEMOVE))
        {
            for(int i=0;i<6+a;i++)
            {
                if(btn[i].ismouseover())
                {
                    btn[i].onmouseover();
                }
            }
            clearmouseclick(WM_MOUSEMOVE);
        }


        for(int i=0;i<6+a;i++)
        {
            if(btn[i].rollout && !btn[i].mouseover)
                btn[i].onrollout();
        }


        for(int i=0;i<6+a;i++)
        {
            if(btn[i].click)
            {
                btn[i].onclick();
                if(i==0)
                {
                    int tmp=EnterInfo();
                    if(tmp==1)
                    {
                        gameplay();
                        return 0;
                    }
                    settextstyle(BOLD_FONT,HORIZ_DIR,5);
                }
                else if(i==1)
                {
                    int tmp=Loadgame();
                    if(tmp==1)
                        return 0;
                }
                else if(i==2)
                {
                    showInstructions();
                }
                else if(i==3)
                    showHighscores();
                /*else if(i==)
                {
                    int tmp=showSettings(a);
                    if(tmp==1)
                    {
                        setactivepage(1);
                        clearviewport();
                        Tbasket::draw();
                        Dbasket::draw();
                        setactivepage(0);
                    }
                }*/
                else if(i==4)
                    showCredits();
                else if(i==5)
                    exit(0);
                else if(i==6)
                    return 0;


                slidemenu();
                break;
            }
        }
        delay(10);
        while(kbhit())getch();
    }while(!end);
    return 0;
}


void slidemenu()
{
    setbkcolor(0);
    clearviewport();
    registermousehandler(WM_LBUTTONDOWN,menuclick_handler);
    settextjustify(LEFT_TEXT,TOP_TEXT);
    settextstyle(BOLD_FONT,HORIZ_DIR,5);
    for(int i=0;i<6;i++)
    {
        btn[i].reset();
    }
    btn[0].setstartx(40,5);
    btn[1].setstartx(35,5);
    btn[2].setstartx(30,5);
    btn[3].setstartx(25,5);
    //btn[4].setstartx(20,5);
    btn[4].setstartx(15,5);
    btn[5].setstartx(10,5);
    btn[6].setstartx(40,5);
    setcolor(blue);
    do
    {
        for(int i=0;i<6+res;i++)
        {
            if(!btn[i].stop)
                btn[i].slide();
        }
        delay(5);
    }while(!btn[0].stop);
}




4.classes.cpp


#include <iostream>
#include <string.h>
#include <graphics.h>
#include <math.h>
#include "classes.h"
using std::cout;
using std::endl;


//funtions of player


player::player()
{
    strcpy(name,"NoName");
    score=0;
    rank=15;
    level=1;
}
void player::namakaran(char nam[])
{
    strcpy(name,nam);
}                
       
void player::updatescore(int points)
{
    score=points;
}
void player::updaterank(int r)
{
    rank=r;
}
void player::updatelevel(int lev)
{
    level=lev;
}
void player::show()
{
    //cout<<endl<<"Name: "<<name<<"_______"<<score<<"_______"<<rank<<"______"<<level<<endl;
}
char* player::_name()
{
    return name;
}
int player::_score()
{
    return score;
}
int player::_rank()
{
    return rank;
}
int player::_level()
{
    return level;
}


//funtions of boundbtn


void boundbtn::set(int xx,int yy,int w,int h)
{
    x=xx;
    y=yy;
    width=w+20;
    height=h+10;    
    mouseover=false;
    rollover=false;
    rollout=false;
    click=false; 
    release=false;   
}
void boundbtn::outtext(char str[],int txtcol,bool center)
{
    int g=getcolor();
    setcolor(txtcol);
    if(center)
    {
        settextjustify(CENTER_TEXT,TOP_TEXT);
        outtextxy(x+width/2,y+4,str);
    }
    else
    {
        settextjustify(LEFT_TEXT,TOP_TEXT);
        outtextxy(x+10,y+4,str);
    }
    settextjustify(LEFT_TEXT,TOP_TEXT);
    setcolor(g);
}
void boundbtn::outtext(int x,int y,int num)
{
    int g=getcolor();
    setcolor(0);
    settextjustify(LEFT_TEXT,TOP_TEXT);
    bgiout<<num;
    outstreamxy(x,y+4);  
    setcolor(g);        
}
        //void border3d(int x,int y,int width,int height,int topcolor,int bottomcolor)
void boundbtn::drawborder(int topcolor,int bottomcolor)
{
    struct fillsettingstype fil;
    getfillsettings(&fil);
    setfillstyle(SOLID_FILL,topcolor);
    bar(x,y,x+3,y+height);
    bar(x,y,x+width-3,y+3);
    setfillstyle(SOLID_FILL,bottomcolor);
    bar(x,y+height-3,x+width,y+height);
    bar(x+width-3,y,x+width,y+height);
    setfillstyle(fil.pattern,fil.color);
           
}
bool boundbtn::ismouseover()
{
    struct viewporttype vp;
    getviewsettings(&vp);
    if((mousex()-vp.left)>x && (mousex()-vp.left)<(x+width) && (mousey()-vp.top)>y && (mousey()-vp.top)<(y+height))
    {
        if(!mouseover)
        {
            rollover=true;
            if(sound)
               Beep(4000,10);
        }
        mouseover=true;               
        return true;
    }
    else
    {
        if(mouseover)
        {
            rollout=true;
        }
        mouseover=false;
        return false;
    }
}
int boundbtn::_x()
{
    return x;
}
int boundbtn::_y()
{
    return y;
}
int boundbtn::_height()
{
    return height;

int boundbtn::_width()
{
    return width;
}        






//func by mahesh................
void fadetext(int r,int g,int b,char t[],char n[])
{
    int tsize=2;
    int i=180;
    int rr,gg,bb;
    float rad=M_PI/180;
    do{
    rr=r*(int)(sin(i*rad)*255);
    gg=g*(int)(sin(i*rad)*255);
    bb=b*(int)(sin(i*rad)*255);
    setcolor(COLOR(rr,gg,bb));
    settextstyle(4,0,tsize);                  //HORTZ_DIR
    settextjustify(LEFT_TEXT,TOP_TEXT);
    outtextxy((int)(getmaxx()/2-textwidth(t)/2),(int)(getmaxy()/2.5),t);//12 for 0
    moveto(getmaxx()/2-textwidth(t)/2-20,int(getmaxy()/2.5+25));
    lineto(getmaxx()/2+textwidth(t)/2+20,int(getmaxy()/2.5+25));
    outtextxy(getmaxx()/2-textwidth(n)/2,int(getmaxy()/2.5)+50,n);
    delay(20);
    i--;
    }while(i>0);
}
void fadetext(int x,int y,int color,char n[]){
    setcolor(color);
    settextstyle(GOTHIC_FONT,0,1);
    settextjustify(LEFT_TEXT,TOP_TEXT);
    moveto(x-textwidth(n)/2-20,y);
    lineto(x+textwidth(n)/2+20,y);
    outtextxy(x-textwidth(n)/2,y-20,n);
}
void bird(int x,int y){
     setlinestyle(0,0,1);
    setcolor(COLOR(200,255,0));  
    setfillstyle(1,COLOR(200,255,0));
    moveto(x,y);
    circle(x,y,10);circle(x+3,y,2);
   
    moveto(x+10,y-2);
    lineto(x+20,y-1);lineto(x+10,y+1);
    lineto(x+17,y+5);
    lineto(x+9,y+3);
   
    ellipse(x-25,y+10,270,0,25,30);
    ellipse(x-25,y+10,250,0,18,18);
    moveto(x-10,y+8);
    lineto(x-38,y+27);
   
    moveto(x-25,y+40);
    lineto(x-70,y+30);
    lineto(x-60,y+20);
    lineto(x-28,y+30);
   
    moveto(x-25,y+35);
    lineto(x-25,y+50);
    lineto(x-30,y+53);
    moveto(x-25,y+50);
    lineto(x-20,y+54);
   
    moveto(x-20,y+40);
    lineto(x-20,y+50);
    lineto(x-24,y+53);
    moveto(x-20,y+50);
    lineto(x-15,y+54);
}




//Egg.................................................................................
egg::egg():xpos(midx),ypos(midy),dt(5){}
void egg::draw()
{    
                  /*set initials 0*/
                  xradius=15;
                  yradius=int(1.8*xradius);
                  MainX=50;
                  MainY=midy-50;
                  im=0;
                  t=0;
                  turn=0;
                  float ang=0;
                  int offset=0;
                  f=0.1;
                  gv=0.2/5;//2*f/3;//gv=9.8*f;
                  u=3.75;
                  xx=50/5;
                  yy=110/5;  
                  int suj,raj;
                 for(int j=0;j<8;j++)
                 {
                    //gradient colouring................
                    //by mahesh............................
                    int c=0;
                    int r=230;
                    int g=100;
                    int b=0;
                    for(int i=(xradius+yradius)/2+10;i>1;i-=3,r+=1,g+=8,b+=15)
                    {
                        setfillstyle(SOLID_FILL,COLOR(r,g,b));
                        setcolor(COLOR(r,g,b));
                        fillellipse(MainX-3+offset,MainY,i,i);
                    }        
                    setcolor(BLACK);
                    suj=int(-4*sin(ang*M_PI/180));
                    raj=int(4*cos(ang*M_PI/180));   
                    if(j%2==0)
                    {
                      rx=abs(xx*(int)cos(ang/180*M_PI)+yy*(int)sin(ang/180*M_PI));   
                      ry=abs(xx*(int)sin(ang/180*M_PI)+yy*(int)cos(ang/180*M_PI));
                      xcorrect=-4*(int)sin(ang/180*M_PI);       
                      ycorrect= 4*(int)cos(ang/180*M_PI);
                      ellipse(MainX+offset+xcorrect+suj,MainY+ycorrect+raj,20-(int)ang,160-(int)ang,rx,ry);
                      arc(MainX+offset+suj,MainY+raj,160-(int)ang,20-(int)ang,xx);
                      setfillstyle(SOLID_FILL, 0);
                      floodfill(MainX+offset+yy-20,MainY+yy-5,0);//for suzeve's gradient...... midx+offset+yy-15,midy+yy-15
                    }
                    else
                    {
                         inc = int(ang+180);
                         ini_draw=true;
                         for(int i=0;i<171;i+=10)
                         {
                                 xi=xx*cos(i*M_PI/180);
                                 yi=yy*sin(i*M_PI/180);
                                 rx=int(xi*cos(inc*M_PI/180)-yi*sin(inc*M_PI/180));
                                 ry=int(yi*cos(inc*M_PI/180)+xi*sin(inc*M_PI/180));
                                 xcorrect=4*(int)sin((ang+45)*M_PI/180)*(int)(cos(ang*M_PI/180));       
                                 ycorrect=4*(int)cos((ang+45)*M_PI/180)*(int)(sin(ang*M_PI/180));
                                 if(ini_draw==true){
                                    moveto(MainX+offset+rx+xcorrect+suj,MainY+ry+ycorrect+raj);
                                    ini_draw=false;
                         }
                                 else                
                                    lineto(MainX+offset+rx-xcorrect+suj,MainY+ry+ycorrect+raj);
                    }
                         arc(MainX+offset+suj,MainY+raj,160-inc-180,25-inc+180,xx);
                         setfillstyle(SOLID_FILL, 0);
                         floodfill(MainX+offset+yy-20+suj,MainY+yy-5+raj,0);
                    }
                 size = imagesize(MainX+offset-yy,MainY-yy,MainX+offset+yy,MainY+yy);
                 eg[j] = malloc(size);             /*allocate memory space*/  
                 setcolor(15);                                               
                 getimage(MainX+offset-yy,MainY-yy,MainX+offset+yy,MainY+yy,eg[j]);/* grab the image */
                 ang+=45;
                 offset+=70;
                 }  
}
int egg::_x()
{
    return(xpos);
}
int egg::_y()
{
    return(ypos);
}
int egg::_t()
{
    return(t);
}
float egg::_u(){
                 return(u);
                  }
void egg::setTnY(int a,int y){
                  t=a;
                  y_ini=y;
                  }
void egg::hyperjump(){
                  gv=2*f/9;
                  }
void egg::drop(){
                  u=0;
                  }
void egg::normal(){
                  gv=2*f/5;
                  u=3.75;
                  }
void egg::move(){
                  putimage(xpos-22,ypos-20,eg[im],XOR_PUT);
                  }
void egg::move(int x,int y)
{
                  if(im>=8)
                    im=0; 
                  putimage(xpos-22,ypos-20,eg[im],XOR_PUT);
                  xpos=x;
                  ypos=y;
                  if(stop)
                  {
                           im=0;
                           fall=false;
                  }
                  if(im>=8)
                    im=0; 
                  putimage(xpos-22,ypos-20,eg[im],XOR_PUT);
}
void egg::rotate(){
                  if(im>=8)
                      im=0;
                  else
                      im++;
                  }
void egg::jumpfirst(){
                  t=0;
                  turn=0;
                  stop=false;
                  fall=false;
                  y_ini=ypos;
                  int sndcur=0;
                  }
int egg::gettimes(int base,int targety,bool fallin){
                 int tempt=0;
                 int tempy=base;
                 int y=base;
                 bool fal=false;
                 do{
                     tempt+=dt;
                     y=(int)(tempy-u*tempt+.5*gv*tempt*tempt);
                     float dy=(u-.5*gv*(2*tempt+1));
                     if(fallin){  
                        if(dy<0)fal=true;
                        }
                     else fal=true;
                     if(abs(y)>MaxY)
                        break;           
                 }while(abs(y-targety)>7||!fal);
                 return(tempt/dt);
                 }
int egg::gettimes(int base,int targety){
                 return(gettimes(ypos,targety,true));
                 }
int egg::gettimes(int targety){
                 return(gettimes(ypos,targety,true));
                 }   
int egg::getmaxy(){
                 int tempt=0;
                 int tempy=ypos;
                 int y=ypos;
                 bool fal=false;
                 do{
                     tempt+=dt;
                     y=(int)(tempy-u*tempt+.5*gv*tempt*tempt);
                     float dy=(u-.5*gv*(2*tempt+1));
                     if(dy<0)fal=true;
                     if(abs(y)>MaxY)
                        break;
                 }while(!fal);
                 return(y);
                 }
void egg::jump(){
                  t+=dt;
                  if(im>=8)
                    im=0; 
                  putimage(xpos-22,ypos-20,eg[im],XOR_PUT);
                  float dy=(u-.5*gv*(2*t+1));
                  ypos=(int)(y_ini-u*t+.5*gv*t*t);
                  if(dy<0)fall=true;
                  else fall=false;
                  if((y_ini-ypos)>115){
                  if(ypos>=y_ini){}
                  else if(turn>1){rotate();turn=0;}
                  else if(turn<=1)turn++;
                  else im=0;
                  }
                  else{
                       if(fall){
                       if((im%8)!=0 ){
                       if(turn>1){
                              im++;
                              turn=0;
                              }
                       else
                           turn+=1;
                           }
                       else
                           im=0;
                           }
                           }
                  im=im%8;
                  putimage(xpos-22,ypos-20,eg[im],XOR_PUT);
                  }
void egg::superjump(int x_ini,int y_ini,int space){
                  t+=dt;
                  if(im>=8)
                    im=0; 
                  putimage(xpos-22,ypos-20,eg[im],XOR_PUT);
                  xpos+=int(ceil(space));
                  ypos=(int)(y_ini-u*t+.5*gv*t*t);
                  float dy=(u-.5*gv*(2*t+1));
                  if(dy<0)fall=true;
                  if((y_ini-ypos)>43){
                  if(ypos>=y_ini){}
                  else if(turn>2){rotate();turn=0;}
                  else if(turn<=2)turn++;
                  }
                  else{
                       if((im%8)!=0 ){
                       if(turn>1){
                              im++;
                              turn=0;
                              }
                       else
                           turn++;
                           }
                       else
                           im=0;
                           }
                  im=im%8; 
                  putimage(xpos-22,ypos-20,eg[im],XOR_PUT);
                  }
bool egg::eat(food &a)
{
                  if(abs(xpos-a.x)<10&&abs(ypos-a.y)<10)
                         return (true); 
                  else
                       return (false);                        
}




foodstatus::foodstatus():x(5),y(150),wid(200),hig(250),shadow(30){}
void foodstatus::initialize(){
                  x=5;y=150;wid=200;hig=250;shadow=30; 
                  //set initials...........
                  x=5;
                  y=150;
                  //background..
                  for(int i=0;i<hig/2+1;i++){
                  setfillstyle(1,COLOR(255-i,2*i/5,i*2+5));
                  bar(x,y+i,x+wid,y+2*i);
                  }
                  setfillstyle(1,0);
                  bar(x+wid*2/40,y+hig*2/40,x+wid*39/40,y+hig*39/40);
                  setfillstyle(11,COLOR(250,20,100));
                  bar(x+wid/40,y+hig/40,x+wid*38/40,y+hig*38/40);
                  wid-=10;hig-=10;x+=5;y+=5;
                  int bcol=COLOR(20,90,50);
                  setfillstyle(1,bcol);
                  bar(x+wid/40,y+hig/40,x+wid*38/40,y+hig*38/40);
                  setbkcolor(bcol);
                  settextstyle(3,HORIZ_DIR,2);
                  outtextxy(x+10,y+5,"Power status.");
                  setbkcolor(0);
                  settextstyle(3,HORIZ_DIR,1);
                  x+=5;y+=25;
                  setcolor(COLOR(255,10,100));
                  setfillstyle(1,0);
                  settextjustify(LEFT_TEXT,TOP_TEXT);
                  char titl[4][10]={"AutoThrow","SmartAuto","Stop","HyperJump"};
                  for (int i=0;i<4;i++){
                  putimage(x+5,y+20+i*40,food::fud[i],COPY_PUT);
                  rectangle(x+5,y+20+i*40,x+5+31,y+20+i*40+31);
                  bar(x+45,y+20+i*40,x+160,y+20+i*40+31);
                  outtextxy(x+45,y+20+i*40,titl[i]);
                  stat[i][0]=x+45;
                  stat[i][1]=y+20+i*40;
                  }
                  //set first foods.........
                  status[0]=3;
                  status[1]=1;
                  status[2]=25;
                  status[3]=2;
                  }
void foodstatus::refresh(){
                  int k;
                  int g=getcolor();
                  for(int i=0;i<4;i++){
                  setcolor(COLOR(255,10,100));
                  setlinestyle(0,0,1);
                  setfillstyle(1,0);
                  bar(stat[i][0],stat[i][1]+16,stat[i][0]+115,stat[i][1]+31);
                  setfillstyle(1,COLOR(50,255,50));
                  if(status[i]>0){
                  if(i==2){     
                     bar(stat[i][0]+5,stat[i][1]+18,stat[i][0]+int(round(status[i])+5),stat[i][1]+25);
                     rectangle(stat[i][0]+5,stat[i][1]+18,stat[i][0]+105,stat[i][1]+25);           
                     }
                  else{
                      for(int j=0;j<status[i];j++){
                         k=stat[i][0]+(10*j)+5;
                         bar(k,stat[i][1]+18,k+5,stat[i][1]+29);
                         }
                         }
                     }
                  else{
                     setbkcolor(0);
                     setcolor(COLOR(100,255,10));
                     settextstyle(0,HORIZ_DIR,2); 
                     settextjustify(LEFT_TEXT,TOP_TEXT);
                     outtextxy(stat[i][0],stat[i][1]+15,"Empty");
                     }
                    }
                   setlinestyle(0,0,2);
                   setcolor(g);
                    }
void foodstatus::inc(int i){
                  int k;
                  if(i==2){     
                     status[i]+=50;     
                     status[i]=(status[i]<100)?status[i]:100;     
                     }
                  else{
                    status[i]++;
                    status[i]=(status[i]<5)?status[i]:5;
                     }
                  refresh();
                  }
void foodstatus::dec(int i){
                  if(status[i]>0){
                     if(i==2&&status[i]<=4)
                        status[i]=0;
                    else
                     status[i]--;
                    }
                  refresh();
                  }
int foodstatus::getstat(int i){
                  return status[i];
                  }
int foodstatus::statx(int i){
                  return stat[i][0]-40;
                } 
int foodstatus::staty(int i)
{
                  return stat[i][1];
}


//food......................................................................................       
food::food():x(100),y(50),fudnum(4),yspd(5){}
void food::draw(){
                  x=100;
                  y=50;
                  yspd=5;
                  fudnum=4;
                  int a[22];
                  float ang=198;
                  int rad;
                  int color[2];
                  color[0]=COLOR(255,50,50);
                  color[1]=COLOR(10,50,255);
                  //star.....(red)...&...(blue).........
                  for(int i=0;i<2;i++){
                    for(int k=15;k>0;k-=2){
                  for(int j=0;j<20;j+=2,ang+=36){
                      if(j%4<2)
                         rad=k;
                      else
                         rad=k/3; 
                      a[j]=(int)(x+rad*cos(ang/180*M_PI));
                      a[j+1]=(int)(y+rad*sin(ang/180*M_PI));
                          }
                  a[20]=a[0];
                  a[21]=a[1];
                  int col=COLOR((1-i)*255,(15-k)*17,i*255);
                  setcolor(col);
                  setlinestyle(0,0,1);
                  moveto(a[0],a[1]);
                  drawpoly(11,a); 
                  setfillstyle(1,(col));
                  fillpoly(11,a);
                  }
                  size = imagesize(x-16,y-16,x+16,y+16);//measure size
                  fud[i] = malloc(size);             /*allocate memory space*/                 
                  getimage(x-16,y-16,x+16,y+16,fud[i]);/* grab the image */
                  x+=50;
                  }
                  //clock..........................
                  setlinestyle(0,0,1);
                  fillellipse(int(x+17*cos(120*M_PI/180)),int(y-17*sin(120*M_PI/180)),2,2);
                  fillellipse(int(x+17*cos(60*M_PI/180)),int(y-17*sin(60*M_PI/180)),2,2);
                  setfillstyle(1,4);
                  setlinestyle(0,0,1);
                  fillellipse(x,y,13,13);
                  setcolor(4);
                  setfillstyle(1,11);
                  fillellipse(x,y,10,10);
                  setcolor(1);
                  setlinestyle(0,0,1);
                  moveto(x-1,y);
                  lineto(x-1,y-10);
                  moveto(x,y);
                  lineto(x+7,y);
                  size = imagesize(x-16,y-18,x+16,y+14);//measure size
                  fud[2] = malloc(size);             /*allocate memory space*/                 
                  getimage(x-16,y-18,x+16,y+14,fud[2]);/* grab the image */
                  x+=50;
                  //hyperjump.........................
                  setcolor(COLOR(200,0,20));
                  setlinestyle(0,0,3);
                  int col=COLOR(50,250,10);
                  setfillstyle(1,col);
                  fillellipse(x,y,13,13);
                  setbkcolor(col);
                  setcolor(COLOR(20,0,200));
                  settextjustify(CENTER_TEXT,TOP_TEXT);
                  settextstyle(0,HORIZ_DIR,2);
                  outtextxy(x,y-7,"H");
                  size = imagesize(x-16,y-16,x+16,y+16);//measure size
                  fud[3] = malloc(size);             /*allocate memory space*/                 
                  getimage(x-16,y-16,x+16,y+16,fud[3]);/* grab the image */
                  setbkcolor(0);
                  x+=-100;y+=80;
                  //blasting..........................
                  int tmp;
                  for(int j=0;j<7;j++){
                  setcolor(15);
                  tmp=60;     
                  for(int i=j*3;i<(j+1)*10;i+=2){
                          ang=rand()%(360)*M_PI/180;
                          putpixel(int(x+i*cos(ang)),int(y+i*sin(ang)),rand()%5+11);
                          }
                  tmp=60;
                  size = imagesize(x-tmp,y-tmp,x+tmp,y+tmp);//measure size
                  blast[j] = malloc(size);             /*allocate memory space*/                 
                  getimage(x-tmp,y-tmp,x+tmp,y+tmp,blast[j]);/* grab the image */
                  x+=95;
                  showin=false;
                  }
                  }
void food::setfood(int foodnum,int xi,int yi){
                  x=xi;
                  y=yi;
                  fudnum=foodnum;
                  erased=false;
                  showin=true;
                  eaten=false;
                  blstnum=0;
                  putimage(x-15,y-15,fud[fudnum],COPY_PUT);
                  putimage(x-15,y-15,fud[fudnum],COPY_PUT);
                  putimage(x-15,y-15,fud[fudnum],COPY_PUT);
                  }
void food::del(){     
                 putimage(x-15,y-15,fud[fudnum],XOR_PUT);
                 }
void food::blst(){
                 if(blstnum<7)
                 putimage(x-60,y-60,blast[blstnum],XOR_PUT);
                 blstnum++;
                 if(blstnum>6)
                    if(!erased){
                                blstnum=0;
                                erased=true;
                                }
                    else
                        showin=false;
                 }
void food::clear(){
                erased=true;
                showin=false;
                timeout=0;
            }
int food::foodnum()
            {
                return fudnum;
            }
void food::sety(int ys){
            y=ys;
            }
void food::show(int xx,int yy,int i)
            {
                int g=getcolor();
                setcolor(COLOR(255,10,100));
                putimage(xx,yy,fud[i],COPY_PUT);
                rectangle(xx-1,yy-1,xx+1+31,yy+1+31);
                setcolor(g);
            }
void food::slidedown()
            {
                 putimage(x-15,y-15,fud[fudnum],XOR_PUT);
                 y+=yspd;
                 putimage(x-15,y-15,fud[fudnum],XOR_PUT);
     


  
5.highscore.cpp 




#include<iostream>
#include<fstream>
#include <graphics.h>
#include "mainmenu.h"
#include "highscores.h"
#include "classes.h"
#define red COLOR(255,0,0)
#define green COLOR(0,255,0)
#define blue COLOR(0,100,255)
#define lightblue COLOR(95,112,220)


using namespace std;


TButton scoreback;


int showHighscores()
{
    clearviewport();


    scoreback.settextpara("BACK",120-textwidth("back")/2,450);
    registermousehandler(WM_LBUTTONDOWN,scoreclick_handler);
    outtextxy(400-textwidth("SCOREBOARD")/2,10,"SCOREBOARD");
    scoreback.display(blue);
    setcolor(15);
    settextstyle(DEFAULT_FONT,HORIZ_DIR,0);
    int h=textheight("h");
    int xx=400-150;
    outtextxy(xx,100,"Player");
    moveto(xx,100+h);
    lineto(xx+textwidth("player"),100+h);                  //to draw underline
    outtextxy(xx+250,100,"Score");
    moveto(xx+250,100+h);
    lineto(xx+250+textwidth("score"),100+h);
    fstream file;
    file.open("scoreboard.txt",ios::in|ios::binary);
    player plyr[10];
    if(file)
       {
            file.read((char*)plyr,sizeof(plyr));
            for(int i=0;i<10;i++)
            {
                bgiout<<i+1<<'.';
                if(i==9)
                    outstreamxy(xx-10,110+h+i*25);
                else
                    outstreamxy(xx,110+h+i*25);
                outtextxy(xx+22,110+h+i*25,plyr[i]._name());
                bgiout<<plyr[i]._score();
                outstreamxy(xx+250+20,110+h+i*25);
            }
        file.close();
        }
    char c;
    bool finish=false;
    do
    {
        if(kbhit())
        {
            c=getch();
            if(c==27)
                scoreback.click=true;
        }


        if(scoreback.ismouseover())
            scoreback.onmouseover();
        if(scoreback.rollout && !scoreback.mouseover)
                scoreback.onrollout();
        if(scoreback.click)
        {
            scoreback.onclick();
            return 0;
        }
       
        delay(10);
    }while(!finish);
    return 0;
}
void scoreclick_handler(int x, int y)
{
    scoreback.isclick();
}




6.instructions.cpp




#include<iostream>
#include <graphics.h>
#include "mainmenu.h"
#include "instructions.h"
#include "metallic.h"
#include "classes.h"
#define red COLOR(255,0,0)
#define green COLOR(0,255,0)
#define blue COLOR(0,65,255)
#define lightblue COLOR(95,112,220)
using namespace std;


TButton instback;


int showInstructions()
{
    //setactivepage(0);
    //setvisualpage(0);
    int gp=getactivepage();
    clearviewport();
    struct viewporttype vp;
    getviewsettings(&vp);
    instback.settextpara("BACK",200-textwidth("back")/2,450);    //draw back button
   
    registermousehandler(WM_LBUTTONDOWN,instclick_handler);
    settextjustify(LEFT_TEXT,TOP_TEXT);
    setcolor(green);
    settextstyle(BOLD_FONT,0,5);
    outtextxy(400-textwidth("instructions")/2,10,"INSTRUCTIONS");
   
    setcolor(15);
    settextstyle(SANS_SERIF_FONT,0,1);
    int h=textheight("h");
    int i=1;
    int x=50;
    int y=50;
    outtextxy(x,y,"Use your left mouse click to make the egg in the basket to jump. Make sure that the egg stays on");
    outtextxy(x,y+h,"the upper basket as it lands. When you miss to put egg on upper basket or the egg doesnot find");
    outtextxy(x,y+i*h,"any basket on its falling way, then the devine basket appears on the bottom of gamefield to save ");i++;
    outtextxy(x,y+i*h,"the egg and your devine basket number will decrease by one");i++;
    i++;
   
    setcolor(green);
    outtextxy(x,y+i*h,"FOOD AND OBSTACLE");i++;
    setcolor(15);
    outtextxy(x,y+i*h,"AutoThrow :  If you have this, you can activate this by clicking on its icon. Activation is signalled by");i++;
    food::show(x,y+i*h,0);   
    outtextxy(x+textwidth("AutoThrow :  "),y+i*h,"blinking rectangle around the icon. This enables the computer intelligence");i++;
    outtextxy(x+textwidth("AutoThrow :  "),y+i*h,"to decide when to throw the egg so that the egg stays on the upper basket.");i++;
   
    outtextxy(x,y+i*h,"SmartAuto :  You can activate this by clicking on its icon. Activation is signalled by blinking rectangle");i++;
    food::show(x,y+i*h,1); 
    outtextxy(x+textwidth("SmartAuto :  "),y+i*h,"around the icon. This enables the computer intelligence to decide when to throw");i++;
    outtextxy(x+textwidth("SmartAuto :  "),y+i*h,"the egg in addition to sensing the obstacle on its way.");i++;
   
    outtextxy(x,y+i*h,"Clock :            If you have this, you can stop the basket on which the egg stays by pressing 'SHIFT' key");i++;
    food::show(x,y+i*h,2); 
    outtextxy(x+textwidth("Clock :            "),y+i*h,"and in the meantime the clock availability bar decreases. Be sure that the basket doesnot");i++;
    outtextxy(x+textwidth("Clock :            "),y+i*h,"keep stopping while you click to make the egg jump. ");i++;
   
    outtextxy(x,y+i*h,"HyperJump :  You can activate this by clicking on its icon. Activation is signalled by a rectangle");i++;
    food::show(x,y+i*h,3); 
    outtextxy(x+textwidth("HyperJump :  "),y+i*h,"around the icon. Activating this you can throw the egg twice much higher.");i++;i++;
   
    outtextxy(x,y+i*h,"Obstacle :");
   
    outtextxy(x+textwidth("Obstacle :  "),y+i*h,"The obstacle causes egg to bounce back if the egg strikes it when jumping. ");i++;
    putimage(x,y+i*(h),obstcl::obs,XOR_PUT);
    putimage(x+20+1,y+i*(h),obstcl::pic[0],XOR_PUT);
    putimage(x+60+20,y+i*(h),obstcl::obs,XOR_PUT);


//==================================================
   
    instback.display(blue);
    char c;
    bool finish=false;
    do
    {
        if(kbhit())
        {
            c=getch();
            if(c==27)
                instback.click=true;
        }
        if(instback.ismouseover())
            instback.onmouseover();
        if(instback.rollout && !instback.mouseover)
                instback.onrollout(); 
        if(instback.click)
        {
            instback.onclick();
                return 0;
        }
       
        delay(25);
    }while(!finish);
    //setactivepage(0);
    //setvisualpage(0);
    return 0;
}
void instclick_handler(int x, int y)
{
    instback.isclick();
}


7.loadgame.cpp




//165
#include <iostream>
#include <fstream>
#include <graphics.h>
#include <math.h>
#include "mainmenu.h"
#include "loadgame.h"
#include "classes.h"


#define barcolor COLOR(236,233,216)
#define tcolor COLOR(250,250,250)
#define bcolor COLOR(182,178,163)
#define blue COLOR(0,65,255)
using namespace std;
void loadclick_handler(int x,int y);
void loadrelease_handler(int x,int y);
boundbtn label[10];
TButton loadback;
int Loadgame()
{
    clearviewport();
    settextstyle(10,0,5);
    setcolor(COLOR(0,255,0));
    outtextxy(350,10,"LOAD");
    loadback.settextpara("BACK",120-textwidth("back")/2,450);
    registermousehandler(WM_LBUTTONDOWN,loadclick_handler);
    registermousehandler(WM_LBUTTONUP,loadrelease_handler);
    loadback.display(blue);
    settextstyle(3,HORIZ_DIR,1);
    setfillstyle(1,barcolor);
    int xpos=200;
    int ypos=80;
    int width=420;
    int height=350;
   
    setbkcolor(barcolor);
    showmsg(xpos-4,ypos-4,width+8,height+8,0);             //draw a rectangle to show loding option
    bar(xpos,ypos,xpos+width,ypos+height);
    setcolor(0);
    settextstyle(3,HORIZ_DIR,1);   
    outtextxy(xpos+20,ypos+20,"Player");
    outtextxy(xpos+20+150,ypos+20,"Level");
    outtextxy(xpos+20+150+70,ypos+20,"Score at level complete");
    fstream file;
    player plyr[10];
    player p2;
    file.open("gamedata.txt",ios::in|ios::binary);
    int n=0;
    if(file)
       {
            file.seekg(0,ios::end);
            n=file.tellg()/sizeof(plyr[0]);
            file.seekg(0,ios::beg);
            for(int i=0;i<n;i++)
            {
                file.read((char*)&plyr[i],sizeof(plyr[0]));
                plyr[i].show();
            }
            file.close();
        }
    file.open("gamedata.txt",ios::in|ios::binary);
    height=textheight("h");
    xpos+=20;
    ypos+=40;
    for(int i=0;i<n;i++)
    {
        label[i].set(xpos,ypos+i*height+i*10,width-50,height);
        label[i].outtext(plyr[i]._name(),0,false);
        label[i].outtext(xpos+15+150,ypos+i*height+i*10,plyr[i]._level());
        label[i].outtext(xpos+50+150+70,ypos+i*height+i*10,plyr[i]._score());
    }
     char c;    
     bool finish=false;
    do
    {
        if(kbhit())
        {
            c=getch();
            if(c==27)
                loadback.click=true;
        }
        for(int i=0;i<10;i++)
        {
            if(label[i].ismouseover())
            {
                if(label[i].click)
                {
                    label[i].drawborder(bcolor,tcolor);
                    label[i].click=false;
                }
                else if(label[i].release)
                {
                    label[i].drawborder(tcolor,bcolor);
                    label[i].release=false;
                    nowplayer=plyr[i];
                    gameplay();
                    return 1;
                }
                else if(label[i].rollover)
                {
                    label[i].drawborder(tcolor,bcolor);
                    label[i].rollover=false;
                }
            }
            else if(label[i].rollout)
            {
                label[i].drawborder(barcolor,barcolor);
                label[i].rollout=false;
            }
           
        }
        if(loadback.ismouseover())
            loadback.onmouseover();
        if(loadback.rollout && !loadback.mouseover)
                loadback.onrollout();
        if(loadback.click)
        {
            loadback.onclick();
            setbkcolor(0);
            return 0;
        }
        delay(1);
    }while(!finish);
    getch();
    return 0;
}


void loadclick_handler(int x,int y)
{
    for(int i=0;i<10;i++)
    {
        if(label[i].ismouseover())
        {
            label[i].click=true;
            break;
        }
    }
    loadback.isclick();
}
void loadrelease_handler(int x,int y)
{
    for(int i=0;i<10;i++)
    {
        if(label[i].ismouseover())
        {
            label[i].release=true;
            break;
        }
    }
  
}


8.metallic.cpp





#include <cstring>
#include <iostream>
#include <graphics.h>
#include <math.h>
#include "metallic.h"
using namespace std;
       void metalbar::metallic(int x,int y,int width,int height,int r1,int g1,int b1,int r2,int g2,int b2)
        {
            int y1=y;
            int y2=y1+1;
            int incr=(r2-r1)/(height);
            int incg=(g2-g1)/(height);
            int incb=(b2-b1)/(height);
            for(int i=0;i<=height;i++)
            {
                setfillstyle(SOLID_FILL,COLOR(r1,g1,b1));
                bar(x,y1,x+width,y2);
                r1+=incr;
                g1+=incg;
                b1+=incb;
                y1=y2;
                y2+=1;
            }
        }
        void metalbar::border3d(int x,int y,int width,int height,int topcolor,int bottomcolor)
        {
            setlinestyle(SOLID_LINE, 0, 1);
            setcolor(topcolor);
            moveto(x,y+height);
            lineto(x,y);
            lineto(x+width,y);
            setcolor(bottomcolor);
            lineto(x+width,y+height);
            lineto(x,y+height);
        }
        metalbar::metalbar()
        {
            height=10+5+5+8+8;
            boxheight=height-14;
        }
        void metalbar::set(int xpos,int ypos,int wid)
        {
            x=xpos;
            y=ypos;
            width=wid;
        }
        void metalbar::drawbar(int xpos,int ypos,int wid)
        {


            int eachpart=10;
            int parts=int(ceil(float(wid)/eachpart));
            if(!instore)
            {
                x=xpos;//100;
                y=ypos;//100;
                int eachpart=10;
                metallic(x,y,eachpart,10,50,50,50,255,255,255);
                metallic(x,y+10,eachpart,5,255,255,255,255,255,255);
                metallic(x,y+10+5,eachpart,5,255,255,255,70,70,80);
                metallic(x,y+10+5+5,eachpart,8,70,70,80,155,155,160);
                metallic(x,y+10+5+5+8,eachpart,8,155,155,160,40,40,50);
                int size=imagesize(x,y,x+eachpart,y+height);
                barblock=malloc(size);
                getimage(x,y,x+eachpart,y+height,barblock);
                instore=true;
            }
            x=xpos;
            y=ypos;
            width=wid;
            boxy=height/2-boxheight/2;
            for(int i=0;i<parts;i++)
            {
                putimage(x+i*eachpart,y,barblock,0);
            }
        }
        void metalbar::embedboxntext(int xpos,int wid,int color,char label[])
        {
            border3d(xpos,y+boxy,wid,boxheight,COLOR(0,0,0),COLOR(210,210,210));
            setfillstyle(SOLID_FILL,color);
            bar(xpos+1,y+boxy+1,xpos+wid,y+boxy+boxheight);
            setcolor(0);
            setbkcolor(color);
            outtextxy(xpos+5,y+boxy+2,label);
        }
        void metalbar::changescore(int x,int bkcolor,int score)
        {
            settextjustify(LEFT_TEXT,TOP_TEXT);
            int c=getcolor();
            int b=getbkcolor();
            setcolor(0);
            setbkcolor(bkcolor);
            bgiout<<score;
            outstreamxy(x+5,y+boxy+2);
            setcolor(c);
            setbkcolor(b);
        }           


void* metalbar::barblock;
bool metalbar::instore=false;




9.playerinfo.cpp




#include <iostream>
#include <graphics.h>
#include <cstring>


#include "mainmenu.h"
#include "playerinfo.h"
#include "classes.h"


#define red COLOR(255,0,0)
#define green COLOR(0,255,0)
#define blue COLOR(0,100,255)
#define lightblue COLOR(95,112,220)


using namespace std;


void infoclick_handler(int x,int cy);


bool infoinitial=false;
const int imgnum=63;
void* image1, *box[imgnum];
char str[1][20],c;
TButton back,play;






void check()
{
    settextstyle(BOLD_FONT,HORIZ_DIR,5);
            if(back.ismouseover())
                back.onmouseover();
            else if(play.ismouseover())
                play.onmouseover();
            if(back.rollout && !back.mouseover)
                back.onrollout();
            if(play.rollout && !play.mouseover)
                play.onrollout();   
           
    settextstyle(GOTHIC_FONT,HORIZ_DIR,3);
}




void delaysharp(bool& broken)
{
    int count=0;
    while(count<50)
    {
        delay(10);
        if(kbhit() || back.click || play.click)
        {
            broken=true;
            return;
        }
        count++;
        check();
    }
    broken=false;
}
int EnterInfo()
{
    clearviewport();
    settextstyle(GOTHIC_FONT,HORIZ_DIR,2);
    setlinestyle(0,0,4);
    registermousehandler(WM_LBUTTONDOWN,infoclick_handler);
    settextjustify(LEFT_TEXT,TOP_TEXT);
    int midx=getmaxx()/2;
    int midy=getmaxy()/2;
   
    int w=500;
    int h=200;
    int rectx=midx-w/2;
    int recty=midy-h/2;
    int r=60;
    int borthick=4;
    int i=0;
    int j=0;
    int index=0;
    str[index][0]='\0';
    int count=0;
    bool broken=false;
    int x1,x2;
    int cx,cy;
    int parts=imgnum;
    int eachpart=10;


    if(!infoinitial)
    {
       
        //setactivepage(1);
        clearviewport();
        setcolor(green);


        arc(rectx,recty,90,180,r);
        moveto(rectx,recty-r);
        lineto(rectx+w,recty-r);


        arc(rectx+w,recty,0,90,r);
        moveto(rectx+w+r,recty);
        lineto(rectx+w+r,recty+h);
   
        arc(rectx+w,recty+h,270,360,r);
        moveto(rectx+w,recty+h+r);
        lineto(rectx,recty+h+r);


        arc(rectx,recty+h,180,270,r);
        moveto(rectx-r,recty+h);
        lineto(rectx-r,recty);


        setfillstyle(11,lightblue);
        floodfill(rectx+10,recty+10,green);


        setcolor(red);
        rectangle(rectx,recty+70,rectx+textwidth("name")+30,recty+70+textheight("h")+20);
        setfillstyle(SOLID_FILL,BLACK);
        floodfill(rectx+5,recty+75,red);


        setcolor(green);
        outtextxy(rectx+10,recty+70+20/2,"Name");
        int tx=rectx+textwidth("name")+30+20;
        int ty=recty+70;


        setcolor(red);
        rectangle(tx,ty,tx+390,ty+textheight("h")+20);
        floodfill(tx+5,ty+5,red);
        int cx=tx+10;
        int cy=ty+10;


        int size=imagesize(rectx-r-borthick,recty-r-borthick,rectx+w+r+borthick,recty+h+r+borthick);
        image1=malloc(size);
        getimage(rectx-r-borthick,recty-r-borthick,rectx+w+r+borthick,recty+h+r+borthick,image1);


       
        //----- for horizontal slide using vertical slice
        x1=rectx-r-borthick;
        x2=x1+eachpart;
        for(int i=0;i<parts;i++,x1=x2,x2+=eachpart)
        {
            size=imagesize(x1,recty-r-borthick,x2,recty+h+r+borthick);
            box[i]=malloc(size);
            getimage(x1,recty-r-borthick,x2,recty+h+r+borthick,box[i]);
        }
        clearviewport();
        infoinitial=true;
        return 0;
    }
    //=================================begin from here if already in store
    //setactivepage(0);
    //setvisualpage(0);
    x1=rectx-r-borthick;
    for(int i=0;i<parts;i++,x1+=eachpart)
    {
        putimage(x1,50,box[i],0);
        delay(10);
    }  
    cx=rectx+textwidth("name")+30+20+10;
    cy=50+r+70+15;  // first 50 is from putimage;
   
    setfillstyle(SOLID_FILL,0);
    setcolor(blue);
    char cur[2];
    cur[0]=134;
    cur[1]='\0';
    settextstyle(BOLD_FONT,HORIZ_DIR,5);
    back.settextpara("BACK",120-textwidth("back")/2,450);
    play.settextpara("PLAY",680-textwidth("play")/2,450);
    back.display(blue);
    play.display(blue);
   
    setcolor(15);
    settextstyle(GOTHIC_FONT,HORIZ_DIR,3);
    do
    {
       while(!kbhit())
        {
            setcolor(15);
            j=textwidth(str[index]);
            outtextxy(cx+j,cy-3,cur);
            delaysharp(broken);
              if(broken)
                  break;
            outtextxy(cx+j,cy-3,"  ");
                delaysharp(broken);
        }
        if(back.click)
        {
            back.onclick();
            return 0;
        }
        if(play.click)
        {
            play.onclick();
            return 1;
        }
        c=getch();
        if(c==8)
        {
            if(i<2)
                i=-1;
            else
                i-=2;
        }
        else if(c==13)
        {
            play.onclick();
            if(str[0][0]=='\0')
                nowplayer.namakaran("NoName");
            else
                nowplayer.namakaran(str[0]);
            nowplayer.updatescore(0);
            nowplayer.updatelevel(1);
            nowplayer.updaterank(15);
            return 1;
        }
        else if(c==27)
        {
            back.onclick();
            return 0;
        }
        else if((c>='0' && c<='9') || (c>='a' && c<='z') || (c>='A' && c<='Z'&& isKeyDown(VK_SHIFT)) || c=='.' || c==' '|| c=='_')
        {
            str[index][i]=c;
        }
        //else if(cc>=65
        else
        {
            i--;
        }
        setfillstyle(SOLID_FILL,0);
        floodfill(cx,cy,red);
        if(textwidth(str[index])<250)
            str[index][++i]='\0';
        else
            str[index][i]='\0';
        setcolor(15);
        outtextxy(cx,cy,str[index]);
    }while(c!=13);
    return 0;
}
void infoclick_handler(int x,int y)
{
    back.isclick();
    if(play.isclick())
    {
        if(str[0][0]=='\0')
            nowplayer.namakaran("NoName");
        else
            nowplayer.namakaran(str[0]);
        nowplayer.updatescore(0);
        nowplayer.updatelevel(1);
        nowplayer.updaterank(15);
        play.click=true;
    }


}

1 comment: