source code to create pacman type game using C++

0

Category:

#include
#include
#include
#include
#include
#include
#include
#include

#define MAXCHANCE 15

#define FOREST     0
#define DESERT     1
#define AQUAMARINE 2

#define UP    1
#define LEFT  2
#define DOWN  3
#define RIGHT 4


int  Glutton_Game_Loop();
void Welcome();
void Draw_Game_Screen_of_Selected_Skin();
void Init_Glutton_Squares();
void Sound_Mode_Conversion();
void Sound_Glutton_Catches_Demon();
void Draw_Dots();
int  Check_For_Level_Completion();
int  Column_Detector(int);
int  Row_Detector(int);
void Scorer(unsigned long int,int);
void Speed_Skin_Menu();
void Start_Play();
void Memory_Provider();
void Draw_Main_Screen();
void Ask_For_Exit();
void Pause_The_Game();
void Switcher(int,int,int);
void Glutton_Gets_Caught();
int  Glutton_Director();
void Demon_Director(int,int,int);
void Glutton_Catches_Demon_in_Mode2(int);
void Blink_Dots(int,int,int,int,int);
void Glutton_Gets_Power();
void Glutton_Loses_Power();
void Demon_Director();
void Bonus_Awarder();

char *Glut_Face_1,*Glut_Face_2,*Glut_Face_3,*Blank_Replacer,*Dot_Replacer,*Glut_Power;
char *Demon[3];
int Memory_Allocator=1;
int Glutton_Squares[289],Dot_Squares[289],Demon_Squares[289];
int Curr_Pos_Glut=149;
int chance=MAXCHANCE;
int Demon_Cell_Color=1;
int Level=1,Dot_Color=LIGHTGREEN;
int Power_Dot_Status_1=1,Power_Dot_Status_2=1,Power_Dot_Status_3=1,Power_Dot_Status_4=1;
long Score=0,Speed;
int Skin=0,Bkgd_Color=0;
int x,y;
union REGS ii,oo;

int Column_Number,Row_Number;

int Dir_Demon[3];
int Curr_Pos_Demon[3];
int d_txt[3],d_tyt[3];
int Demon_Column_Number[3],Demon_Row_Number[3];
int tyt=0,txt=0;
int Direction=1;
int Direction_m=0;
int Power_Mode_Timer=0,loop=0;
int Glutton_Mode=1;
int Bonus_Counter=0;
int Bonus=0;

void Var_Initializer()
{
    Curr_Pos_Glut=149;
    Curr_Pos_Demon[0]=142;
    Curr_Pos_Demon[1]=144;
    Curr_Pos_Demon[2]=144;
    d_tyt[0]=2;
    d_txt[0]=0;
    d_tyt[1]=2;
    d_txt[1]=0;
    d_tyt[2]=2;
    d_txt[2]=0;
    tyt=0;
    txt=0;
    Direction=1;
    Direction_m=0;
    Power_Mode_Timer=0;
    loop=0;
    Glutton_Mode=1;
}

void main()
{
 int d=DETECT,m;
  initgraph(&d,&m,"");

  x=getmaxx()/2;
  y=getmaxy()/2;

 Welcome();

 Speed_Skin_Menu();
 cleardevice();
 Start_Play();
 closegraph();
}


int Glutton_Game_Loop()
{
  union REGS ii,oo;
  int x,y;
    x=getmaxx()/2+45;
    y=getmaxy()/2;

 int get;

 setcolor(WHITE);
 setfillstyle(SOLID_FILL,WHITE);

 Var_Initializer();

 if(Memory_Allocator==1)
 {
 Init_Glutton_Squares();
 Draw_Game_Screen_of_Selected_Skin();
 Memory_Provider();
 }

 if(chance==MAXCHANCE)
     Init_Glutton_Squares();

 Draw_Dots();
 Draw_Main_Screen();
 Demon_Director();


while(1)
{
    loop++;

    settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
    outtextxy(x-340,y-188-6,"Score");
    Scorer(Score,1);

    Blink_Dots(loop,Power_Dot_Status_1,Power_Dot_Status_2,Power_Dot_Status_3,Power_Dot_Status_4);

    if((Curr_Pos_Glut==Curr_Pos_Demon[0]||Curr_Pos_Glut==Curr_Pos_Demon[1]||Curr_Pos_Glut==Curr_Pos_Demon[2])&&Glutton_Mode==1)
    {
    Glutton_Gets_Caught();
    return 0;
    }

    Glutton_Catches_Demon_in_Mode2(Glutton_Mode);

    get=Glutton_Director();
    if(get==1)    return 1;

    Glutton_Gets_Power();

    if((Curr_Pos_Glut==Curr_Pos_Demon[0]||Curr_Pos_Glut==Curr_Pos_Demon[1]||Curr_Pos_Glut==Curr_Pos_Demon[2])&&Glutton_Mode==1)
    {
    Glutton_Gets_Caught();
    return 0;
    }

    Glutton_Catches_Demon_in_Mode2(Glutton_Mode);


    if(loop==10)
    {
    putimage(x-12-27,y-12,Blank_Replacer,0);
    putimage(x-12,y-12,Demon[1],0);
    }
    if(loop==11)
    {
    if(Glutton_Mode==2||loop==11)
        putimage(x-12,y-12,Blank_Replacer,0);
    putimage(x-12,y-12-27,Demon[1],0);
    }

    if(loop==22)
    {
    putimage(x-12+27,y-12,Blank_Replacer,0);
    putimage(x-12,y-12,Demon[2],0);
    }
    if(loop==23)
    {
    if(Glutton_Mode==2||loop==23)
        putimage(x-12,y-12,Blank_Replacer,0);
    putimage(x-12,y-12-27,Demon[2],0);
    }

    if(Glutton_Mode==1||loop%2==0)
    {
    if(loop==1||Curr_Pos_Demon[0]==144)
    {
        putimage(x-12,y-12,Blank_Replacer,0);
        Curr_Pos_Demon[0]=142;
    }

    Switcher(Dir_Demon[0],Glutton_Mode,0);
    Demon_Director(0,Column_Number,Row_Number);

    if(loop>=12)
    {
        if(loop==12||Curr_Pos_Demon[1]==144)
        {
        putimage(x-12,y-12-27,Blank_Replacer,0);
        Curr_Pos_Demon[1]=142;
        }

        Switcher(Dir_Demon[1],Glutton_Mode,1);
        Demon_Director(1,Column_Number,Row_Number);

        if(loop>=24)
        {
        if(loop==24||Curr_Pos_Demon[2]==144)
        {
            putimage(x-12,y-12-27,Blank_Replacer,0);
            Curr_Pos_Demon[2]=142;
        }

        Switcher(Dir_Demon[2],Glutton_Mode,2);
        Demon_Director(2,Column_Number,Row_Number);
        }
    }

    if((Curr_Pos_Glut==Curr_Pos_Demon[0]||Curr_Pos_Glut==Curr_Pos_Demon[1]||Curr_Pos_Glut==Curr_Pos_Demon[2])&&Glutton_Mode==1)
    {
        Glutton_Gets_Caught();
        return 0;
    }

    }

    Glutton_Catches_Demon_in_Mode2(Glutton_Mode);
    Glutton_Loses_Power();

    Bonus_Awarder();

    delay(Speed);

    Scorer(Score,0);


    if(kbhit())
    {
        ii.h.ah=0;
        int86(22,&ii,&oo);
        if(oo.h.ah==1)
        {
            Ask_For_Exit();
        }
        if(oo.h.ah==28)
        {
          Pause_The_Game();
        }
        if(oo.h.ah==77)
        {
            if(Glutton_Squares[Curr_Pos_Glut+17]==1)
             {
                 Direction=4;
                 Direction_m=0;
             }
            else if(Glutton_Squares[Curr_Pos_Glut+17]==0)
             {
                 Direction_m=4;
             }
        }
        if(oo.h.ah==75)
        {
            if(Glutton_Squares[Curr_Pos_Glut-17]==1)
             {
                 Direction=2;
                 Direction_m=0;
             }
            else if(Glutton_Squares[Curr_Pos_Glut-17]==0)
             {
                 Direction_m=2;
             }
        }
        if(oo.h.ah==72)
        {
            if(Glutton_Squares[Curr_Pos_Glut-1]==1)
             {
                 Direction=1;
                 Direction_m=0;
             }
            else if(Glutton_Squares[Curr_Pos_Glut-1]==0)
             {
                 Direction_m=1;
             }
        }
        if(oo.h.ah==80)
        {
            if(Glutton_Squares[Curr_Pos_Glut+1]==1)
             {
                 Direction=3;
                 Direction_m=0;
             }
            else if(Glutton_Squares[Curr_Pos_Glut+1]==0)
             {
                 Direction_m=3;
             }
        }
    }

    if(Direction_m==1&&Glutton_Squares[Curr_Pos_Glut-1]==1)
    Direction=1;
    if(Direction_m==2&&Glutton_Squares[Curr_Pos_Glut-17]==1)
    Direction=2;
    if(Direction_m==3&&Glutton_Squares[Curr_Pos_Glut+1]==1)
    Direction=3;
    if(Direction_m==4&&Glutton_Squares[Curr_Pos_Glut+17]==1)
    Direction=4;

}

}

