#include #include #include #include void title(void); void uz0(); void uzs(); void box(void); void name(void); void uzair(void); void help(void); void select(void); void board(void); void input(void); void xy(void); void check(void); void tu(void); void win(void); void answer(void); int i,j,x,y,turn=0,n=0,z=0,t,u,uturn=0,o=0,v=0,success=0; char key; int color[5],choice[5]; void main (void) { for(i=1;i<=14;i++){textcolor(i);cprintf("00 ");} char yn; clrscr(); title(); box(); name(); uzair(); do { if( yn=='Y' || yn=='y') { gotoxy(32,20); textcolor(9); cprintf("Welcome Again"); sound(1700); delay(100); nosound(); sound(2000); delay(100); nosound(); sound(2300); delay(100); nosound(); delay(1000); } help(); select(); board(); input(); clrscr(); gotoxy(22,12); textcolor(11); cprintf("If You Want To Play Again Press 'Y'"); gotoxy(22,14); textcolor(11); cprintf(" Otherwise GOODBYE ! "); for(i=1500;i<=2000;i+=100) { sound(i); delay(80); nosound(); } yn=getch(); i=0; j=0; x=0; y=0; turn=0; n=0; z=0; t=0; u=0; uturn=0; o=0; v=0; success=0; } while(yn=='Y' || yn=='y'); gotoxy(30,20); textcolor(9); cprintf("Thanks For Playing."); sound(2500); delay(150); nosound(); sound(1500); delay(150); nosound(); delay(1000); textcolor(15); clrscr(); } void title(void) { uz0(); delay(200); gotoxy(28,23); textcolor(5); cprintf("Proudly"); sound(500); delay(40); nosound(); delay(300); gotoxy(37,23); textcolor(5); cprintf("Presents"); sound(1000); delay(40); nosound(); delay(500); uzs(); delay(600); clrscr(); } void uz0(void) { _setcursortype(_NOCURSOR); textcolor(11); //A for(i=15;i>=12;i--) { gotoxy(35,i); cprintf("0 0"); delay(50); } gotoxy(35,11); cprintf(" 0 0 "); delay(50); gotoxy(35,10); cprintf(" 0 0"); delay(50); gotoxy(35,9); cprintf(" 00"); delay(50); for(i=37;i<=40;i++) { gotoxy(i,13); cprintf("0"); delay(50); } sound(2500); delay(80); nosound(); //Z j=30; for(i=25;i<=31;i++) { gotoxy(i,9); cprintf("0"); delay(50); } for(i=10;i<=14;i++) { gotoxy(j,i); cprintf("0"); delay(50); j--; } for(i=25;i<=31;i++) { gotoxy(i,15); cprintf("0"); delay(50); } sound(2500); delay(80); nosound(); //I for(i=46;i<=48;i++) { gotoxy(i,9); cprintf("0"); delay(50); } for(i=10;i<=15;i++) { gotoxy(47,i); cprintf("0"); delay(50); } for(i=46;i<=48;i++) { gotoxy(i,15); cprintf("0"); delay(50); } sound(2500); delay(80); nosound(); //U for(i=15;i>=9;i--) { gotoxy(14,i); cprintf("0 0"); delay(50); } for(i=15;i<=21;i++) { gotoxy(i,15); cprintf("0"); delay(50); } sound(2500); delay(80); nosound(); //R j=55; for(i=9;i<=15;i++) { gotoxy(52,i); cprintf("0"); delay(50); } for(i=53;i<=56;i++) { gotoxy(i,9); cprintf("0"); delay(50); } for(i=10;i<=11;i++) { gotoxy(57,i); cprintf("0"); delay(50); } for(i=53;i<=56;i++) { gotoxy(i,12); cprintf("0"); delay(50); } for(i=13;i<=15;i++) { gotoxy(j,i); cprintf("0"); delay(50); j++; } sound(2500); delay(80); nosound(); } void uzs(void) { textcolor(9); _setcursortype(_NOCURSOR); //U for(i=15;i>=9;i--) { gotoxy(14,i); cprintf("* *"); delay(40); } for(i=15;i<=21;i++) { gotoxy(i,15); cprintf("*"); delay(40); } sound(2000); delay(80); nosound(); //Z j=30; for(i=25;i<=31;i++) { gotoxy(i,9); cprintf("*"); delay(40); } for(i=10;i<=14;i++) { gotoxy(j,i); cprintf("*"); delay(40); j--; } for(i=25;i<=31;i++) { gotoxy(i,15); cprintf("*"); delay(40); } sound(2000); delay(80); nosound(); //A for(i=15;i>=12;i--) { gotoxy(35,i); cprintf("* *"); delay(40); } gotoxy(35,11); cprintf(" * * "); delay(40); gotoxy(35,10); cprintf(" * *"); delay(40); gotoxy(35,9); cprintf(" **"); delay(40); for(i=37;i<=40;i++) { gotoxy(i,13); cprintf("*"); delay(40); } sound(2000); delay(80); nosound(); //I for(i=46;i<=48;i++) { gotoxy(i,9); cprintf("*"); delay(40); } for(i=10;i<=15;i++) { gotoxy(47,i); cprintf("*"); delay(40); } for(i=46;i<=48;i++) { gotoxy(i,15); cprintf("*"); delay(40); } sound(2000); delay(80); nosound(); //R j=55; for(i=9;i<=15;i++) { gotoxy(52,i); cprintf("*"); delay(40); } for(i=53;i<=56;i++) { gotoxy(i,9); cprintf("*"); delay(40); } for(i=10;i<=11;i++) { gotoxy(57,i); cprintf("*"); delay(40); } for(i=53;i<=56;i++) { gotoxy(i,12); cprintf("*"); delay(40); } for(i=13;i<=15;i++) { gotoxy(j,i); cprintf("*"); delay(40); j++; } sound(2000); delay(80); nosound(); } void box(void) { _setcursortype(_NOCURSOR); j=0; for(i=1;i<=79;i++) { delay(10); textcolor(11); cprintf("0"); sound(2600); delay(5); nosound(); } j=1; for(i=1;i<=25;i++) { delay(10); textcolor(11); cprintf("0"); gotoxy(80,j); j++; sound(2300); delay(5); nosound(); } j=80; for(i=1;i<=80;i++) { delay(10); gotoxy(j,24); textcolor(11); cprintf("0"); j--; sound(2000); delay(5); nosound(); } j=24; for(i=1;i<=21;i++) { delay(10); textcolor(11); cprintf("0"); gotoxy(1,j); j--; sound(1700); delay(5); nosound(); } for(i=1;i<=73;i++) { delay(10); textcolor(11); cprintf("0"); sound(1400); delay(5); nosound(); } j=4; for(i=1;i<=19;i++) { delay(10); textcolor(11); cprintf("0"); gotoxy(74,j); j++; sound(1100); delay(5); nosound(); } j=74; for(i=1;i<=68;i++) { delay(10); gotoxy(j,21); textcolor(11); cprintf("0"); j--; sound(800); delay(5); nosound(); } j=21; for(i=1;i<=16;i++) { delay(10); textcolor(11); cprintf("0"); gotoxy(6,j); j--; sound(500); delay(5); nosound(); } textcolor(15); } void name(void) { _setcursortype(_NOCURSOR); gotoxy(26,10); textcolor(9); cprintf("Welcome To The Game Of"); gotoxy(31,15); textcolor(5); sound(300); delay(62); cprintf("M"); nosound(); sound(500); delay(62); cprintf("A"); nosound(); sound(700); delay(62); cprintf("S"); nosound(); sound(900); delay(62); cprintf("T"); nosound(); sound(1100); delay(62); cprintf("E"); nosound(); sound(1300); delay(62); cprintf("R"); nosound(); sound(1500); delay(62); cprintf(" "); nosound(); sound(1700); delay(62); cprintf("M"); nosound(); sound(1900); delay(62); cprintf("I"); nosound(); sound(2100); delay(62); cprintf("N"); nosound(); sound(2300); delay(62); cprintf("D"); nosound(); delay(1500); } void uzair(void) { _setcursortype(_NOCURSOR); gotoxy(18,10); textcolor(9); cprintf("Programmed By "); gotoxy(30,15); textcolor(5); sound(2600); delay(62); cprintf(" "); nosound(); sound(2400); delay(62); cprintf("U"); nosound(); sound(2200); delay(62); cprintf("Z"); nosound(); sound(2000); delay(62); cprintf("A"); nosound(); sound(1800); delay(62); cprintf("I"); nosound(); sound(1600); delay(62); cprintf("R"); nosound(); sound(1400); delay(62); cprintf(" "); nosound(); sound(1200); delay(62); cprintf("A"); nosound(); sound(1000); delay(62); cprintf("H"); nosound(); sound(800); delay(62); cprintf("M"); nosound(); sound(600); delay(62); cprintf("A"); nosound(); sound(400); delay(62); cprintf("D"); nosound(); delay(2000); clrscr(); } void help(void) { _setcursortype(_NOCURSOR); clrscr(); gotoxy(35,4); textcolor(7); cprintf("HELP"); gotoxy(15,8); textcolor(9); cprintf("Master Mind is a game of guessing colors and thier right position."); textcolor(9); cprintf("In this game computer selects a setting of colors and you have to guess it in 6 "); textcolor(9); cprintf("chances.If your choice is correct '*' will be displayed,if your color is correct"); textcolor(9); cprintf("but position is wrong '!' will be displayed and if your choice is wrong '?' will"); textcolor(9); cprintf("be displayed.You can enter your choice by pressing the capital letter reserved "); textcolor(9); cprintf("for that color.You can quit the game by just pressing cpital 'E'.Their is a bug "); textcolor(9); cprintf("in this game.If you encounter more than 5 displays from the computer please quit"); textcolor(9); cprintf("the game and start it again...Thanks for playing my game............Uzair Ahmad."); gotoxy(35,21); textcolor(13); cprintf("ENJOY !"); sound(3000); delay(100); nosound(); getch(); } void select(void) { _setcursortype(_NOCURSOR); randomize(); for(i=0;i<5;i++) { color[i]=random(8)+1; } clrscr(); textcolor(3); gotoxy(17,11); cprintf("Computer has selected a setting of colors."); gotoxy(23,12); cprintf("Now its your time to guess it."); gotoxy(33,17); textcolor(5); cprintf("GOODLUCK !"); sound(3700); delay(30); nosound(); delay(1350); clrscr(); } void board(void) { _setcursortype(_NOCURSOR); int k=1; i=0,j=0; gotoxy(54,1); textcolor(10); cprintf("\"MASTER MIND.\""); gotoxy(1,2); textcolor(11); cprintf("You can choose from 8 colors given below:"); gotoxy(5,4); sound(2700);delay(50); textcolor(9);cprintf("Blue "); nosound(); sound(2800);delay(50); textcolor(4);cprintf("Red "); nosound(); sound(2900);delay(50); textcolor(2);cprintf("Green "); nosound(); sound(3000);delay(50); textcolor(14);cprintf("Yellow "); nosound(); sound(3100);delay(50); textcolor(3);cprintf("Cyan "); nosound(); sound(3200);delay(50); textcolor(6);cprintf("brOwn "); nosound(); sound(3300);delay(50); textcolor(15);cprintf("White "); nosound(); sound(3400);delay(50); textcolor(5);cprintf("Pink"); nosound(); textcolor(7); for(i=6;i<22;i+=3) { gotoxy(1,i); cprintf("%d.",k); for(j=3;j<24;j+=5) { sound(1000); delay(50); gotoxy(j,i); cprintf(" #"); nosound(); } k++; } gotoxy(73,25);textcolor(6);cprintf("'E'xit."); sound(3800);delay(60);nosound(); gotoxy(30,25);textcolor(8);cprintf("Press A Key."); sound(3400);delay(60);nosound(); getch(); } void input(void) { _setcursortype(_NOCURSOR); i=0; j=0; while( ( (key=getch()) != 'E') && (turn<30) ) { switch(key) { case'B': case'b': turn++; xy(); gotoxy(x,y); sound(1700); delay(50); nosound(); textcolor(9); cprintf("B"); choice[i]=1; i++; break; case'R': case'r': turn++; xy(); gotoxy(x,y); sound(1700); delay(50); nosound(); textcolor(4); cprintf("R"); choice[i]=2; i++; break; case'G': case'g': turn++; xy(); gotoxy(x,y); sound(1700); delay(50); nosound(); textcolor(2); cprintf("G"); choice[i]=3; i++; break; case'Y': case'y': turn++; xy(); gotoxy(x,y); sound(1700); delay(50); nosound(); textcolor(14); cprintf("Y"); choice[i]=4; i++; break; case'C': case'c': turn++; xy(); gotoxy(x,y); sound(1700); delay(50); nosound(); textcolor(3); cprintf("C"); choice[i]=5; i++; break; case'O': case'o': turn++; xy(); gotoxy(x,y); sound(1700); delay(50); nosound(); textcolor(6); cprintf("O"); choice[i]=6; i++; break; case'W': case'w': turn++; xy(); gotoxy(x,y); sound(1700); delay(50); nosound(); textcolor(15); cprintf("W"); choice[i]=7; i++; break; case'P': case'p': turn++; xy(); gotoxy(x,y); sound(1700); delay(50); nosound(); textcolor(5); cprintf("P"); choice[i]=8; i++; break; default: break; } if(i>4) { i=0; check(); if(success==5) { win(); turn=30; } else { success=0; } } } if(turn==30 && success!=5) { answer(); } getch(); } void xy(void) { int row,col; col=turn%5; if(col==0) { col=5; } x=(col+5)+n; n+=4; y=6+z; if(n==20) { n=0; z+=3; } } void check(void) { int h,flag=1,d; h=0 ; j=0; for(h=0,d=5;h<5,d>=1;h++,d--) { if(choice[h]==color[h]) { tu(); gotoxy(t,u); sound(1500); delay(60); nosound(); textcolor(11); cprintf("*"); success++; flag=0; } if(flag!=0) { for(j=0;j