Tuesday, 31 January 2017

Angel and Devil game using c graphics

Hi friends,
this is the source code of Angel and Devil game ,to check , how this code run go to below given  link.
                              ((         https://youtu.be/4fXWh1_lS6E        ))
   #include<stdio.h>
   #include<conio.h>
   #include<graphics.h
   #include<stdlib.h>
   #include<dos.h>
 #include<process.h>
   #include<time.h>
   void angdev();
   void angle1(int,int,int,int,int);
   void angle2(int,int,int,int,int);
   void devil();
   void devil1(int,int,int,int,int,int,int);
   void devil2(int,int,int,int,int,int,int);
   void destin1(int,int,int,int);
   void destin2(int,int,int,int);
   void second();
   void alert3();
   void tune4();
   void tune5();
   void tune6();
   void smile(int v,int w,int r,int s,int t)
   {
   setcolor(r);
   setfillstyle(1,s);
   circle(v,w,35);
   floodfill(v,w,r);
   arc(v,w,225,315,20);
   arc(v,w,225,315,19);
 setfillstyle(1,r);
   circle((v-15),(w-15),3);
   circle((v+15),(w-15),3);
   floodfill((v-15),(w-15),r);
   floodfill((v+15),(w-15),r);
   setcolor(t);
   setfillstyle(1,t);
   circle((v-15),(w-15),2);
   circle((v+15),(w-15),2);
   floodfill((v-15),(w-15),t);
   floodfill((v+15),(w-15),t);
   }
   void happy(int v,int w,int r,int s,int t)
   {
   setcolor(r);
   setfillstyle(1,s);
   circle(v,w,35);
   floodfill(v,w,r);
   arc(v,w,225,315,25);
   arc(v,w,235,305,24);
   setcolor(t);
   setfillstyle(1,t);
   circle(v-22,w+5,7);
   circle(v+22,w+5,7);
   floodfill(v-22,w+5,t);
   floodfill(v+22,w+5,t);
   setcolor(r);
   arc(v-10,w,55,125,8);
   arc(v+10,w,55,125,8);
   }
   void sad(int v,int w,int r,int s,int t )
   {
   setcolor(r);
   setfillstyle(1,s);
   circle(v,w,35);
   floodfill(v,w,r);
   arc(v,w+35,47,130,20);
   arc(v,w+35,50,125,21);
  setfillstyle(1,r);
   circle(v-15,w-15,3);
   circle(v+15,w-15,3);
   floodfill(v-15,w-15,r);
   floodfill(v+15,w-15,r);
   setcolor(t);
   setfillstyle(1,t);
   circle(v-15,w-15,2);
   circle(v+15,w-15,2);
   floodfill(v-15,w-15,t);
   floodfill(v+15,w-15,t);
   }
   void quit()
   {
   int a,i;
   char n[5];
   cleardevice();
   setbkcolor(1);
   setcolor(14);
   settextstyle(1,HORIZ_DIR,5);
   outtextxy(200,200,"QUITING......");
   for(i=5;i>=0;i=i-1)
   {
   tune6();
   setcolor(4);
   sprintf(n,"%d",i);
   outtextxy(250,270,n);
   delay(800);
   setcolor(1);
   outtextxy(250,270,n);
   }
   delay(100);
   }
   void start()
   {
   int i,x,y,j;
   cleardevice();
   setbkcolor(14);
   for(i=1;i<=100;i=i+5)
   {
   x=250,y=0;
   setcolor(1);
   settextstyle(1,HORIZ_DIR,3);
   outtextxy(x,y+i,"WELCOME");
   delay(20);
   setcolor(14);
   outtextxy(x,y+i,"WELCOME");
   }
   setcolor(1);
   settextstyle(1,HORIZ_DIR,3);
   outtextxy(x,100,"WELCOME");
   for(i=1;i<=350;i=i+5)
   {
   x=500,y=130;
   setcolor(2);
   settextstyle(8,HORIZ_DIR,3);
   outtextxy(x-i,y,"HOPE YOU WILL ENJOY IT");
   delay(10);
   setcolor(14);
   outtextxy(x-i,y,"HOPE YOU WILL ENJOY IT");
   }
   setcolor(2);
   settextstyle(8,HORIZ_DIR,3);
   outtextxy(150,130,"HOPE YOU WILL ENJOY IT");
   delay(50);
   setcolor(1);
   settextstyle(1,HORIZ_DIR,1);
   outtextxy(50,200,"INSTRUCTION..");
   while(!kbhit())
   {
   setcolor(15);
   setfillstyle(1,15);
   line(100,250,130,280);
   line(130,280,70,280);
   line(70,280,100,250);
   floodfill(100,270,15);
   setcolor(6);
   settextstyle(1,HORIZ_DIR,1);
   outtextxy(150,250,"PRESS this key to roll dice");
   outtextxy(50,300,"1.  6 and 1 gives another turn.");
   outtextxy(50,320,"2.  Coin start on coming 1.");
   outtextxy(50,340,"3.  Angels make your path easy.");
   outtextxy(50,360,"4.  Devils make your path tough.");
   outtextxy(50,380,"5.  Blinking of starting point decide the chance.");
   setcolor(1);
   outtextxy(100,420,"PRESS any key to continue....");
   delay(500);
   setcolor(14);
   outtextxy(100,420,"PRESS any key to continue....");
   tune5();
   }
   alert3();
   delay(500);
   cleardevice();
   second();
   exit(0);
   }
   void control()
   {
   int ch;
   cleardevice();
   setbkcolor(1);
   while(!kbhit())
   {
   setcolor(14);
   settextstyle(1,HORIZ_DIR,2);
   outtextxy(200,200,"PRESS ENTER to start");
   delay(500);
   setcolor(1);
   outtextxy(200,200,"PRESS ENTER to start");
   delay(100);
   setcolor(14);
   outtextxy(200,230,"PRESS ESC to exit");
   delay(500);
   setcolor(1);
   outtextxy(200,230,"PRESS ESC to exit");
   delay(100);
   }
   if(kbhit())
   {
   ch=getch();
   if(ch==27)
   {
   alert3();
   delay(500);
   cleardevice();
   quit();
   exit(0);
   }
   if(ch==13)
   {
   alert3();
   delay(500);
   cleardevice();
   start();
   getch();
   exit(0);
   }
   }
   }
   void first()
   {
   int ch,i,j,k=1,z,w,x,y,gd=0,gm;
   char a[5];
   initgraph(&gd,&gm,"c:\\turboc3\\bgi");
   setbkcolor(4);
   x=0,y=200,z=630,w=230;
   for(i=0;i<=300;i=i+2)
   {
   settextstyle(1,HORIZ_DIR,3);
   setcolor(14);
   outtextxy(x+i,y,"KHEEM");
   setcolor(1);
   outtextxy(z-i,w,"PRESENTS");
   delay(10);
   setcolor(0);
   outtextxy(x+i,y,"KHEEM");
   outtextxy(z-i,w,"PRESENTS");
   }
   setcolor(14);
   outtextxy(300,y,"KHEEM");
   setcolor(1);
   outtextxy(330,w,"PRESENTS");
   delay(800);
   cleardevice();
   x=100,y=0;
   for(i=0;i<=100;i=i+5)
   {
   settextstyle(1,HORIZ_DIR,6);
   setcolor(3);
   outtextxy(x,y+i,"ANGEL");
   delay(40);
   setcolor(4);
   outtextxy(x,y+i,"ANGEL");
   }
   setcolor(3);
   outtextxy(x,100,"ANGEL");
   for(i=1;i<=8;i++)
   {
   setcolor(3);
   settextstyle(1,HORIZ_DIR,i);
   outtextxy(250,175,"AND");
   delay(200);
   setcolor(4);
   outtextxy(250,175,"AND");
   }
   setcolor(3);
   outtextxy(250,175,"AND");
   x=0,y=300,z=580,w=300;
   for(i=0;i<=200;i=i+5)
   {
   setcolor(3);
   settextstyle(1,HORIZ_DIR,6);
   outtextxy(x+i,y,"DEVIL");
   setcolor(3);
   outtextxy(z-i,w,"GAME");
   delay(30);
   setcolor(4);
   outtextxy(x+i,y,"DEVIL");
   outtextxy(z-i,w,"GAME");
   }
   setcolor(3);
   outtextxy(200,300,"DEVIL");
   setcolor(3);
   outtextxy(380,300,"GAME");
   delay(1000);
   cleardevice();
   setcolor(3);
   settextstyle(1,HORIZ_DIR,5);
   outtextxy(250,200,"ANGEL AND DEVIL");
   outtextxy(350,250,"GAME");
   setcolor(1);
   settextstyle(3,HORIZ_DIR,2);
   outtextxy(100,100,"KHEEM");
   outtextxy(120,120,"PRESENTS");
   for(j=1;j<=100;j++)
   {
   for(i=k;i<=(k+2);i++)
   {
   setcolor(3);
   outtextxy(40,400,"Loading....");
   setcolor(1);
   setfillstyle(1,1);
   circle(150+i,420,1);
   floodfill(150+i,420,1);
   delay(10);
   }
   setcolor(1);
   sprintf(a,"%d",j);
   outtextxy(458,390,a);
   delay(30);
   setcolor(4);
   outtextxy(458,390,a);
   setcolor(1);
   outtextxy(500,390,"%");
   k=i;
   }
   outtextxy(458,390,a);
   delay(500);
   control();
   getch();
   }
   void draw1(int g,int h)
   {
    setcolor(15);
      setfillstyle(1,1);
      circle(g,h,8);
      floodfill(g,h,15);
    }
    void draw2(int e,int f)
    {
     setcolor(15);
      setfillstyle(1,2);
      circle(e,f,8);
      floodfill(e,f,15);
    }
  void result(char *name,int s)
   {
   int x=250,y=0,z=150,w,v,r,t,i;
   char a[100];
   cleardevice();
   setbkcolor(9);
   v=100,w=250,r=15,t=12;
   happy(v,w,r,s,t);
   for(i=0;i<=200;i=i+3)
   {
   w=450;
   setcolor(14);
   settextstyle(1,HORIZ_DIR,6);
   outtextxy(x,y+i,"CONGRATS !");
   sprintf(a,"%s",name);
   outtextxy(z,w-i,a);
   delay(10);
   setcolor(9);
   outtextxy(x,y+i,"CONGRATS !");
   outtextxy(z,w-i,a);
   }
   setcolor(14);
   outtextxy(x,200,"CONGRATS !");
   setcolor(1);
   outtextxy(z,250,a);
   delay(3000);
   control();
   getch();
   }
   void alert1()
   {
   int i;
   for(i=1000;i<=1400;i=i+50)
   {
   sound(i);
   delay(20);
   }
   nosound();
   }
   void alert2()
   {
   int i;
   for(i=300;i<=700;i=i+50)
   {
   sound(i);
   delay(100);
   }
   nosound();
   }
   void alert3()
   {
   int i;
   for(i=200;i<=300;i=i+20)
   {
   sound(i);
   delay(20);
   }
   nosound();
   }
   void tune1()
   {
   int i;
   for(i=500;i<=640;i=i+20)
   {
   sound(i);
   delay(30);
   }
   nosound();
   }
   void tune2()
   {
   int i,a=0;
   while(a<6)
   {
   for(i=550;i<=800;i=i+60)
   {
   sound(i);
   delay(35);
   }
   a=a+1;
   }
   nosound();
   }
   void tune3()
   {
    int i;
    for(i=2300;i<=2700;i=i+20)
    {
    sound(i);
    delay(100);
    }
    nosound();
    }
    void tune4()
    {
    int i,j,a=0;
    while(a<5)
    {
    for(i=500;i<1000;i=i+60)
    {
    sound(i);
    delay(100);
    }
    for(j=1000;j<=1500;j=j+30)
    {
    sound(j);
    delay(40);
    }
    a=a+1;
    }
    nosound();
    }
    void tune5()
    {
    int i,j;
    for(i=600;i<=620;i=i+20)
    {
    sound(i);
    delay(150);
    for(j=500;j<=520;j=j+20);
    {
    sound(j);
    delay(20);
    }
    }
    nosound();
    }
    void tune6()
    {
    int i;
    for(i=700;i<=800;i=i+30)
    {
    sound(i);
    delay(30);
    }
    nosound();
    }
   void sign1()
   {
   setcolor(15);
   setfillstyle(1,1);
   pieslice(73,85,0,360,15);
   }
   void sign2()
   {
   setcolor(15);
   setfillstyle(1,2);
   pieslice(73,85,0,360,15);
   }
   void layout()
   {
   int i,j;
   setcolor(15);
   rectangle(95,15,545,465);
   for(i=45;i<=450;i=i+45)
   {
   line(95,15+i,545,15+i);
   }
   for(j=45;j<=450;j=j+45)
   {
   line(95+j,15,95+j,465);
   }
   }
   void color()
   {
   int i,j,v,x,y;
   for(i=45;i<=450;i=i+45)
   {
   for(j=45;j<=450;j=j+45)
   {
   v=random(14);
   if(v==0)
   {
   v=v+12;
   }
   x=(95+i)-10;
   y=(15+j)-10;
   setfillstyle(1,v);
   floodfill(x,y,15);
   }
   }
   setfillstyle(1,4);
   floodfill(130,50,15);
   setfillstyle(1,2);
   floodfill(130,455,15);
   outtextxy(100,454,"START");
   outtextxy(100,49,"END");
    angdev();
   }
   void design()
   {
   setcolor(14);
   settextstyle(0,HORIZ_DIR,1);
   outtextxy(0,240,"Designed");
   outtextxy(0,260,"     by...");
   outtextxy(0,280,"Kheem");
   outtextxy(0,300,"   singh");
   outtextxy(0,320,"B_TECH");
   outtextxy(0,340,"   (ECE)");
   outtextxy(0,360,"AIACTR");
   }
   void boundary()
   {
   setcolor(15);
   setfillstyle(1,6);
   rectangle(92,12,548,468);
   floodfill(94,14,15);
   setfillstyle(9,14);
   rectangle(88,8,552,472);
   floodfill(89,9,15);
   }
   void numbering()
   {
   int r,s=111,x,y,i,j;
   char a[5],b[5];
   setcolor(15);
   for(i=45;i<=450;i=i+45)
   {
    if((i%2)!=0)
    {
    r=(s-1)-10;
    for(j=45;j<=450;j=j+45)
    {
    x=(95+j)-40;
    y=(15+i)-40;
    sprintf(a,"%d",r);
    outtextxy(x,y,a);
    r=(r-1);
    }
    }
    if((i%2)==0)
     {
     s=(r+1)-10;
     for(j=45;j<=450;j=j+45)
     {
     x=(95+j)-40;
     y=(15+i)-40;
     sprintf(b,"%d",s);
     outtextxy(x,y,b);
     s=s+1;
     }
     }
     }
     }
     void goti1()
     {
     int g=73,h=445;
     setcolor(1);
     circle(g,h,15);
     setcolor(15);
     setfillstyle(1,1);
     circle(g,h,8);
     floodfill(g,h,15);
     }
     void goti2()
     {
     int e=73,f=400;
     setcolor(2);
     circle(e,f,15);
     setcolor(15);
     setfillstyle(1,2);
     circle(e,f,8);
     floodfill(e,f,15);
     }
     void blink1()
     {
     setcolor(15);
     circle(73,445,15);
     delay(50);
     setcolor(1);
     circle(73,445,15);
     delay(100);
     }
     void blink2()
     {
     setcolor(15);
     circle(73,400,15);
     delay(50);
     setcolor(2);
     circle(73,400,15);
     delay(100);
     }
     void clear1(int k,int g,int h)
     {
     setcolor(k);
     setfillstyle(1,k);
     circle(g,h,8);
     floodfill(g,h,k);
     }
     void clear2(int z,int e,int f)
     {
     setcolor(z);
     setfillstyle(1,z);
     circle(e,f,8);
     floodfill(e,f,z);
    }
    void box(int s)
    {
    setcolor(15);
    setfillstyle(1,s);
    bar3d(560,315,620,375,10,1);
    }
    void one()                  //one circle prints on dice
    {
    setcolor(15);
    setfillstyle(1,15);
    circle(590,345,5);
    floodfill(590,345,15);
    }
    void two ()                 //two circle prints on dice
    {
    setcolor(15);
    setfillstyle(1,15);
    circle(575,345,5);
    circle(605,345,5);
    floodfill(575,345,15);
    floodfill(605,345,15);
    }
    void three()                //three circle prints on dice
    {
    setcolor(15);
    setfillstyle(1,15);
    circle(590,325,5);
    circle(590,345,5);
    circle(590,365,5);
    floodfill(590,325,15);
    floodfill(590,345,15);
    floodfill(590,365,15);
    }
    void four()                 //four circle prints on dice
    {
    setcolor(15);
    setfillstyle(1,15);
    circle(575,325,5);
    circle(605,325,5);
    circle(575,365,5);
    circle(605,365,5);
    floodfill(575,325,15);
    floodfill(605,325,15);
    floodfill(575,365,15);
    floodfill(605,365,15);
    }
    void five()                 //five circle prints on dice
    {
    setcolor(15);
    setfillstyle(1,15);
    circle(575,325,5);
    circle(605,325,5);
    circle(575,365,5);
    circle(605,365,5);
    circle(590,345,5);
    floodfill(575,325,15);
    floodfill(605,325,15);
    floodfill(575,365,15);
    floodfill(605,365,15);
    floodfill(590,345,15);
    }
    void six()                  //six circle prints on dice
    {
    setcolor(15);
    setfillstyle(1,15);
    circle(575,325,5);
    circle(605,325,5);
    circle(575,365,5);
    circle(605,365,5);
    circle(575,345,5);
    circle(605,345,5);
    floodfill(575,325,15);
    floodfill(605,325,15);
    floodfill(575,365,15);
    floodfill(605,365,15);
    floodfill(575,345,15);
    floodfill(605,345,15);
    }
     void second()
     {
     int gd=0,gm,i,l=0,m=0,o=0,p=0,e=73,f=400,n=1,k,z,ch,u,g=73,h=445,r,s=1,t,v,w;
     char c[5],d[5];
     initgraph(&gd,&gm,"c:\\turboc3\\bgi");
     layout();
     color();
     numbering();
     boundary();
     goti1();
     goti2();
     design();
     v=590,w=60,r=15,s=1,t=0;
     smile(v,w,r,s,t);
     v=590,w=240,r=15,s=2,t=0;
     smile(v,w,r,s,t);
     for(i=1;i!=0;i++)
     {
     if((i%2)!=0)                   //Blue player turn starts now
     {
     n=1;
     sign1();
     v=590,w=60,r=0,s=0,t=0;
     happy(v,w,r,s,t);
     sad(v,w,r,s,t);
     v=590,w=60,r=15,s=1,t=0;
     smile(v,w,r,s,t);
     while((n==1)||(n==6))
     {
     s=1;
     box(s);
     while(!kbhit())
     {
     blink1();
     }
     ch=getch();
     if(ch==72)
     {
     n=random(7);
     alert2();
     if(n==0)
     {
     n=(n+4);
     }
     setcolor(15);
     sprintf(c,"%d",n);
     outtextxy(67,85,c);
     if(n==1)                     //circles print on dice same as value of n
     {
     one();
     }
     if(n==2)
     {
     two();
     }
     if (n==3)
     {
      three();
     }
     if (n==4)
     {
     four();
     }
     if(n==5)
     {
     five();
     }
     if(n==6)
     {
     six();
     }
     delay(500);
     sign1();
     for(u=1;u<=n;u++)
     {
      k=getpixel(g+10,h+10);
     if(l<=0)
     {
     if(n==1)
     {
     l=l+45;
     m=0;
     clear1(k,g,h);
     goto next1;
     }
     else
     {
     alert1();
     break;
     }
     }
     if((l>0)&&((g!=118)||(h!=40)))
     {
     if(((m%2)==0)&&(l<450))
     {
     l=l+45;
     m=m+0;
     clear1(k,g,h);
     goto next1;
     }
     if(((m%2)==0)&&(l==450))
     {
     m=m+45;
     l=l+0;
     clear1(k,g,h);
     goto next1;
     }
     if(((m%2)!=0)&&(l>45))
     {
     l=l-45;
     m=m+0;
     clear1(k,g,h);
       goto next1;
     }
     if(((m%2)!=0)&&(l==45))
     {
     m=m+45;
     l=l+0;
     clear1(k,g,h);
     goto next1;
     }
     }
       if(((g==118)&&(h==40))&&((u-1)!=n))
     {
     l=(u)*45;
     m=m+0;
     clear1(k,g,h);
     goto next1;
     }
     next1:
     if(((g==e)&&(h==f))&&(u>(n-6)))
     {
    draw2(e,f);
     }
     g=(95+l)-22;
     h=(465-m)-20;
    draw1(g,h);
    tune1();
      if(((g==118)&&(h==40))&&(u==n))
     {
     char name[]="BLUE PLAYER WINS";
     v=590,w=60,r=0,s=0,t=0;
     smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=12;
     happy(v,w,r,s,t);
     tune4();
     result(name,s);
     }
     if(((g==e)&&(h==f))&&(u==n))
     {
     o=0;
     p=0;
     e=73;
     f=400;
     goti2();
     tune2();
     }
     if(((g==478)&&(h==445))&&(u==n))
     {
      v=590,w=60,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=12;
     happy(v,w,r,s,t);
     l=450;
     m=135;
     k=getpixel(g+10,h+10);
     tune3();
     clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
       }
     if(((g==433)&&(h==355))&&(u==n))
     {
      v=590,w=60,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=12;
     happy(v,w,r,s,t);
     l=180;
     m=360;
     k=getpixel(g+10,h+10);
     tune3();
      clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
     }
     if(((g==118)&&(h==265))&&(u==n))
     {
      v=590,w=60,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=12;
     happy(v,w,r,s,t);
     l=315;
     m=270;
    k= getpixel(g+10,h+10);
    tune3();
     clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
     }
     if(((g==208)&&(h==175))&&(u==n))
     {
      v=590,w=60,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=12;
     happy(v,w,r,s,t);
     l=45;
     m=360;
    k= getpixel(g+10,h+10);
    tune3();
     clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
     }
      if(((g==523)&&(h==130))&&(u==n))
     {
       v=590,w=60,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=12;
     happy(v,w,r,s,t);
     l=450;
     m=405;
    k= getpixel(g+10,h+10);
    tune3();
     clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
     }
      if(((g==253)&&(h==400))&&(u==n))
     {
       v=590,w=60,r=0,s=0,t=0;
     smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=0;
     sad(v,w,r,s,t);
     l=315;
     m=0;
    k= getpixel(g+10,h+10);
    tune2();
     clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
     }
      if(((g==253)&&(h==310))&&(u==n))
     {
       v=590,w=60,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=0;
     sad(v,w,r,s,t);
     l=450;
     m=45;
    k= getpixel(g+10,h+10);
   tune2();
     clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
     }
      if(((g==388)&&(h==220))&&(u==n))
     {
       v=590,w=60,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=0;
     sad(v,w,r,s,t);
     l=315;
     m=135;
    k= getpixel(g+10,h+10);
    tune2();
     clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
     }
      if(((g==388)&&(h==85))&&(u==n))
     {
       v=590,w=60,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=0;
     sad(v,w,r,s,t);
     l=180;
     m=90;
    k= getpixel(g+10,h+10);
    tune2();
     clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
     }
      if(((g==163)&&(h==40))&&(u==n))
     {
       v=590,w=60,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=60,r=15,s=1,t=0;
     sad(v,w,r,s,t);
     l=135;
     m=315;
    k= getpixel(g+10,h+10);
    tune2();
     clear1(k,g,h);
     g=(95+l)-22;
     h=(465-m)-20;
     delay(300);
     draw1(g,h);
     }
     delay(200);
     }
     }
     if(ch==27)
     {
     exit(0);
     }
     }
     }
     if((i%2)==0)            //Green player turn starts now
     {
     n=1;
     sign2();
       v=590,w=240,r=0,s=0,t=0;
      sad(v,w,r,s,t);
     happy(v,w,r,s,t);
     v=590,w=240,r=15,s=2,t=0;
     smile(v,w,r,s,t);
     while((n==1)||(n==6))
     {
      s=2;
      box(s);
      while(!kbhit())
      {
      blink2();
      }
     ch=getch();
     if(ch==72)
     {
     n=random(7);
     alert2();
     if(n==0)
     {
     n=n+4;
     }
     setcolor(15);
     sprintf(d,"%d",n);
     outtextxy(67,85,d);
     if(n==1)                    //circle print on dice same as value of n
     {
     one();
     }
     if(n==2)
     {
     two();
     }
     if (n==3)
     {
      three();
     }
     if (n==4)
     {
     four();
     }
     if(n==5)
     {
     five();
     }
     if(n==6)
     {
     six();
     }
     delay(500);
     sign2();
     for(u=1;u<=n;u++)
     {
     z=getpixel(e+10,f+10);
     if(o==0)
     {
     if(n==1)
     {
     o=o+45;
     p=0;
     clear2(z,e,f);
     goto next2;
     }
     else
     {
     alert1();
     break;
     }
     }
     if((o>0)&&((e!=118)||(f!=60)))
     {
     if(((p%2)==0)&&(o<450))
     {
     o=o+45;
     p=p+0;
     clear2(z,e,f);
     goto next2;
     }
     if(((p%2)==0)&&(o==450))
     {
     p=p+45;
     o=o+0;
     clear2(z,e,f);
     goto next2;
     }
     if(((p%2)!=0)&&(o>45))
     {
     o=o-45;
     p=p+0;
     clear2(z,e,f);
     goto next2;
     }
     if(((p%2)!=0)&&(o==45))
     {
     p=p+45;
     o=o+0;
     clear2(z,e,f);
     goto next2;
     }
     }
     if(((e==118)&&(f==60))&&((u-1)!=n))
     {
     o=(u)*45;
     p=p+0;
     clear2(z,e,f);
     goto next2;
     }
     next2:
      if(((e==g)&&(f==g))&&(u>(n-6)))
     {
    draw1(g,h);
     }
     e=(95+o)-22;
     f=(465-p)-20;
     draw2(e,f);
     tune1();
      if(((e==118)&&(f==60))&&(u==n))
     {
     char name[]="GREEN PLAYER WINS";
     alert2();
     v=590,w=240,r=0,s=0,t=0;
     smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=12;
     happy(v,w,r,s,t);
     tune4();
     result(name,s);
     }
     if(((e==g)&&(f==h))&&(u==n))
     {
     l=0;
     m=0;
     g=73;
     h=445;
     goti1();
     tune2();
     }
      if(((e==478)&&(f==445))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=12;
     happy(v,w,r,s,t);
     o=450;
     p=135;
    z= getpixel(e+10,f+10);
     tune3();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }
      if(((e==433)&&(f==355))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=12;
     happy(v,w,r,s,t);
     o=180;
     p=360;
    z= getpixel(e+10,f+10);
    tune3();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }
      if(((e==118)&&(f==265))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=12;
     happy(v,w,r,s,t);
     o=315;
     p=270;
    z= getpixel(e+10,f+10);
    tune3();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }
      if(((e==208)&&(f==175))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=12;
     happy(v,w,r,s,t);
     o=45;
     p=360;
    z= getpixel(e+10,f+10);
    tune3();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }

      if(((e==523)&&(f==130))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     sad(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=12;
     happy(v,w,r,s,t);
     o=450;
     p=405;
    z= getpixel(e+10,f+10);
    tune3();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }
      if(((e==253)&&(f==400))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=0;
     sad(v,w,r,s,t);
     o=315;
     p=0;
    z= getpixel(e+10,f+10);
    tune2();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }
      if(((e==253)&&(f==310))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=0;
     sad(v,w,r,s,t);
     o=450;
     p=45;
    z= getpixel(e+10,f+10);
    tune2();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }
      if(((e==388)&&(f==220))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=0;
     sad(v,w,r,s,t);
     o=315;
     p=135;
    z= getpixel(e+10,f+10);
    tune2();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }
      if(((e==388)&&(f==85))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=0;
     sad(v,w,r,s,t);
     o=180;
     p=90;
    z= getpixel(e+10,f+10);
    tune2();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }
      if(((e==163)&&(f==40))&&(u==n))
     {
      v=590,w=240,r=0,s=0,t=0;
      smile(v,w,r,s,t);
     happy(v,w,r,s,t);
     delay(100);
     v=590,w=240,r=15,s=2,t=0;
     sad(v,w,r,s,t);
     o=135;
     p=315;
    z= getpixel(e+10,f+10);
    tune2();
     clear2(z,e,f);
     e=(95+o)-22;
     f=(465-p)-20;
     delay(300);
     draw2(e,f);
     }
     delay(200);
     }
     }
     if(ch==27)
     {
     exit(0);
     }
     }
     }
     }
     }
     void angdev()
     {
     int g,h,k,l,m,i,j,n,o;
     for (j=0;j<=405;j=j+45)
     {
     for(i=45;i<=450;i=i+45)
     {
     g=(95+i)-22;
     h=(465-j)-20;
     if((g==478)&&(h==445))
     {
     k=11;
     l=14;
     m=0;
     angle1(g,h,k,l,m);
     }
     if((g==433)&&(h==355))
     {
     k=11;
     l=14;
     m=0;
     angle1(g,h,k,l,m);
     angle2(g,h,k,l,m);
     }
     if((g==118)&&(h==265))
     {
     k=15;
     l=14;
     m=0;
     angle1(g,h,k,l,m);
     angle2(g,h,k,l,m);
     }
     if((g==208)&&(h==175))
     {
     k=11;
     l=14;
     m=0;
     angle1(g,h,k,l,m);
     }
     if((g==523)&&(h==130))
     {
     k=11;
     l=14;
     m=0;
     angle1(g,h,k,l,m);
     }
     if((g==253)&&(h==400))
     {
     k=14;
     l=4;
     m=15,n=0,o=15;
     devil1(g,h,k,l,m,n,o);
     k=4,l=14,m=4,n=0,o=15;
     devil2(g,h,k,l,m,n,o);
     }
     if((g==253)&&(h==310))
     {
     k=4;l=14;m=4;n=0;o=15;
     devil1(g,h,k,l,m,n,o);
     k=14;l=4;m=14;n=0;o=15;
     devil2(g,h,k,l,m,n,o);
     }
     if((g==388)&&(h==220))
     {
     k=14;l=4;m=15;n=0;o=15;
     devil1(g,h,k,l,m,n,o);
     k=4;l=1;m=14;n=0;o=15;
     devil2(g,h,k,l,m,n,o);
     }
     if((g==388)&&(h==85))
     {
     k=4;l=1;m=14;n=0;o=15;
     devil1(g,h,k,l,m,n,o);
     k=4;l=14;m=4;n=0;o=4;
     devil2(g,h,k,l,m,n,o);
     }
     if((g==163)&&(h==40))
     {
     k=4;l=14;m=4;n=0;o=15;
     devil1(g,h,k,l,m,n,o);
     k=4;l=1;m=14;n=0;o=14;
     devil2(g,h,k,l,m,n,o);
     }
     if((g==523)&&(h==310))
     {
     k=11,l=6;
     destin1(g,h,k,l);
     }
     if((g==253)&&(h==85))
     {
     k=11,l=6;
     destin1(g,h,k,l);
     }
     if((g==388)&&(h==175))
     {
     k=11,l=6;
     destin1(g,h,k,l);
     }
     if((g==118)&&(h==85))
     {
     k=11,l=6;
     destin1(g,h,k,l);
     }
     if((g==523)&&(h==40))
     {
     k=11,l=6;
     destin1(g,h,k,l);
     }
     if((g==388)&&(h==445))
     {
     k=4,l=14;
     destin2(g,h,k,l);
     }
     if((g==523)&&(h==400))
     {
     k=14,l=4;
     destin2(g,h,k,l);
     }
     if((g==388)&&(h==310))
     {
     k=4,l=1;
     destin2(g,h,k,l);
     }
     if((g==253)&&(h==355))
     {
     k=1,l=14;
     destin2(g,h,k,l);
     }
     if((g==208)&&(h==130))
     {
     k=14,l=1;
     destin2(g,h,k,l);
     }
     }
     }
     }
     void destin1(int g,int h,int k,int l)
     {
      setcolor(k);
   setfillstyle(1,k);
   circle(g+13,h-12,8);
   floodfill(g+13,h-12,k);
   setcolor(l);
   line(g+13,h-18,g+13,h-6);
   line(g+12,h-18,g+12,h-6);
   line(g+14,h-18,g+14,h-6);
   line(g+9,h-15,g+17,h-15);
     }
     void destin2(int g,int h,int k,int l)
     {
       setcolor(k);
    setfillstyle(1,k);
    circle(g+13,h-12,8);
    floodfill(g+13,h-12,k);
    setcolor(l);
    line(g+13,h-14,g,h-14);
   line(g+13,h-11,g,h-11);
     }
      void angle1(int g,int h,int k,int l,int m)
      {
setcolor(k);
circle(g-15,h+10,7);
   setfillstyle(1,k);
   circle(g-15,h+10,6);
   floodfill(g-15,h+10,k);
   setcolor(l);
   ellipse(g-15,h-1,0,360,5,2);
   setcolor(m);
   arc(g-15,h+10,200,340,3);
   circle(g-17,h+8,1);
   circle(g-13,h+8,1);
      }
    void angle2(int g,int h,int k,int l,int m)
    {
setcolor(k);
circle(g+14,h-10,7);
   setfillstyle(1,k);
   circle(g+14,h-10,6);
   floodfill(g+14,h-10,k);
   setcolor(l);
   ellipse(g+14,h-21,0,360,5,2);
   setcolor(m);
   arc(g+14,h-10,200,340,3);
   circle(g+12,h-12,1);
   circle(g+16,h-12,1);
    }
   void devil1(int g,int h,int k,int l,int m,int n,int o)
    {
    setcolor(k);
   arc(g+13,h-17,125,215,6);
    arc(g+13,h-17,325,45,6);
    setcolor(l);
   circle(g+13,h-12,7);
    setfillstyle(1,l);
    circle(g+13,h-12,6);
    floodfill(g+13,h-12,l);
    setcolor(m);
    setfillstyle(10,m);
    pieslice(g+13,h-10,180,360,3);
    setcolor(n);
    setfillstyle(1,o);
    pieslice(g+10,h-13,125,0,2);
    pieslice(g+16,h-13,180,55,2);
    }
    void devil2(int g,int h,int k,int l,int m,int n,int o)
    {
      setcolor(k);
   arc(g-15,h+5,125,215,6);
    arc(g-15,h+5,325,45,6);
    setcolor(l);
   circle(g-15,h+10,7);
    setfillstyle(1,l);
    circle(g-15,h+10,6);
   floodfill(g-15,h+10,l);
    setcolor(m);
    setfillstyle(10,m);
    pieslice(g-15,h+12,180,360,3);
    setcolor(n);
    setfillstyle(1,o);
    pieslice(g-18,h+9,125,0,2);
    pieslice(g-12,h+9,180,55,2);
    }
     void main()
     {
     first();
     getch();
     closegraph();
     }

No comments:

Post a Comment