void Draw_Game_Screen_of_Selected_Skin()
{
int x,y;
x=getmaxx()/2+45;
y=getmaxy()/2;

int g,h,M_col=14;

if(Skin==DESERT)
{
    setfillstyle(SOLID_FILL,1);
    bar(x-230,y-230,x+230,y+230);
    for(g=x-230;g
    for(h=y-230;h
        putpixel(g,h,M_col);
    for(g=x-230;g
    for(h=y-230;h
        putpixel(g+1,h+1,M_col);
}
else if(Skin==AQUAMARINE)
{
    M_col=CYAN;
    setfillstyle(SOLID_FILL,LIGHTBLUE);
    bar(x-230,y-230,x+230,y+230);
}
else
;

    setlinestyle(SOLID_LINE,1,3);
    line(x-216-14,y-216-14,x+216+14,y-216-14);
    line(x+216+14,y-216-14,x+216+14,y+216+14);
    line(x+216+14,y+216+14,x-216-14,y+216+14);
    line(x-216-14,y+216+14,x-216-14,y-216-14);
    setlinestyle(SOLID_LINE,1,1);

    if(Skin==AQUAMARINE)
    setfillstyle(SOLID_FILL,BLUE);
    else if(Skin==DESERT)
    setfillstyle(SOLID_FILL,8);
    else
    setfillstyle(3,7);

    for(int l=0;l<17;l++)
    {
    line(x-216-14,y-14-216+l*27,x+216+14,y-216-14+l*27);
    line(x+216+14-l*27,y-14-216,x+216+14-l*27,y+14+216);
    }
      for(l=0;l<288;l++)
      if(Glutton_Squares[l]==0&&l!=143&&l!=144&&l!=161&&l!=127)
      {
        floodfill(x-216+27*(l/17),y-216+27*(l%17),WHITE);
      }

  setfillstyle(1,Demon_Cell_Color);
  floodfill(x-25,y+25,15);
  floodfill(x-25-27,y+25,15);
  floodfill(x-25,y+25-27*2,15);
  floodfill(x-25-27,y+25-27,15);
  floodfill(x-25-27,y+25-27*2,15);
  floodfill(x-25+27,y+25,15);
  floodfill(x-25+27*2,y+25,15);
  floodfill(x-25+27*2,y+25-27*2,15);
  floodfill(x-25+27*3,y+25,15);
  floodfill(x-25+27*3,y+25-27,15);
  floodfill(x-25+27*3,y+25-27*2,15);


  if(Skin==AQUAMARINE)        setcolor(LIGHTBLUE);
  else if(Skin==DESERT)        setcolor(7);
  else                setcolor(0);

  for(l=0;l<17;l++)
  {
      line(x-216-14,y-14-216+l*27,x+216+14,y-216-14+l*27);
      line(x+216+14-l*27,y-14-216,x+216+14-l*27,y+14+216);
  }
  setcolor(8);
  setlinestyle(SOLID_LINE,1,3);
  line(x-148,y-16,x-121,y-16);
  line(x-148,y+15,x-121,y+15);
  line(x-121,y-16,x-121,y+15);
  line(x+148,y-16,x+121,y-16);
  line(x+148,y+15,x+121,y+15);
  line(x+121,y-16,x+121,y+15);
  setcolor(7);
  line(x-216-14,y-216-14,x+216+14,y-216-14);
  line(x+216+14,y-216-14,x+216+14,y+216+14);
  line(x+216+14,y+216+14,x-216-14,y+216+14);
  line(x-216-14,y+216+14,x-216-14,y-216-14);
  setlinestyle(SOLID_LINE,1,1);
}

void Init_Glutton_Squares()
{
for(int n=0;n<289;n++)
Glutton_Squares[n]=0;

for(n=0;n<17;n++)       Glutton_Squares[n]=1;

Glutton_Squares[17]=1;Glutton_Squares[20]=1;Glutton_Squares[25]=1;
Glutton_Squares[30]=1;Glutton_Squares[33]=1;Glutton_Squares[34]=1;Glutton_Squares[36]=1;
Glutton_Squares[37]=1;Glutton_Squares[38]=1;Glutton_Squares[40]=1;Glutton_Squares[41]=1;
Glutton_Squares[42]=1;Glutton_Squares[43]=1;Glutton_Squares[44]=1;Glutton_Squares[46]=1;
Glutton_Squares[47]=1;Glutton_Squares[48]=1;Glutton_Squares[50]=1;Glutton_Squares[51]=1;
Glutton_Squares[52]=1;Glutton_Squares[53]=1;Glutton_Squares[55]=1;Glutton_Squares[56]=1;
Glutton_Squares[57]=1;Glutton_Squares[59]=1;Glutton_Squares[61]=1;Glutton_Squares[62]=1;
Glutton_Squares[63]=1;Glutton_Squares[65]=1;Glutton_Squares[66]=1;Glutton_Squares[67]=1;
Glutton_Squares[69]=1;Glutton_Squares[72]=1;Glutton_Squares[74]=1;Glutton_Squares[78]=1;
Glutton_Squares[80]=1;Glutton_Squares[83]=1;Glutton_Squares[86]=1;Glutton_Squares[87]=1;

for(n=89;n<=97;n++)     Glutton_Squares[n]=1;

Glutton_Squares[99]=1;Glutton_Squares[100]=1;

for(n=104;n<=106;n++)   Glutton_Squares[n]=1;

Glutton_Squares[108]=1;Glutton_Squares[112]=1;

for(n=114;n<=116;n++)   Glutton_Squares[n]=1;

for(n=119;n<=121;n++)    Glutton_Squares[n]=1;

Glutton_Squares[123]=1;Glutton_Squares[125]=1;Glutton_Squares[129]=1;

for(n=133;n<=136;n++)    Glutton_Squares[n]=1;
for(n=140;n<=142;n++)   Glutton_Squares[n]=1;
for(n=146;n<=150;n++)   Glutton_Squares[n]=1;
for(n=152;n<=155;n++)   Glutton_Squares[n]=1;

Glutton_Squares[157]=1;Glutton_Squares[159]=1;Glutton_Squares[163]=1;

for(n=167;n<=169;n++)   Glutton_Squares[n]=1;
for(n=172;n<=174;n++)   Glutton_Squares[n]=1;

Glutton_Squares[176]=1;Glutton_Squares[180]=1;

for(n=182;n<=184;n++)   Glutton_Squares[n]=1;

Glutton_Squares[188]=1;Glutton_Squares[189]=1;

for(n=191;n<=199;n++)   Glutton_Squares[n]=1;

Glutton_Squares[201]=1;Glutton_Squares[202]=1;Glutton_Squares[205]=1;Glutton_Squares[208]=1;
Glutton_Squares[210]=1;Glutton_Squares[214]=1;Glutton_Squares[216]=1;Glutton_Squares[219]=1;

for(n=221;n<=223;n++)   Glutton_Squares[n]=1;
for(n=225;n<=227;n++)   Glutton_Squares[n]=1;

Glutton_Squares[229]=1;

for(n=231;n<=233;n++)  Glutton_Squares[n]=1;
for(n=235;n<=238;n++)  Glutton_Squares[n]=1;
for(n=240;n<=242;n++)  Glutton_Squares[n]=1;
for(n=244;n<=248;n++)  Glutton_Squares[n]=1;
for(n=250;n<=252;n++)  Glutton_Squares[n]=1;

Glutton_Squares[254]=1;Glutton_Squares[255]=1;Glutton_Squares[258]=1;
Glutton_Squares[263]=1;Glutton_Squares[268]=1;Glutton_Squares[271]=1;

for(n=272;n<=288;n++)  Glutton_Squares[n]=1;


for(n=0;n<=288;n++)
{
  Dot_Squares[n]=Glutton_Squares[n];
  Demon_Squares[n]=Glutton_Squares[n];
}
Demon_Squares[59]=0;
Demon_Squares[229]=0;
Dot_Squares[59]=0;
Dot_Squares[229]=0;
Dot_Squares[149]=0;

}

int Check_For_Level_Completion()
{
 int n,m=1;
 for(n=0;n<289;n++)
  {
   if(Dot_Squares[n]==1)
   m=0;
  }
 if(m==1)
  {
  return 1;
  }
  return 0;
}

int Row_Detector(int x)
{
if(x%17==0)        return 1;
else if((x-1)%17==0)    return 2;
else if((x-2)%17==0)    return 3;
else if((x-3)%17==0)    return 4;
else if((x-4)%17==0)    return 5;
else if((x-5)%17==0)    return 6;
else if((x-6)%17==0)    return 7;
else if((x-7)%17==0)    return 8;
else if((x-8)%17==0)    return 9;
else if((x-9)%17==0)    return 10;
else if((x-10)%17==0)   return 11;
else if((x-11)%17==0)   return 12;
else if((x-12)%17==0)   return 13;
else if((x-13)%17==0)   return 14;
else if((x-14)%17==0)   return 15;
else if((x-15)%17==0)   return 16;
else if((x-16)%17==0)   return 17;
return 0;
}

int Column_Detector(int x)
{
if(x>=0&&x<=16)         return 1;
else if(x>=17&&x<=33)   return 2;
else if(x>=34&&x<=50)   return 3;
else if(x>=51&&x<=67)   return 4;
else if(x>=68&&x<=84)   return 5;
else if(x>=85&&x<=101)  return 6;
else if(x>=102&&x<=118) return 7;
else if(x>=119&&x<=135) return 8;
else if(x>=136&&x<=152) return 9;
else if(x>=153&&x<=169) return 10;
else if(x>=170&&x<=186) return 11;
else if(x>=187&&x<=203) return 12;
else if(x>=204&&x<=220) return 13;
else if(x>=221&&x<=237) return 14;
else if(x>=238&&x<=254) return 15;
else if(x>=255&&x<=271) return 16;
else                    return 17;
}

void snd(int loop)
{
    if(loop%3==0)
        sound(200);

    else if(loop%3==1)
        sound(220);

    else if(loop%3==2)
        sound(240);

    delay(50);
    nosound();
}

void Draw_Dots()
{
int x,y;
x=getmaxx()/2+45;
y=getmaxy()/2;

setcolor(Dot_Color);
int what;

 for(int z=0;z<289;z++)
 {
    if(z<17)
    what=0;
    if(z>=17&&z<34)
    what=1;
    if(z>=34&&z<51)
    what=2;
    if(z>=51&&z<68)
    what=3;
    if(z>=68&&z<85)
    what=4;
    if(z>=85&&z<102)
    what=5;
    if(z>=102&&z<119)
    what=6;
    if(z>=119&&z<136)
    what=7;
    if(z>=136&&z<153)
    what=8;
    if(z>=153&&z<170)
    what=9;
    if(z>=170&&z<187)
    what=10;
    if(z>=187&&z<204)
    what=11;
    if(z>=204&&z<221)
    what=12;
    if(z>=221&&z<238)
    what=13;
    if(z>=238&&z<255)
    what=14;
    if(z>=255&&z<272)
    what=15;
    if(z>=272&&z<289)
    what=16;
        if(Dot_Squares[z]==1&&z!=229&&z!=59)
        {
               circle(x-216+27*what,y-216+27*(z%17),2);
               circle(x-216+27*what,y-216+27*(z%17),1);
               circle(x-216+27*what,y-216+27*(z%17),1.5);
        }
 }
}

void Sound_Mode_Conversion()//MODE CONVERSION SOUND
{
    for(int o=0;o<15;o++)
    {
    sound(250+10*o);
    delay(3);
    }
    nosound();
}

void Sound_Glutton_Catches_Demon()
{
    sound(750);
    delay(12);
    nosound();
}

void Scorer(unsigned long int sco,int what)
{
 int x,y;
 x=getmaxx()/2;
 y=getmaxy()/2;
 int ss[6]={0,0,0,0,0,0};
    ss[5]=sco/100000;
    ss[4]=(sco%100000)/10000;
    ss[3]=(sco%10000)/1000;
    ss[2]=(sco%1000)/100;
    ss[1]=(sco%100)/10;
    ss[0]=(sco%10);
    if(what==0)
    {
    setfillstyle(SOLID_FILL,7);
    bar(x-250,y-184,x-205,y-174);
    }
    else
    setcolor(6);

    settextstyle(DEFAULT_FONT,0,1);

    for(int o=5;o>=0;o--)
    switch(ss[o])
    {
      case 0:   outtextxy(x-204-o*7,y-183+2,"0");break;
      case 1:   outtextxy(x-204-o*7,y-183+2,"1");break;
      case 2:   outtextxy(x-204-o*7,y-183+2,"2");break;
      case 3:   outtextxy(x-204-o*7,y-183+2,"3");break;
      case 4:   outtextxy(x-204-o*7,y-183+2,"4");break;
      case 5:   outtextxy(x-204-o*7,y-183+2,"5");break;
      case 6:   outtextxy(x-204-o*7,y-183+2,"6");break;
      case 7:   outtextxy(x-204-o*7,y-183+2,"7");break;
      case 8:   outtextxy(x-204-o*7,y-183+2,"8");break;
      case 9:   outtextxy(x-204-o*7,y-183+2,"9");break;
      default: break;
    }
}

void Welcome()
{
    int g,h,M_col=14;

    setfillstyle(SOLID_FILL,1);
    bar(0,0,2*x,2*y);
    for(g=0;g<640;g+=2)
    for(h=0;h<505;h+=2)
        putpixel(g,h,M_col);
    for(g=0;g<640;g+=2)
    for(h=0;h<505;h+=2)
        putpixel(g+1,h+1,M_col);

    setfillstyle(SOLID_FILL,7);
    bar(x-200,y-150,x+200,y+150);
    setcolor(0);
    rectangle(x-150,y-110,x+150,y-55);
    rectangle(x-150+1,y-110+1,x+150-1,y-55-1);
    rectangle(x-200,y-150,x+200,y+150);
    rectangle(x-200+1,y-150+1,x+200-1,y+150-1);
    rectangle(x-200+2,y-150+2,x+200-2,y+150-2);
    rectangle(x-150,y-30,x+150,y+130);
    rectangle(x-150+1,y-30+1,x+150-1,y+130-1);

    setcolor(15);
    line(x-200,y-150,x+200,y-150);
    line(x-200,y-150+1,x+200-1,y-150+1);
    line(x-200,y-150+2,x+200-2,y-150+2);
    line(x-200,y-150,x-200,y+150);
    line(x-200+1,y-150,x-200+1,y+150-1);
    line(x-200+2,y-150,x-200+2,y+150-2);
    line(x+150,y-110,x+150,y-55);
    line(x+150-1,y-110+1,x+150-1,y-55);
    line(x-150,y-55,x+150,y-55);
    line(x-150+1,y-55-1,x+150-1,y-55-1);
    line(x-150,y+130,x+150,y+130);
    line(x-150+1,y+130-1,x+150-1,y+130-1);
    line(x+150,y-30,x+150,y+130);
    line(x+150-1,y-30+1,x+150-1,y+130);

    settextstyle(DEFAULT_FONT,0,5);
    setcolor(2);
    outtextxy(x-135,y-100,"Glutt n");

    setcolor(YELLOW);
    setfillstyle(SOLID_FILL,YELLOW);
    circle(x+82,y+134-212,11);
    circle(x-5+82,y+131-212,2);
    circle(x+5+82,y+131-212,2);
    floodfill(x+82,y+134-212,YELLOW);
    setcolor(0);
    setfillstyle(SOLID_FILL,0);
    circle(x+82,y+139-212,2);
    floodfill(x+82,y+139-212,0);
    setcolor(14);
    settextstyle(DEFAULT_FONT,0,1);
    setcolor(12);
    outtextxy(x-125,y+150-30,"e Mail - singhsuneet@yahoo.com");
    setcolor(RED);
    outtextxy(x-47,y+110-30,"SUNEET SINGH");
    outtextxy(x-40,y+120-30,"99/CSE/123");
    outtextxy(x-70,y+130-30,"C.R.S.C.E. MURTHAL");
    outtextxy(x-73,y+140-30,"Haryana - ( INDIA )");
    outtextxy(x-125,y+150-30,"e Mail   singhsuneet yahoo.com");
    setcolor(1);
    outtextxy(x-40,y+130-40,"  /   /");
    setcolor(14);
    outtextxy(x-30,y+100-40,"CREATOR");

    sleep(1);

    for(g=0;g<2;g++)
    {
    sound(500);     delay(300);
    sound(400);     delay(180);
    sound(450);     delay(450);
    sound(350);     delay(180);
    sound(400);      delay(180);
    sound(350);      delay(180);
    sound(400);      delay(180);
    }
    for(g=0;g<2;g++)
    {
    sound(350);      delay(300);
    sound(400);      delay(200);
    sound(450);      delay(400);
    sound(500);      delay(200);
    sound(350);      delay(180);
    sound(400);      delay(180);
    sound(350);      delay(180);
    sound(400);      delay(180);
    }
    sound(500); delay(100);
    nosound();

    setfillstyle(SOLID_FILL,7);
    bar(x-150+2,y-30+2,x+150-2,y+130-2);
    setcolor(LIGHTGREEN);
    settextstyle(DEFAULT_FONT,0,1);
    outtextxy(x-150,y-20+60,"   Desert Sand");
    outtextxy(x-147,y-0+70,"   Aquamarine");
    outtextxy(x-150,y+20+80,"   Dark Forest");
    outtextxy(x+39,y-50+67,"r u nuts??");
    outtextxy(x+48,y-50+163,"zZzz..z.");
    setcolor(8);
    outtextxy(x-30,y-50+30,"SELECT");
    outtextxy(x+60,y-50+50,"SPEED");
    setcolor(15);
    outtextxy(x-110,y-50+50,"SKIN");
    setcolor(2);
    rectangle(x-134,y+95,x-33,y+111);
    rectangle(x+120,y+15,x+140,y+121);
}

void Speed_Skin_Menu()
{

int h,g;
int sk=1,sp=0;


setcolor(14);

for(sk=0;sk<25;sk++)
line(x+122,y+119-sk*2,x+138,y+119-sk*2);

h=25;

sk=1;sp=0;
            Skin=3; Speed=100;

while(1)
{
 if(kbhit())
 {
        ii.h.ah=0;
        int86(22,&ii,&oo);
        if(oo.h.ah==28)
         {
           break;
         }
        if(oo.h.ah==77)
         {
            if(sk==1)
            {
             setcolor(14);
            if(Skin==3)
             rectangle(x-134,y+95,x-33,y+111);
            else if(Skin==2)
             rectangle(x-134,y+95-30,x-33,y+111-30);
            else if(Skin==1)
             rectangle(x-134,y+95-60,x-33,y+111-60);
             sk=0;sp=1;
             setcolor(15); outtextxy(x+60,y-50+50,"SPEED");
             setcolor(8);  outtextxy(x-110,y-50+50,"SKIN");
            }
            else
            {
             setcolor(2);
            if(Skin==3)
             rectangle(x-134,y+95,x-33,y+111);
            else if(Skin==2)
             rectangle(x-134,y+95-30,x-33,y+111-30);
            else if(Skin==1)
             rectangle(x-134,y+95-60,x-33,y+111-60);
             sk=1;sp=0;
             setcolor(8);outtextxy(x+60,y-50+50,"SPEED");
             setcolor(15);outtextxy(x-110,y-50+50,"SKIN");
            }
             }
        if(oo.h.ah==75)
         {
            if(sk==1)
            {
            setcolor(14);
            if(Skin==3)
            rectangle(x-134,y+95,x-33,y+111);
            else if(Skin==2)
            rectangle(x-134,y+95-30,x-33,y+111-30);
            else if(Skin==1)
            rectangle(x-134,y+95-60,x-33,y+111-60);
            sk=0;sp=1;
            setcolor(15);outtextxy(x+60,y-50+50,"SPEED");
            setcolor(8);outtextxy(x-110,y-50+50,"SKIN");
            }
            else
            {
            setcolor(2);
            if(Skin==3)
            rectangle(x-134,y+95,x-33,y+111);
            else if(Skin==2)
            rectangle(x-134,y+95-30,x-33,y+111-30);
            else if(Skin==1)
            rectangle(x-134,y+95-60,x-33,y+111-60);
            sk=1;sp=0;
            setcolor(8);outtextxy(x+60,y-50+50,"SPEED");
            setcolor(15);outtextxy(x-110,y-50+50,"SKIN");
            }
         }
        if(oo.h.ah==72)
         {
           if(sk==1)
           {
            if(Skin==3)
            {  Skin=2;
            setcolor(7);
            rectangle(x-134,y+95,x-33,y+111);
            setcolor(2);
            rectangle(x-134,y+95-30,x-33,y+111-30);
            }
            else if(Skin==2)
            {  Skin=1;
            setcolor(7);
            rectangle(x-134,y+95-30,x-33,y+111-30);
            setcolor(2);
            rectangle(x-134,y+95-60,x-33,y+111-60);
            }
            else if(Skin==1)
            {  Skin=3;
            setcolor(7);
            rectangle(x-134,y+95-60,x-33,y+111-60);
            setcolor(2);
            rectangle(x-134,y+95,x-33,y+111);
            }
           }
           else if(sp==1&&h!=52)
           {
           if(h<10)
           Speed-=5;
           else if(h>45)
           Speed-=4;
           else
           Speed-=2;
           h++;
           setcolor(14);
           for(g=0;g
           line(x+122,y+119-g*2,x+138,y+119-g*2);
           }
         }
        if(oo.h.ah==80)
         {
           if(sk==1)
           {
            if(Skin==3)
            {  Skin=1;
            setcolor(7);
            rectangle(x-134,y+95,x-33,y+111);
            setcolor(2);
            rectangle(x-134,y+95-60,x-33,y+111-60);
            }
            else if(Skin==2)
            {  Skin=3;
            setcolor(7);
            rectangle(x-134,y+95-30,x-33,y+111-30);
            setcolor(2);
            rectangle(x-134,y+95,x-33,y+111);
            }
            else if(Skin==1)
            {  Skin=2;
            setcolor(7);
            rectangle(x-134,y+95-60,x-33,y+111-60);
            setcolor(2);
            rectangle(x-134,y+95-30,x-33,y+111-30);
            }
           }
           else if(sp==1&&h!=1)
           {
           if(h<10)
           Speed+=5;
           else if(h>45)
           Speed+=4;
           else
           Speed+=2;
           h--;
           setcolor(7);
           line(x+122,y+119-h*2,x+138,y+119-h*2);
           }
         }
 }
}

x+=45;
    if(Skin==1)
    {
    Bkgd_Color=7;
    Dot_Color=RED;
    }
    else if(Skin==2)
    {
    Dot_Color=LIGHTGREEN;
    Bkgd_Color=LIGHTBLUE;
    }
    else
    {
    Bkgd_Color=0;
    Dot_Color=GREEN;
    }
}

void Start_Play()
{

 int game;
 int g,h;

 while(1)
  {
      game=Glutton_Game_Loop();
      if(game==1)
        {
        Init_Glutton_Squares();game=2;
        Demon_Cell_Color++;
        Level++;
        Power_Dot_Status_1=1;
        Power_Dot_Status_2=1;
        Power_Dot_Status_3=1;
        Power_Dot_Status_4=1;
        Bonus_Counter=0;
        Bonus=0;
        }
     else
        {
        chance--;
        }
    if(chance==0)
        {
        int xx,yy;
        settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
        setcolor(0);
            outtextxy(x-315,y+195,"Pause");
            outtextxy(x-315,y+205,"ENTER");
        setcolor(4);
        settextstyle(TRIPLEX_FONT,HORIZ_DIR,2);
            outtextxy(x-322,y-15,"GAME");
            outtextxy(x-320,y+15,"OVER");
        setcolor(2);
        settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
            outtextxy(x-312,y+165,"Play");
            outtextxy(x-322,y+180,"Again??");
        setcolor(10);
        circle(x-313,y+205,10);
        circle(x-280,y+205,10);
        circle(x-313,y+205,9);
        circle(x-280,y+205,9);
        setfillstyle(SOLID_FILL,7);
        floodfill(x-313,y+205,10);
        floodfill(x-280,y+205,10);
        setcolor(14);
            outtextxy(x-313-3,y+202,"y");
            outtextxy(x-280-3,y+202,"n");
        while(1)
        {
            ii.h.ah=0;
            int86(22,&ii,&oo);
            if(oo.h.ah==21)
            {
             setcolor(2);
             circle(x-313,y+205,10);
             circle(x-313,y+205,9);
             setcolor(8);
                 outtextxy(x-313-3,y+202,"y");
             delay(500);
             setcolor(10);
             circle(x-313,y+205,10);
             circle(x-313,y+205,9);
             setcolor(14);
                 outtextxy(x-313-3,y+202,"y");
             delay(500);
             Level=1;Score=0;chance=MAXCHANCE;Demon_Cell_Color=1;
             Power_Dot_Status_1=1;Power_Dot_Status_2=1;Power_Dot_Status_3=1;Power_Dot_Status_4=1;
             Start_Play();
            }
            if(oo.h.ah==49)
            {
             setcolor(2);
             circle(x-280,y+205,10);
             circle(x-280,y+205,9);
             setcolor(8);
                 outtextxy(x-280-3,y+202,"n");
             delay(500);
             setcolor(10);
             circle(x-280,y+205,10);
             circle(x-280,y+205,9);
             setcolor(14);
                 outtextxy(x-280-3,y+202,"n");
             delay(500);

            free(Glut_Face_1);free(Glut_Face_2);free(Glut_Face_3);
            free(Blank_Replacer);free(Dot_Replacer);free(Glut_Power);
            free(Demon[0]);free(Demon[1]);free(Demon[2]);
            closegraph();
            exit(0);
            }
          }
        }
  }
}

void Memory_Provider()
{
int area_occupied;

if(Memory_Allocator==1)
{

  area_occupied=imagesize(x+15,y-12,x+37,y+12);
   Blank_Replacer=((char*)malloc(area_occupied));
    getimage(x+15,y-12,x+37,y+12,Blank_Replacer);

  setcolor(Dot_Color);
               circle(x+27,y,2);
               circle(x+27,y,1);
               circle(x+27,y,1.5);

  area_occupied=imagesize(x+15,y-12,x+39,y+12);
   Dot_Replacer=((char*)malloc(area_occupied));
    getimage(x+15,y-12,x+39,y+12,Dot_Replacer);

 setcolor(WHITE);
 setfillstyle(SOLID_FILL,MAGENTA);
 circle(x,y,10);
 floodfill(x,y,WHITE);
 setcolor(0);
 circle(x+3,y-3,1);
 circle(x-3,y-3,1);
 line(x+4,y+6,x+3,y+5);
 line(x+3,y+5,x+2,y+6);
 line(x+2,y+6,x+1,y+5);
 line(x+1,y+5,x,y+6);
 line(x+0,y+6,x-1,y+5);
 line(x-1,y+5,x-2,y+6);
 line(x-2,y+6,x-3,y+5);
 line(x-3,y+5,x-4,y+6);

  area_occupied=imagesize(x-12,y-12,x+12,y+12);
  Demon[0]=((char*)malloc(area_occupied));
  getimage(x-11,y-12,x+11,y+12,Demon[0]);

 setcolor(WHITE);
 circle(x-27,y,10);
  setfillstyle(SOLID_FILL,7);
 floodfill(x-27,y,WHITE);

setcolor(0);
 circle(x-30,y-3,1);
 circle(x-24,y-3,1);
 line(x+4-27,y+6,x+3-27,y+5);
 line(x+3-27,y+5,x+2-27,y+6);
 line(x+2-27,y+6,x+1-27,y+5);
 line(x+1-27,y+5,x-27,y+6);
 line(x+0-27,y+6,x-1-27,y+5);
 line(x-1-27,y+5,x-2-27,y+6);
 line(x-2-27,y+6,x-3-27,y+5);
 line(x-3-27,y+5,x-4-27,y+6);

   area_occupied=imagesize(x-39,y-12,x-15,y+12);
  Demon[1]=((char*)malloc(area_occupied));
  getimage(x-39,y-12,x-15,y+12,Demon[1]);

 setcolor(WHITE);
  setfillstyle(SOLID_FILL,CYAN);
 circle(x+27,y,10);
 floodfill(x+27,y,WHITE);
 setcolor(0);
 circle(x+30,y-3,1);
 circle(x+24,y-3,1);
 line(x+4+27,y+6,x+3+27,y+5);
 line(x+3+27,y+5,x+2+27,y+6);
 line(x+2+27,y+6,x+1+27,y+5);
 line(x+1+27,y+5,x+27,y+6);
 line(x+0+27,y+6,x-1+27,y+5);
 line(x-1+27,y+5,x-2+27,y+6);
 line(x-2+27,y+6,x-3+27,y+5);
 line(x-3+27,y+5,x-4+27,y+6);

   area_occupied=imagesize(x+15,y-12,x+39,y+12);
  Demon[2]=((char*)malloc(area_occupied));
  getimage(x+15,y-12,x+39,y+12,Demon[2]);

  setcolor(8);
  setfillstyle(SOLID_FILL,RED);
  circle(x,y+134,11);
  circle(x-5,y+131,2);
  circle(x+5,y+131,2);
  floodfill(x,y+134,8);

  area_occupied=imagesize(x-11,y+123,x+11,y+145);
  Glut_Power=((char*)malloc(area_occupied));
  getimage(x-11,y+123,x+11,y+145,Glut_Power);

  setcolor(YELLOW);
  setfillstyle(SOLID_FILL,YELLOW);
  circle(x,y+134,11);
  circle(x-5,y+131,2);
  circle(x+5,y+131,2);
  floodfill(x,y+134,YELLOW);

  area_occupied=imagesize(x-11,y+123,x+11,y+145);
  Glut_Face_1=((char*)malloc(area_occupied));
  getimage(x-11,y+123,x+11,y+145,Glut_Face_1);

  setcolor(0);
  setfillstyle(SOLID_FILL,0);
  circle(x,y+139,2);
  floodfill(x,y+139,0);
  area_occupied=imagesize(x-11,y+123,x+11,y+145);
  Glut_Face_2=((char*)malloc(area_occupied));
  getimage(x-11,y+123,x+11,y+145,Glut_Face_2);

  setcolor(YELLOW);
  setfillstyle(SOLID_FILL,YELLOW);
  circle(x,y+139,2);
  floodfill(x,y+139,YELLOW);
  setcolor(0);
  setfillstyle(SOLID_FILL,0);
  circle(x,y+139,3);
  floodfill(x,y+139,0);
  area_occupied=imagesize(x-11,y+123,x+11,y+145);
  Glut_Face_3=((char*)malloc(area_occupied));
  getimage(x-11,y+123,x+11,y+145,Glut_Face_3);
}
}

void Draw_Main_Screen()
{

if(Memory_Allocator==1)
{

setfillstyle(SOLID_FILL,7);
bar(x-360,y-240,x-232,y+240);
bar(x-360,y-240,x+265,y-232);
bar(x-360,y+232,x+265,y+240);
bar(x+232,y-240,x+265,y+240);
setfillstyle(SOLID_FILL,0);
bar(x-340,y-230+70,x-252,y+230);
setcolor(15);
rectangle(x-230,y-230,x+230,y+230);
rectangle(x-230+1,y-230+1,x+230-1,y+230-1);
rectangle(x-230-1,y-230-1,x+230+1,y+230+1);
rectangle(x-230-2,y-230-2,x+230+2,y+230+2);
setcolor(8);

rectangle(x-340,y-230+70,x-252,y+230);
rectangle(x-340-1,y-230+70-1,x-252+1,y+230+1);
rectangle(x-340+1,y-230+70+1,x-252-1,y+230-1);
rectangle(x-340+2,y-230+70+2,x-252-2,y+230-2);

line(x-230,y-230,x+230,y-230);
line(x-230-2,y-230-2,x+230+2,y-230-2);
line(x-230-1,y-230-1,x+230+1,y-230-1);
line(x-230+1,y-230+1,x+230-1,y-230+1);


line(x-230,y-230,x-230,y+230);
line(x-230+1,y-230,x-230+1,y+230-1);
line(x-230-1,y-230,x-230-1,y+230+1);
line(x-230-2,y-231,x-230-2,y+230+2);
setcolor(15);
rectangle(x-230,y-230,x+230,y+230);
rectangle(x-230+1,y-230+1,x+230-1,y+230-1);
rectangle(x-230-1,y-230-1,x+230+1,y+230+1);
rectangle(x-230-2,y-230-2,x+230+2,y+230+2);

line(x-252+1,y+228+4,x-340-1,y+228+4);
line(x-252,y+228+3,x-340,y+228+3);
line(x-252-1,y+228+2,x-340+1,y+228+2);
line(x-252-2,y+228+1,x-340+2,y+228+1);

line(x-252,y-229+70,x-252,y+228+2);
line(x-252-2,y-229+2+70,x-252-2,y+228-2+2);
line(x-252-1,y-229+1+70,x-252-1,y+228-1+2);
line(x-252+1,y-229-1+70,x-252+1,y+228+1+2);
setcolor(8);


line(x-230,y-230,x+230,y-230);
line(x-230-2,y-230-2,x+230+2,y-230-2);
line(x-230-1,y-230-1,x+230+1,y-230-1);
line(x-230+1,y-230+1,x+230-1,y-230+1);

line(x-230,y-230,x-230,y+230);
line(x-230+1,y-230,x-230+1,y+230-1);
line(x-230-1,y-230,x-230-1,y+230+1);
line(x-230-2,y-231,x-230-2,y+230+2);
Memory_Allocator=0;
}

setfillstyle(1,Demon_Cell_Color);

bar(x-13-27*2,y+25-11,x-13+27*3,y+40);
bar(x-13-27*2,y+25-11-27*2,x-13-27,y+25-10);
bar(x-13+27*2,y+25-11-27*2,x-13+27*3,y+25-10);
bar(x-13-27,y+25-11-27*2,x-13,y+25-10-30);
bar(x-13+27,y+25-11-27*2,x-13+27*2,y+25-10-30);

if(Skin==1)
setcolor(7);
else if(Skin==2)
setcolor(LIGHTBLUE);
else
setcolor(0);

for(int dod=0;dod<4;dod++)
line(x-15-25+dod*27,y+25-11,x-40+dod*27,y+39);
line(x-15-25-27,y+40-2*27,x-40,y+40-2*27);
line(x-15-25+27*3,y+40-2*27,x-40+27*4,y+40-2*27);
line(x-15-25-27,y+40-27,x-40,y+40-27);

line(x-15-25+27*3,y+40-27,x-40+27*4,y+40-27);
line(x-15-25+3*27,y-2*27+25-11,x-40+3*27,y-27+39);
line(x-15-25,y+25-11-2*27,x-40,y+39-27);

setfillstyle(SOLID_FILL,7);
bar(x+235,y-240,x+265,y+240);
bar(x-273,y-225,x-260,y-204);
setfillstyle(SOLID_FILL,0);
bar(x-335,y-230+75,x-258,y+225);
for(int chan=0;chan
{
  setcolor(YELLOW);
  setfillstyle(SOLID_FILL,YELLOW);
  circle(x+250-1,y+214-34*chan+7,11);
  circle(x-5+250-1,y+211-34*chan+7,2);
  circle(x+5+250-1,y+211-34*chan+7,2);
  floodfill(x+250-1,y+214-34*chan+7,YELLOW);
  setcolor(0);
  setfillstyle(SOLID_FILL,0);
  circle(x+250-1,y+219-34*chan+7,2);
  floodfill(x+250-1,y+219-34*chan+7,0);
}
 settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
 setcolor(4);
 switch(Level)
 {
  case 1:   outtextxy(x-272,y-228-1,"1");break;
  case 2:   outtextxy(x-272,y-228-1,"2");break;
  case 3:   outtextxy(x-272,y-228-1,"3");break;
  case 4:   outtextxy(x-272,y-228-1,"4");break;
  case 5:   outtextxy(x-272,y-228-1,"5");break;
  case 6:   outtextxy(x-272,y-228-1,"6");break;
  case 7:   outtextxy(x-272,y-228-1,"7");break;
  case 8:   outtextxy(x-272,y-228-1,"8");break;
  case 9:   outtextxy(x-272,y-228-1,"9");break;
  case 10:   outtextxy(x-272,y-228-1,"10");break;
  case 11:   outtextxy(x-272,y-228-1,"11");break;
  case 12:   outtextxy(x-272,y-228-1,"12");break;
  case 13:   outtextxy(x-272,y-228-1,"13");break;
  case 14:   outtextxy(x-272,y-228-1,"14");break;
  case 15:   outtextxy(x-272,y-228-1,"15");break;
  case 16:   outtextxy(x-272,y-228-1,"16");break;
  case 17:   outtextxy(x-272,y-228-1,"17");break;
  case 18:   outtextxy(x-272,y-228-1,"18");break;
  case 19:   outtextxy(x-272,y-228-1,"19");break;
  case 20:   outtextxy(x-272,y-228-1,"20");break;
  default:   outtextxy(x-272,y-228-1,"20+");break;
  }
 setcolor(RED);
 outtextxy(x-340,y-230+1,"Level");

         settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
         setcolor(RED);
         outtextxy(x-315,y+195,"Pause");
         outtextxy(x-315,y+205,"ENTER");

 putimage(x-12,y-12,Demon[0],0);
 putimage(x-12-27,y-12,Demon[1],0);
 putimage(x-12+27,y-12,Demon[2],0);


}
void Glutton_Gets_Caught()
{
 int diminisher=0;
 putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
 putimage(x-12-27*d_txt[0],y-12-27*d_tyt[0],Blank_Replacer,0);
 putimage(x-12-27*d_txt[1],y-12-27*d_tyt[1],Blank_Replacer,0);
 putimage(x-12-27*d_txt[2],y-12-27*d_tyt[2],Blank_Replacer,0);

 for(int oo=400;oo>=150;oo-=25)
 {
  diminisher++;
  setcolor(YELLOW);
  circle(x-27*txt,y+11+123-27*tyt,11-diminisher);
  sound(oo);
  delay(100);
  setcolor(Bkgd_Color);
  circle(x-27*txt,y+11+123-27*tyt,11-diminisher);
 }
 nosound();
 setcolor(YELLOW);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt+5,y+11+123-27*tyt);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt+4,y+11+123-27*tyt+4);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt+4,y+11+123-27*tyt-4);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt,y+11+123-27*tyt+5);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt,y+11+123-27*tyt-5);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt-4,y+11+123-27*tyt+4);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt-4,y+11+123-27*tyt-4);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt-5,y+11+123-27*tyt);
 setcolor(Bkgd_Color);
 circle(x-27*txt,y+11+123-27*tyt,1);
 circle(x-27*txt,y+11+123-27*tyt,2);
 delay(500);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt+5,y+11+123-27*tyt);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt+4,y+11+123-27*tyt+4);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt+4,y+11+123-27*tyt-4);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt,y+11+123-27*tyt+5);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt,y+11+123-27*tyt-5);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt-4,y+11+123-27*tyt+4);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt-4,y+11+123-27*tyt-4);
 line(x-27*txt,y+11+123-27*tyt,x-27*txt-5,y+11+123-27*tyt);
 putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
}

void Switcher(int Directionection,int Glutton_Mode,int Demon_Number)
{

    switch(Directionection)
    {
    case UP:           if(Demon_Squares[Curr_Pos_Demon[Demon_Number]-1]==1&&( (Curr_Pos_Demon[Demon_Number]-1)!=-1&&(Curr_Pos_Demon[Demon_Number]-1)!=271&&(Curr_Pos_Demon[Demon_Number]-1)!=254&&(Curr_Pos_Demon[Demon_Number]-1)!=237&&(Curr_Pos_Demon[Demon_Number]-1)!=220&&(Curr_Pos_Demon[Demon_Number]-1)!=203&&(Curr_Pos_Demon[Demon_Number]-1)!=186&&(Curr_Pos_Demon[Demon_Number]-1)!=169&&(Curr_Pos_Demon[Demon_Number]-1)!=152&&(Curr_Pos_Demon[Demon_Number]-1)!=135&&(Curr_Pos_Demon[Demon_Number]-1)!=118&&(Curr_Pos_Demon[Demon_Number]-1)!=101&&(Curr_Pos_Demon[Demon_Number]-1)!=84&&(Curr_Pos_Demon[Demon_Number]-1)!=67&&(Curr_Pos_Demon[Demon_Number]-1)!=50&&(Curr_Pos_Demon[Demon_Number]-1)!=33&&(Curr_Pos_Demon[Demon_Number]-1)!=16) )
               {
            if(Dot_Squares[Curr_Pos_Demon[Demon_Number]]==1)
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Dot_Replacer,0);
            else
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Blank_Replacer,0);
            d_tyt[Demon_Number]++;
            Curr_Pos_Demon[Demon_Number]--;
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Demon[Demon_Number],0);
            if(Glutton_Mode==2)
            {setcolor(RED);
            circle(x-27*d_txt[Demon_Number],y-27*d_tyt[Demon_Number],10);}
            Demon_Column_Number[Demon_Number]=Column_Detector(Curr_Pos_Demon[Demon_Number]);
            Demon_Row_Number[Demon_Number]=Row_Detector(Curr_Pos_Demon[Demon_Number]);
               } break;
    case LEFT:           if(Demon_Squares[Curr_Pos_Demon[Demon_Number]-17]==1&&!((Curr_Pos_Demon[Demon_Number])>=0&&(Curr_Pos_Demon[Demon_Number])<=16))
               {
            if(Dot_Squares[Curr_Pos_Demon[Demon_Number]]==1)
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Dot_Replacer,0);
            else
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Blank_Replacer,0);
            d_txt[Demon_Number]++;
            Curr_Pos_Demon[Demon_Number]-=17;
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Demon[Demon_Number],0);
            if(Glutton_Mode==2)
            {setcolor(RED);
            circle(x-27*d_txt[Demon_Number],y-27*d_tyt[Demon_Number],10);}
            Demon_Column_Number[Demon_Number]=Column_Detector(Curr_Pos_Demon[Demon_Number]);
            Demon_Row_Number[Demon_Number]=Row_Detector(Curr_Pos_Demon[Demon_Number]);
               }
               break;

    case DOWN:           if(Demon_Squares[Curr_Pos_Demon[Demon_Number]+1]==1&&( (Curr_Pos_Demon[Demon_Number]+1)!=289&&(Curr_Pos_Demon[Demon_Number]+1)!=272&&(Curr_Pos_Demon[Demon_Number]+1)!=255&&(Curr_Pos_Demon[Demon_Number]+1)!=238&&(Curr_Pos_Demon[Demon_Number]+1)!=221&&(Curr_Pos_Demon[Demon_Number]+1)!=204&&(Curr_Pos_Demon[Demon_Number]+1)!=187&&(Curr_Pos_Demon[Demon_Number]+1)!=170&&(Curr_Pos_Demon[Demon_Number]+1)!=153&&(Curr_Pos_Demon[Demon_Number]+1)!=136&&(Curr_Pos_Demon[Demon_Number]+1)!=119&&(Curr_Pos_Demon[Demon_Number]+1)!=102&&(Curr_Pos_Demon[Demon_Number]+1)!=85&&(Curr_Pos_Demon[Demon_Number]+1)!=68&&(Curr_Pos_Demon[Demon_Number]+1)!=51&&(Curr_Pos_Demon[Demon_Number]+1)!=34&&(Curr_Pos_Demon[Demon_Number]+1)!=17) )
               {
            if(Dot_Squares[Curr_Pos_Demon[Demon_Number]]==1)
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Dot_Replacer,0);
            else
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Blank_Replacer,0);
            d_tyt[Demon_Number]--;
            Curr_Pos_Demon[Demon_Number]++;
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Demon[Demon_Number],0);
            if(Glutton_Mode==2)
            {setcolor(RED);
            circle(x-27*d_txt[Demon_Number],y-27*d_tyt[Demon_Number],10);}
            Demon_Column_Number[Demon_Number]=Column_Detector(Curr_Pos_Demon[Demon_Number]);
            Demon_Row_Number[Demon_Number]=Row_Detector(Curr_Pos_Demon[Demon_Number]);
               } break;

    case RIGHT:           if(Demon_Squares[Curr_Pos_Demon[Demon_Number]+17]==1&&!((Curr_Pos_Demon[Demon_Number])>=272&&(Curr_Pos_Demon[Demon_Number])<=288))
               {
            if(Dot_Squares[Curr_Pos_Demon[Demon_Number]]==1)
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Dot_Replacer,0);
            else
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Blank_Replacer,0);
            d_txt[Demon_Number]--;
            Curr_Pos_Demon[Demon_Number]+=17;
            putimage(x-12-27*d_txt[Demon_Number],y-12-27*d_tyt[Demon_Number],Demon[Demon_Number],0);
            if(Glutton_Mode==2)
            {setcolor(RED);
            circle(x-27*d_txt[Demon_Number],y-27*d_tyt[Demon_Number],10);}
            Demon_Column_Number[Demon_Number]=Column_Detector(Curr_Pos_Demon[Demon_Number]);
            Demon_Row_Number[Demon_Number]=Row_Detector(Curr_Pos_Demon[Demon_Number]);
               }
               break;

    default:           break;
    }
}


void Demon_Director(int demon_Power_Dot_Status_ber,int Column_Number,int Row_Number)
{
int dec_Row_Detector,dec_col;
           dec_col=(Column_Number-Demon_Column_Number[demon_Power_Dot_Status_ber]);
           dec_Row_Detector=(Row_Number-Demon_Row_Number[demon_Power_Dot_Status_ber]);


    if(Dir_Demon[demon_Power_Dot_Status_ber]==LEFT)
    {
     if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==1&&(Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17)>=0)//path unblocked
     {
          if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==1&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==0)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
           if(dec_Row_Detector<=0)
           Dir_Demon[demon_Power_Dot_Status_ber]=1;  break;
          case 1:
           if(dec_Row_Detector<0)
           Dir_Demon[demon_Power_Dot_Status_ber]=1;  break;
          case 2:
           if(dec_Row_Detector<=0)
           Dir_Demon[demon_Power_Dot_Status_ber]=1;  break;
         }
          }
          else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==0&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==1)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_Row_Detector>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=3; break;
          case 1:
         if(dec_Row_Detector>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=3; break;
          case 2:
         if(dec_Row_Detector>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=3; break;
         }
          }
          else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==1&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==1)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
             if(dec_Row_Detector<0)
             Dir_Demon[demon_Power_Dot_Status_ber]=1;
             if(dec_Row_Detector>=0)
             Dir_Demon[demon_Power_Dot_Status_ber]=3; break;
          case 1:
             if(dec_Row_Detector<=0)
             Dir_Demon[demon_Power_Dot_Status_ber]=1;
             if(dec_Row_Detector>=0)
             Dir_Demon[demon_Power_Dot_Status_ber]=3; break;
          case 2:
             if(dec_Row_Detector<=0)
             Dir_Demon[demon_Power_Dot_Status_ber]=1;
             if(dec_Row_Detector>0)
             Dir_Demon[demon_Power_Dot_Status_ber]=3; break;
         }
          }
     }

     else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==0||(Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17)<0)//path blocked
     {
          if((Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==0||(Curr_Pos_Demon[demon_Power_Dot_Status_ber]%17==0))&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==1)
          Dir_Demon[demon_Power_Dot_Status_ber]=3;
          else if((Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==0||((Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1)%17==0))&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==1)
          Dir_Demon[demon_Power_Dot_Status_ber]=1;
          if( Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==1&&(Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1)%17!=0 && Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==1&&(Curr_Pos_Demon[demon_Power_Dot_Status_ber])%17!=0)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
          if(dec_Row_Detector>0)
          Dir_Demon[demon_Power_Dot_Status_ber]=3;
          else if(dec_Row_Detector<=0)
          Dir_Demon[demon_Power_Dot_Status_ber]=1; break;
          case 1:
          if(dec_Row_Detector>=0)
          Dir_Demon[demon_Power_Dot_Status_ber]=3;
          else if(dec_Row_Detector<0)
          Dir_Demon[demon_Power_Dot_Status_ber]=1; break;
          case 2:
          if(dec_Row_Detector>0)
          Dir_Demon[demon_Power_Dot_Status_ber]=3;
          else if(dec_Row_Detector<=0)
          Dir_Demon[demon_Power_Dot_Status_ber]=1; break;
         }
          }
     }
    }


    else if(Dir_Demon[demon_Power_Dot_Status_ber]==RIGHT)
    {
     if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==1&&(Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17)<=288)//path unblocked
     {
          if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==1&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==0)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
          if(dec_Row_Detector<=0)
          Dir_Demon[demon_Power_Dot_Status_ber]=1;    break;
          case 1:
          if(dec_Row_Detector<=0)
          Dir_Demon[demon_Power_Dot_Status_ber]=1;    break;
          case 2:
          if(dec_Row_Detector<0)
          Dir_Demon[demon_Power_Dot_Status_ber]=1;    break;
         }
          }
          else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==0&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==1)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
          if(dec_Row_Detector>=0)
          Dir_Demon[demon_Power_Dot_Status_ber]=3;  break;
          case 1:
          if(dec_Row_Detector>=0)
          Dir_Demon[demon_Power_Dot_Status_ber]=3;  break;
          case 2:
          if(dec_Row_Detector>0)
          Dir_Demon[demon_Power_Dot_Status_ber]=3;  break;
         }
          }
          else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==1&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==1)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_Row_Detector<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=1;
         if(dec_Row_Detector>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=3;    break;
          case 1:
         if(dec_Row_Detector<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=1;
         if(dec_Row_Detector>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=3;    break;
          case 2:
         if(dec_Row_Detector<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=1;
         if(dec_Row_Detector>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=3;    break;
         }
          }
     }

     else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==0||(Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17)>288)//path blocked
     {
          if((Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==0||(Curr_Pos_Demon[demon_Power_Dot_Status_ber]%17==0))&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==1)
          Dir_Demon[demon_Power_Dot_Status_ber]=3;
          else if((Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==0||((Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1)%17==0))&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==1)
          Dir_Demon[demon_Power_Dot_Status_ber]=1;
          if( Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==1&&(Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1)%17!=0 && Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==1&&(Curr_Pos_Demon[demon_Power_Dot_Status_ber])%17!=0)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_Row_Detector>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=3;
         else if(dec_Row_Detector<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=1;  break;
          case 1:
         if(dec_Row_Detector>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=3;
         else if(dec_Row_Detector<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=1;  break;
          case 2:
         if(dec_Row_Detector>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=3;
         else if(dec_Row_Detector<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=1;  break;
         }
          }
     }
    }



    else if(Dir_Demon[demon_Power_Dot_Status_ber]==UP)
    {
     if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==1&&Curr_Pos_Demon[demon_Power_Dot_Status_ber]%17!=0)//path unblocked
     {
          if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==1&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==0)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;  break;
          case 1:
         if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;  break;
          case 2:
         if(dec_col<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;  break;
        }
          }
          else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==0&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==1)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;
          case 1:
         if(dec_col>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;
          case 2:
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;
         }
          }
          else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==1&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==1)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;
         if(dec_col>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;   break;
          case 1:
         if(dec_col<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;   break;
          case 2:
         if(dec_col<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;
         if(dec_col>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;   break;
         }
          }
     }

     else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-1]==0||(Curr_Pos_Demon[demon_Power_Dot_Status_ber])%17==0)//path blocked
     {
          if((Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==0||(Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17)<0)&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==1)
          Dir_Demon[demon_Power_Dot_Status_ber]=4;
          else if((Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==0||((Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17)>288))&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==1)
          Dir_Demon[demon_Power_Dot_Status_ber]=2;
          if( Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==1&&((Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17)<=288) && Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==1&&(Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17)>=0)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_col>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;
         else if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;  break;
          case 1:
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;
         else if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;  break;
          case 2:
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;
         else if(dec_col<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;  break;
         }
          }
     }
    }

    else if(Dir_Demon[demon_Power_Dot_Status_ber]==DOWN)
    {
     if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==1&&(Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1)%17!=0)//path unblocked
     {
          if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==1&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==0)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;break;
          case 1:
         if(dec_col<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;break;
          case 2:
         if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;break;
         }
          }
          else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==0&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==1)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;break;
          case 1:
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;break;
          case 2:
         if(dec_col>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;break;
         }
          }
          else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==1&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==1)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;
         if(dec_col>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4; break;
          case 1:
         if(dec_col<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4; break;
          case 2:
         if(dec_col<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2;
         if(dec_col>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4; break;
         }
          }
     }

     else if(Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1]==0||(Curr_Pos_Demon[demon_Power_Dot_Status_ber]+1)%17==0)//path blocked
     {
          if((Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==0||(Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17)<0)&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==1)
          Dir_Demon[demon_Power_Dot_Status_ber]=4;
          else if((Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==0||((Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17)>288))&&Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==1)
          Dir_Demon[demon_Power_Dot_Status_ber]=2;
          if( Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17]==1&&((Curr_Pos_Demon[demon_Power_Dot_Status_ber]+17)<=288) && Demon_Squares[Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17]==1&&(Curr_Pos_Demon[demon_Power_Dot_Status_ber]-17)>=0)
          {
         switch(demon_Power_Dot_Status_ber)
         {
          case 0:
         if(dec_col>0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;
         else if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2; break;
          case 1:
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;
         else if(dec_col<0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2; break;
          case 2:
         if(dec_col>=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=4;
         else if(dec_col<=0)
         Dir_Demon[demon_Power_Dot_Status_ber]=2; break;
        }
          }
     }
    }
}


void Glutton_Catches_Demon_in_Mode2(int Glutton_Mode)
{

    if(Curr_Pos_Glut==Curr_Pos_Demon[0]&&Glutton_Mode==2)
    {
         putimage(x-12-27*d_txt[0],y-12-27*d_tyt[0],Blank_Replacer,0);
         Curr_Pos_Demon[0]=144;
         d_txt[0]=0;
         d_tyt[0]=2;
         Score+=(100*Level);
         Sound_Glutton_Catches_Demon();
    }
    if(Curr_Pos_Glut==Curr_Pos_Demon[1]&&Glutton_Mode==2)
    {
         putimage(x-12-27*d_txt[1],y-12-27*d_tyt[1],Blank_Replacer,0);
         Curr_Pos_Demon[1]=144;
         d_txt[1]=0;
         d_tyt[1]=2;
         Score+=(100*Level);
         Sound_Glutton_Catches_Demon();
    }
    if(Curr_Pos_Glut==Curr_Pos_Demon[2]&&Glutton_Mode==2)
    {
         putimage(x-12-27*d_txt[2],y-12-27*d_tyt[2],Blank_Replacer,0);
         Curr_Pos_Demon[2]=144;
         d_txt[2]=0;
         d_tyt[2]=2;
         Score+=(100*Level);
         Sound_Glutton_Catches_Demon();
    }
}
void Blink_Dots(int loop,int Power_Dot_Status_1,int Power_Dot_Status_2,int Power_Dot_Status_3,int Power_Dot_Status_4)
{
    setcolor(8);
    if(loop%3!=0)
    setfillstyle(SOLID_FILL,LIGHTGREEN);
    else
    setfillstyle(SOLID_FILL,0);

 if(Dot_Squares[36]==1||Power_Dot_Status_1==1)
 {
 circle(x-216+27*2,y-216+27*(36%17),6);
 floodfill(x-216+27*2,y-216+27*(36%17),8);
 }
 if(Dot_Squares[48]==1||Power_Dot_Status_2==1)
 {
 circle(x-216+27*2,y-216+27*(48%17),6);
 floodfill(x-216+27*2,y-216+27*(48%17),8);
 }
 if(Dot_Squares[252]==1||Power_Dot_Status_4==1)
 {
 circle(x-216+27*14,y-216+27*(252%17),6);
 floodfill(x-216+27*14,y-216+27*(252%17),8);
 }
 if(Dot_Squares[240]==1||Power_Dot_Status_3==1)
 {
 circle(x-216+27*14,y-216+27*(240%17),6);
 floodfill(x-216+27*14,y-216+27*(240%17),8);
 }
}

void Ask_For_Exit()
{
    settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
    setcolor(0);
    outtextxy(x-315,y+195,"Pause");
    outtextxy(x-315,y+205,"ENTER");
    setcolor(2);
    settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
    outtextxy(x-312,y+175,"Quit");
    setcolor(10);
    circle(x-313,y+205,10);
    circle(x-280,y+205,10);
    circle(x-313,y+205,9);
    circle(x-280,y+205,9);
    setfillstyle(SOLID_FILL,7);
    floodfill(x-313,y+205,10);
    floodfill(x-280,y+205,10);
    setcolor(14);
    outtextxy(x-313-3,y+202,"y");
    outtextxy(x-280-3,y+202,"n");

    while(1)
    {
        ii.h.ah=0;
        int86(22,&ii,&oo);
        if(oo.h.ah==21)
        {
         setcolor(2);
         circle(x-313,y+205,10);
         circle(x-313,y+205,9);
         setcolor(8);
             outtextxy(x-313-3,y+202,"y");
         delay(500);
         setcolor(10);
         circle(x-313,y+205,10);
         circle(x-313,y+205,9);
         setcolor(14);
             outtextxy(x-313-3,y+202,"y");
         delay(500);
        free(Glut_Face_1);free(Glut_Face_2);free(Glut_Face_3);free(Blank_Replacer);free(Dot_Replacer);free(Glut_Power);
        free(Demon[0]);free(Demon[1]);free(Demon[2]);
        closegraph();exit(0);
        }
        if(oo.h.ah==49)
        {
         setcolor(2);
         circle(x-280,y+205,10);
         circle(x-280,y+205,9);
         setcolor(8);
             outtextxy(x-280-3,y+202,"n");
         delay(500);
         setcolor(10);
         circle(x-280,y+205,10);
         circle(x-280,y+205,9);
         setcolor(14);
             outtextxy(x-280-3,y+202,"n");
         delay(500);
         setfillstyle(SOLID_FILL,0);
         bar(x-336,y+160,x-255,y+225);
         settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
         setcolor(4);
             outtextxy(x-315,y+195,"Pause");
             outtextxy(x-315,y+205,"ENTER");
         break;
        }
    }
}

void Pause_The_Game()
{
    int blinker=0;
    settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
    setcolor(0);
    outtextxy(x-315,y+195,"Pause");
    outtextxy(x-315,y+205,"ENTER");
    setcolor(6);
    outtextxy(x-320,y-3,"Paused");

    while(1)
    {
        blinker++;
        if(kbhit())
        {
        ii.h.ah=0;
        int86(22,&ii,&oo);
        if(oo.h.ah==28)
        break;
        }
        setcolor(14);
        outtextxy(x-315,y+185,"Press");
        if(blinker%10<5)
         setcolor(0);
        else
         setcolor(4);
        settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
         outtextxy(x-335,y+205,"ENTER");
        settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
        if(blinker>1000)
           blinker=0;
    }
    setcolor(0);
    outtextxy(x-315,y+185,"Press");
    outtextxy(x-320,y-3,"Paused");
    settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
    outtextxy(x-335,y+205,"ENTER");
    settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
    setcolor(RED);
    outtextxy(x-315,y+195,"Pause");
    outtextxy(x-315,y+205,"ENTER");
}
int Glutton_Director()
{
int get=0;
   switch(Direction)
   {
    case UP:           if(Glutton_Squares[Curr_Pos_Glut-1]==1&&( (Curr_Pos_Glut-1)!=-1&&(Curr_Pos_Glut-1)!=271&&(Curr_Pos_Glut-1)!=254&&(Curr_Pos_Glut-1)!=237&&(Curr_Pos_Glut-1)!=220&&(Curr_Pos_Glut-1)!=203&&(Curr_Pos_Glut-1)!=186&&(Curr_Pos_Glut-1)!=169&&(Curr_Pos_Glut-1)!=152&&(Curr_Pos_Glut-1)!=135&&(Curr_Pos_Glut-1)!=118&&(Curr_Pos_Glut-1)!=101&&(Curr_Pos_Glut-1)!=84&&(Curr_Pos_Glut-1)!=67&&(Curr_Pos_Glut-1)!=50&&(Curr_Pos_Glut-1)!=33&&(Curr_Pos_Glut-1)!=16) )
               {
            if(Dot_Squares[Curr_Pos_Glut-1]==1)
            {snd(loop);Score+=10;}
            else
            delay(40);
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            tyt++;
            Curr_Pos_Glut--;
            if(Glutton_Mode==1)
            {
                if(Curr_Pos_Glut%3==0)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_1,0);
                else if(Curr_Pos_Glut%3==0)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_2,0);
                else
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_3,0);
            }
            else
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);
            Dot_Squares[Curr_Pos_Glut]=0;
            get=Check_For_Level_Completion();
            if(get==1){
            sleep(1);
            putimage(x-12-27*d_txt[0],y-12-27*d_tyt[0],Blank_Replacer,0);
            putimage(x-12-27*d_txt[1],y-12-27*d_tyt[1],Blank_Replacer,0);
            putimage(x-12-27*d_txt[2],y-12-27*d_tyt[2],Blank_Replacer,0);
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            return 1;
            }
            Column_Number=Column_Detector(Curr_Pos_Glut);
            Row_Number=Row_Detector(Curr_Pos_Glut);
               } break;
    case LEFT:           if(Glutton_Squares[Curr_Pos_Glut-17]==1&&!((Curr_Pos_Glut)>=0&&(Curr_Pos_Glut)<=16))
               {
            if(Dot_Squares[Curr_Pos_Glut-17]==1)
            {snd(loop);Score+=10;}
            else
            delay(40);
            Dot_Squares[Curr_Pos_Glut]=0;
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            txt++;
            Curr_Pos_Glut-=17;
            if(Glutton_Mode==1)
            {
                if(Curr_Pos_Glut%3==0)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_1,0);
                else if(Curr_Pos_Glut%3==1)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_2,0);
                else
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_3,0);
            }
            else
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);
            Dot_Squares[Curr_Pos_Glut]=0;
            get=Check_For_Level_Completion();
            if(get==1){
            sleep(1);
            putimage(x-12-27*d_txt[0],y-12-27*d_tyt[0],Blank_Replacer,0);
            putimage(x-12-27*d_txt[1],y-12-27*d_tyt[1],Blank_Replacer,0);
            putimage(x-12-27*d_txt[2],y-12-27*d_tyt[2],Blank_Replacer,0);
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            return 1;
            }
            Column_Number=Column_Detector(Curr_Pos_Glut);
            Row_Number=Row_Detector(Curr_Pos_Glut);
               }
               if(Curr_Pos_Glut==229)
               {
            sound(500);
            delay(40);
            nosound();
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            txt=5;
            tyt=5;
            Curr_Pos_Glut=59;
            if(Glutton_Mode==1)
            {
                if(Curr_Pos_Glut%3==0)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_1,0);
                else if(Curr_Pos_Glut%3==1)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_2,0);
                else
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_3,0);
            }
            else
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);
            Column_Number=Column_Detector(Curr_Pos_Glut);
            Row_Number=Row_Detector(Curr_Pos_Glut);
               }

               break;

    case DOWN:           if(Glutton_Squares[Curr_Pos_Glut+1]==1&&( (Curr_Pos_Glut+1)!=289&&(Curr_Pos_Glut+1)!=272&&(Curr_Pos_Glut+1)!=255&&(Curr_Pos_Glut+1)!=238&&(Curr_Pos_Glut+1)!=221&&(Curr_Pos_Glut+1)!=204&&(Curr_Pos_Glut+1)!=187&&(Curr_Pos_Glut+1)!=170&&(Curr_Pos_Glut+1)!=153&&(Curr_Pos_Glut+1)!=136&&(Curr_Pos_Glut+1)!=119&&(Curr_Pos_Glut+1)!=102&&(Curr_Pos_Glut+1)!=85&&(Curr_Pos_Glut+1)!=68&&(Curr_Pos_Glut+1)!=51&&(Curr_Pos_Glut+1)!=34&&(Curr_Pos_Glut+1)!=17) )
               {
            if(Dot_Squares[Curr_Pos_Glut+1]==1)
            {snd(loop);Score+=10;}
            else
            delay(40);
            Dot_Squares[Curr_Pos_Glut]=0;
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            tyt--;
            Curr_Pos_Glut++;
            if(Glutton_Mode==1)
            {
                if(Curr_Pos_Glut%3==0)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_1,0);
                else if(Curr_Pos_Glut%3==1)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_2,0);
                else
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_3,0);
            }
            else
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);
            Dot_Squares[Curr_Pos_Glut]=0;
            get=Check_For_Level_Completion();
            if(get==1){
            sleep(1);
            putimage(x-12-27*d_txt[0],y-12-27*d_tyt[0],Blank_Replacer,0);
            putimage(x-12-27*d_txt[1],y-12-27*d_tyt[1],Blank_Replacer,0);
            putimage(x-12-27*d_txt[2],y-12-27*d_tyt[2],Blank_Replacer,0);
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            return 1;
            }
            Column_Number=Column_Detector(Curr_Pos_Glut);
            Row_Number=Row_Detector(Curr_Pos_Glut);
               } break;

    case RIGHT:           if(Glutton_Squares[Curr_Pos_Glut+17]==1&&!((Curr_Pos_Glut)>=272&&(Curr_Pos_Glut)<=288))
               {
            if(Dot_Squares[Curr_Pos_Glut+17]==1)
            {snd(loop);Score+=10;}
            else
            delay(40);
            Dot_Squares[Curr_Pos_Glut]=0;
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            txt--;
            Curr_Pos_Glut+=17;
            if(Glutton_Mode==1)
            {
                if(Curr_Pos_Glut%3==0)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_1,0);
                else if(Curr_Pos_Glut%3==1)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_2,0);
                else
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_3,0);
            }
            else
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);
            Dot_Squares[Curr_Pos_Glut]=0;
            get=Check_For_Level_Completion();
            if(get==1){
            sleep(1);
            putimage(x-12-27*d_txt[0],y-12-27*d_tyt[0],Blank_Replacer,0);
            putimage(x-12-27*d_txt[1],y-12-27*d_tyt[1],Blank_Replacer,0);
            putimage(x-12-27*d_txt[2],y-12-27*d_tyt[2],Blank_Replacer,0);
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            return 1;
            }
            Column_Number=Column_Detector(Curr_Pos_Glut);
            Row_Number=Row_Detector(Curr_Pos_Glut);
               }
               if(Curr_Pos_Glut==59)
               {
            sound(500);
            delay(40);
            nosound();
            putimage(x-11-27*txt,y+123-27*tyt,Blank_Replacer,0);
            txt=-5;
            tyt=5;
            Curr_Pos_Glut=229;
            if(Glutton_Mode==1)
            {
                if(Curr_Pos_Glut%3==0)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_1,0);
                else if(Curr_Pos_Glut%3==1)
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_2,0);
                else
                putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_3,0);
            }
            else
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);
            Column_Number=Column_Detector(Curr_Pos_Glut);
            Row_Number=Row_Detector(Curr_Pos_Glut);
               }
               break;

    default:           break;
    }
    return 0;
}
void Glutton_Gets_Power()
{

int Demon_Runs_Back=0;

if(Curr_Pos_Glut==36&&Power_Dot_Status_1==1)
{
 Power_Dot_Status_1=0;
 Power_Dot_Status_1=0;
 Demon_Runs_Back=1;
 Power_Mode_Timer=loop;
 Glutton_Mode=2;
 Sound_Mode_Conversion();
 putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);
}
if(Curr_Pos_Glut==48&&Power_Dot_Status_2==1)
{
 Power_Dot_Status_2=0;
 Power_Dot_Status_2=0;
 Demon_Runs_Back=1;
 Power_Mode_Timer=loop;
 Glutton_Mode=2;
 Sound_Mode_Conversion();
 putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);

}
if(Curr_Pos_Glut==240&&Power_Dot_Status_3==1)
{
 Power_Dot_Status_3=0;
 Power_Dot_Status_3=0;
 Demon_Runs_Back=1;
 Power_Mode_Timer=loop;
 Glutton_Mode=2;
 Sound_Mode_Conversion();
 putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);
}
if(Curr_Pos_Glut==252&&Power_Dot_Status_4==1)
{
 Power_Dot_Status_4=0;
 Power_Dot_Status_4=0;
 Demon_Runs_Back=1;
 Power_Mode_Timer=loop;
 Glutton_Mode=2;
 Sound_Mode_Conversion();
 putimage(x-11-27*txt,y+123-27*tyt,Glut_Power,0);
}
if(Glutton_Mode==2&&Demon_Runs_Back==1)
{
Demon_Runs_Back=0;
    if(Dir_Demon[0]==1)
    Dir_Demon[0]=3;
    else if(Dir_Demon[0]==2)
    Dir_Demon[0]=4;
    else if(Dir_Demon[0]==3)
    Dir_Demon[0]=1;
    else
    Dir_Demon[0]=2;

    if(Dir_Demon[1]==1)
    Dir_Demon[1]=3;
    else if(Dir_Demon[1]==2)
    Dir_Demon[1]=4;
    else if(Dir_Demon[1]==3)
    Dir_Demon[1]=1;
    else
    Dir_Demon[1]=2;

    if(Dir_Demon[2]==1)
    Dir_Demon[2]=3;
    else if(Dir_Demon[2]==2)
    Dir_Demon[2]=4;
    else if(Dir_Demon[2]==3)
    Dir_Demon[2]=1;
    else
    Dir_Demon[2]=2;
}

}
void Glutton_Loses_Power()
{
if(Level<=10)
{if(loop==Power_Mode_Timer+33-Level*3)
    {
     Glutton_Mode=1;
     Power_Mode_Timer=0;
        if(Curr_Pos_Glut%3==0)
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_1,0);
            else if(Curr_Pos_Glut%3==0)
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_2,0);
            else
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_3,0);

    }}
else
if(loop==Power_Mode_Timer+2)
    {
     Glutton_Mode=1;
     Power_Mode_Timer=0;
            if(Curr_Pos_Glut%3==0)
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_1,0);
            else if(Curr_Pos_Glut%3==0)
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_2,0);
            else
            putimage(x-11-27*txt,y+123-27*tyt,Glut_Face_3,0);

    }
}
void Demon_Director()
{
int ran;
randomize();
ran=random(10);
if(ran%10==0)
    {Dir_Demon[0]=1;Dir_Demon[1]=4;Dir_Demon[2]=1;}
else if(ran%10==1)
    {Dir_Demon[0]=2;Dir_Demon[1]=2;Dir_Demon[2]=1;}
else if(ran%10==2)
    {Dir_Demon[0]=2;Dir_Demon[1]=1;Dir_Demon[2]=4;}
else if(ran%10==3)
    {Dir_Demon[0]=1;Dir_Demon[1]=4;Dir_Demon[2]=1;}
else if(ran%10==4)
    {Dir_Demon[0]=4;Dir_Demon[1]=1;Dir_Demon[2]=2;}
else if(ran%10==5)
    {Dir_Demon[0]=4;Dir_Demon[1]=2;Dir_Demon[2]=2;}
else if(ran%10==6)
    {Dir_Demon[0]=1;Dir_Demon[1]=4;Dir_Demon[2]=4;}
else if(ran%10==7)
    {Dir_Demon[0]=1;Dir_Demon[1]=2;Dir_Demon[2]=1;}
else if(ran%10==8)
    {Dir_Demon[0]=1;Dir_Demon[1]=1;Dir_Demon[2]=4;}
else
    {Dir_Demon[0]=4;Dir_Demon[1]=1;Dir_Demon[2]=2;}
}
void Bonus_Awarder()
{

 if(Bonus_Counter>loop)
 Bonus_Counter++;
 else if(Bonus_Counter
 Bonus_Counter=loop;

if(Bonus_Counter==120||Bonus==1)
{
    setcolor(Level);
    setfillstyle(SOLID_FILL,Level);
    circle(x,y+108,5);
    circle(x-3,y+108,3);
    circle(x+3,y+108,3);
    circle(x,y+108-3,3);
    circle(x,y+108+3,3);
    Bonus=1;
}

if(Bonus_Counter==155&&Bonus==1)
{
    putimage(x-12,y+96,Blank_Replacer,0);
    Bonus=0;
}

if(Bonus==1&&Curr_Pos_Glut==148)
{
 Score+=(Level*500);
 for(int o=0;o<15;o++)
 {
 sound(450+20*o);
 delay(4);
 }
 nosound();
 Bonus=0;
}
}

Comments (0)

Post a Comment

Copyright © 2009 virtualinfocom All rights reserved. Theme by Games. | animation Ani2Pix.