/************************************************************************/ /* Designed & developed by J.V.RAVICHANDRAN. */ /* Started on 02/10/1997. */ /* Author's name -- J.V.RAVICHANDRAN */ /* Company's name -- Semantix Computers. */ /* Company's address -- B-10, Triveni Apartments, */ /* Vikas puri, New Delhi - 110018. */ /* Completed on -- 10th October, 1997. */ /* Name of software -- GREYcells Tic-tac-toe */ /* Nature of software -- Game */ /************************************************************************/ #include <\tc\library\graphics.h> #include <\tc\library\process.h> #include <\tc\library\io.h> #include <\tc\library\dos.h> #include <\tc\library\conio.h> #include <\tc\library\string.h> #include <\tc\library\stdlib.h> #include <\tc\library\stdio.h> #include <\tc\library\alloc.h> #include <\tc\library\fcntl.h> #include <\tc\library\stat.h> #define ALT 1 #define ASCII 1 int gdriver = VGA, gmode=VGAHI, err_code,time_spent=0,boardvisible=0,counter=0; int nkey,ikey,key,ik=1,boxrr=150,boxcc=175,boxr=125,boxc=150,ctr=0,cx=125,rx=25,start=0; int player=0,color=15,ir,once=0,entered=1,rctr,menuflag; int playertype1=0, playertype2=0,checkxflag=0,checkoflag=0,length,handle,handl; int checkxflag,checkoflag,checkx1flag,checko1flag,menuitem=0,firsttime=0; char str,firstletter,secondletter; int playerno1=0, playerno2=0, err_flag=0,gameover=0,checkflag=0,once; int menucol,menurow,menucoll,menuroww,item,player1lastcounter=10,player2lastcounter=0; int messageboxc,messageboxr,messageboxcc,messageboxrr,rctr=0; void *sbox; int sctr=0,bctr=0,count,counter,lastcount,lastcounter; int menuon=0,lastrctr,menuerror=0,sharecounter=0; unsigned size; int oxx1,oxx2,oxx3,oxx4,oxx5,oxx6,oxx7,oxx8,oxx9; int letter3=0,letter4=1,winflag=0; char *box[9],*playername[20]; int letter1, letter2,letter; char score1,score2; int soundon=1,incolor=12,soundctr,lettercolor=15,ct,midx,mee=0; char terminator,leng,newstr; main(){
initgraph(&gdriver, &gmode, ""); err_code = graphresult();
if (err_code !=grOk) { printf("Graphic initialization error...\n"); time_spent=0; while (time_spent<50 0l="" _fmode="O_BINARY;" _write="" counter="" ct="=-1){" d="" delay="" delaytic.="" exit="" fa_hidden="" handle="" if="" lseek="" pre="" seek_set="" sprintf="" terminator="" time_spent="">ct=access("termtic.$$$",0); if (ct==-1){ setfillstyle(SOLID_FILL,15); bar(100,100,400,200); setfillstyle(SOLID_FILL,0); bar(101,101,399,120); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(15); outtextxy(220,111,"GREYcells"); setcolor(0); outtextxy(110,135,"Intruder alert ! Please contact"); outtextxy(110,150,"the developer immediately."); sound(100); delay(75); nosound(); getch(); cleardevice(); closegraph(); _close(handle); exit(0); ik=1;}if (ct==0){ handle=open("termtic.$$$", O_RDONLY | O_BINARY); lseek(handle, 0L, SEEK_SET); counter=0; leng=filelength(handle); sscanf(&terminator,"%d",&leng); while (!eof(handle)){ read(handle,&terminator,4);} } chmod("termtic.$$$",S_IWRITE); unlink("termtic.$$$");_fmode=O_BINARY; handle=_creat("termtic.$$$", FA_HIDDEN); lseek(handle, 0L, SEEK_SET);sscanf(&terminator,"%d",&counter); counter++; sprintf(&terminator,"%d",counter); _write(handle,&terminator,4); if (counter<28 counter="" if="" ik="0;}">28){ sound(100); delay(25); sound(150); delay(25); sound(125); delay(25); nosound(); alertformoney(); getch(); cleardevice(); chmod("termtic.$$$",S_IREAD); _close(handle); ik=0; sharecounter=1;} if (ik<1 32:="" case="" color="15;}" cx="400;" delay="" firstscreen="" if="" ik="" item="=1){" key="" menu="" menuon="=2" nosound="" rx="250;" setcolor="" settextjustify="" settextstyle="" sound="" soundon="" switch="" while="">1){ soundon=0;} if (soundon==1){ setcolor(7); outtextxy(menucol+75,menurow+13,"Sound ( OFF )"); setcolor(15); outtextxy(menucol+75,menurow+13,"Sound ( ON )");} if (soundon==0){ setcolor(7); outtextxy(menucol+75,menurow+13,"Sound ( ON )"); setcolor(15); outtextxy(menucol+75,menurow+13,"Sound ( OFF )");} } break; case ALT==1: case 129: if (menuon==0){ menucol=15; menurow=14; menucoll=164; menuroww=57; messageboxc=menucol; messageboxr=menurow; messageboxcc=menucoll; messageboxrr=menuroww; savebox(); dropdownmenu(); 1>28>setcolor(12); settextstyle(DEFAULT_FONT,VERT_DIR,1); settextjustify(0,1); outtextxy(20,11,"0");settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setcolor(8); if (soundon==1){ outtextxy(menucol+75,menurow+13,"Sound ( ON )");} if (soundon==0){ outtextxy(menucol+75,menurow+13,"Sound ( OFF )");} outtextxy(menucol+75,menurow+33,"Levels (1-3)"); item=0; menuon=2;} break; case 35: if (menuon==0){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); cx=120; setcolor(12); outtextxy(cx,43,"H"); setcolor(15); cx+=textwidth("H"); cx=cx+1; outtextxy(cx,43,"elp"); menuitem=2; menuflag=0; menuon=1;} break; case 34: if (menuon==0){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); cx=20; setcolor(12); outtextxy(cx,43,"G"); cx+=textwidth("G"); cx=cx+1; setcolor(15); outtextxy(cx,43,"ame"); menuitem=1; menuflag=0; menuon=1;} break; case 27: if (menuon==2){ restorebox(); setcolor(7); settextstyle(DEFAULT_FONT,VERT_DIR,1); settextjustify(0,1); outtextxy(20,11,"0"); menuon=0;} if (menuon==0){ sound(50); delay(50); nosound();} if (menuon==1 && menuflag==1 && menuitem==1){ restorebox(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); cx=20; setcolor(15); outtextxy(cx,43,"G"); cx+=textwidth("G"); cx=cx+1; setcolor(7); outtextxy(cx,43,"ame"); menuon=0; menuflag=0; item=0; menuitem=1; } if (menuon==1 && menuflag==1 && menuitem==2){ restorebox(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); cx=120; setcolor(15); outtextxy(cx,43,"H"); setcolor(7); cx+=textwidth("H"); cx=cx+1; outtextxy(cx,43,"elp"); menuon=0; menuflag=0; menuitem=1; item=0; } break; case 75: if (start==4 && menuon==0){ /* left arrow */ boxoff(); if (boxc>150){ boxc=boxc-100; boxcc=boxcc-100;} if (boxc<150 77:="" arrow="" boxc="210;" boxcc="" boxoff="" boxon="" break="" case="" ctr="" if="" menuon="=0){" right="" start="=4">0){ boxc=boxc+100; boxcc=boxcc+100;} boxon(); } ctr++; break; case 80: if (menuon==2){ if (item==0){ threed_menu();150>settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1);if (soundon==1){ setcolor(7); outtextxy(menucol+75,menurow+13,"Sound ( OFF )"); setcolor(15); outtextxy(menucol+75,menurow+13,"Sound ( ON )");} if (soundon==0){ setcolor(7); outtextxy(menucol+75,menurow+13,"Sound ( ON )"); setcolor(15); outtextxy(menucol+75,menurow+13,"Sound ( OFF )");} } if (item==1){ twod_menu();settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setcolor(8); if (soundon==1){ outtextxy(menucol+75,menurow+13,"Sound ( ON )");} if (soundon==0){ outtextxy(menucol+75,menurow+13,"Sound ( OFF )");} setlinestyle(SOLID_LINE,1,1); threed_menuitem2(); setcolor(15); outtextxy(menucol+75,menurow+33,"Levels (1-3)");} if (item==2){ twod_menuitem2(); setcolor(8); outtextxy(menucol+75,menurow+33,"Levels (1-3)");}sound(20); delay(75); nosound(); item++; if (item==3){ item=0;} } if (menuon==1 && menuflag==1 && menuitem==1){ if (item==0){ threed_menu();settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setcolor(15); outtextxy(menucol+50,menurow+13,"Start");} if (item==1){ twod_menu();settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setcolor(8); outtextxy(menucol+50,menurow+13,"Start"); setlinestyle(SOLID_LINE,1,1); threed_menuitem2(); setcolor(15); outtextxy(menucol+50,menurow+33,"Quit");} if (item==2){ twod_menuitem2(); setcolor(8); outtextxy(menucol+50,menurow+33,"Quit");}sound(20); delay(75); nosound(); item++; if (item==3){ item=0;} } if (menuon==1 && menuflag==1 && menuitem==2){ if (item==0){ threed_menu();settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setcolor(15); outtextxy(menucol+75,menurow+13,"How to use...");} if (item==1){ twod_menu();settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setcolor(8); outtextxy(menucol+75,menurow+13,"How to use..."); setlinestyle(SOLID_LINE,1,1); threed_menuitem2(); setcolor(15); outtextxy(menucol+70,menurow+33,"About");} if (item==2){ twod_menuitem2(); setcolor(8); outtextxy(menucol+70,menurow+33,"About");} sound(20); delay(75); nosound(); item++; if (item==3){ item=0;} } if (menuon==1 && menuitem==1 && menuflag==0){ menucol=20; menurow=48; menucoll=120; menuroww=91; messageboxc=menucol; messageboxr=menurow; messageboxcc=menucoll; messageboxrr=menuroww; savebox(); dropdownmenu(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setcolor(8); outtextxy(menucol+50,menurow+13,"Start"); outtextxy(menucol+50,menurow+33,"Quit"); item=0; menuflag=1;} if (menuon==1 && menuitem==2 && menuflag==0){ menucol=120; menurow=48; menucoll=259; menuroww=91; messageboxc=menucol; messageboxr=menurow; messageboxcc=menucoll; messageboxrr=menuroww; savebox(); dropdownmenu(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setcolor(8); outtextxy(menucol+75,menurow+13,"How to use..."); outtextxy(menucol+70,menurow+33,"About"); item=0; menuflag=1;} if (start==4 && menuon==0){ if (boxc>150){ boxoff(); if (boxrr<320 72:="" boxoff="" boxon="" boxr="" boxrr="boxrr+85;}" break="" case="" if="" menuon="=0){" start="=4">150){ boxr=boxr-85; boxrr=boxrr-85; } boxon();} break; case 88: /* caps x */ if (start==4 && checkxflag==0 && menuon==0){ checkflag=1; boxoff(); mee=2; error(); if (gameover==-1){gameover=0;checkxflag=0;} checkflag=0;} if (start==4 && checkxflag==1 && menuon==0){ boxoff(); if (playertype1==1 || playertype2==1){ if (winflag==0){ scanboxes(); setstatus(); boxrr=150; boxcc=175; boxr=125; boxc=150; boxon();}} if (winflag==0 && err_flag==0){ setplayer();} if (winflag==1 && err_flag==0){ start=5;} } if (playertype2==2 && winflag==0 && err_flag==0){ once=0; computer_o(); writectext(); if (once==2){display_win();} boxrr=150; boxcc=175; boxr=125; boxc=150; boxon(); if (winflag==0 && err_flag==0){ setplayer();} if (winflag==1 && err_flag==0){ start=5;}} if (entered>=9 && winflag==0 && gameover==0){ gameover=1; error(); start=5;} break; case 79: /* caps O*/ if (start==4 && checkoflag==0 && menuon==0){ checkflag=1; boxoff(); mee=2; error(); checkflag=0;} if (start==4 && checkoflag==1 && menuon==0){ boxoff(); if (playertype1==1 || playertype2==1){ if (winflag==0){ scanboxes(); setstatus(); boxrr=150; boxcc=175; boxr=125; boxc=150; boxon();}} if (winflag==0 && err_flag==0){ setplayer();} if (winflag==1 && err_flag==0){ start=5;} } if (playertype2==2 && winflag==0){ once=0; computer_o(); writeotext(); if (once==2){display_win();} boxrr=150; boxcc=175; boxr=125; boxc=150; boxon(); if (winflag==0 && err_flag==0){ setplayer();} if (winflag==1 && err_flag==0){ start=5;}} if (entered>=9 && winflag==0 && gameover==0){ gameover=1; error(); start=5;} break; case 13: if (menuon==1 && menuitem==1){ restorebox(); if (item==0){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); cx=20; setcolor(15); outtextxy(cx,43,"G"); cx+=textwidth("G"); cx=cx+1; setcolor(7); outtextxy(cx,43,"ame");} if (item==1){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); cx=20; setcolor(15); outtextxy(cx,43,"G"); cx+=textwidth("G"); cx=cx+1; setcolor(7); outtextxy(cx,43,"ame"); gameover=0; clearboard(); boxrr=150; boxcc=175; boxr=125; boxc=150; ctr=1; while (ctr<10 about="" ame="" box="" checkoflag="1;}" checkxflag="0;" ctr="1;" cx="" delay="" elp="" entered="1;" howtouse="" if="" ik="1;" item="=2){" letter1="=2){" lettercolor="12;" menuflag="0;" menuitem="=2){" menuon="0;}</pre" nosound="" outtextxy="" player="1;" quit="" restorebox="" setcolor="" setplayer="" settextjustify="" settextstyle="" sound="" start="4;" strcpy="" textwidth="" winflag="0;}">50>if (menuon==2){ restorebox(); setcolor(7); settextstyle(DEFAULT_FONT,VERT_DIR,1); settextjustify(0,1); outtextxy(20,11,"0"); if (item==2){ shareware();} menuon=0;}break; } } cleardevice(); closegraph(); return 0;} int scanboxes(){ sscanf(&box[1],"%d",&oxx1); sscanf(&box[2],"%d",&oxx2); sscanf(&box[3],"%d",&oxx3); sscanf(&box[4],"%d",&oxx4); sscanf(&box[7],"%d",&oxx7); sscanf(&box[5],"%d",&oxx5); sscanf(&box[6],"%d",&oxx6); sscanf(&box[8],"%d",&oxx8); sscanf(&box[9],"%d",&oxx9); return 1;} int computer_o(){ scanboxes(); if (entered==2){ if (oxx5==2 && once==0){ /* capture box5 */ boxfive(); once=1;} if (oxx5==0 && once==0){ if (oxx1==2){ /* capture box1 */ boxone();} once=1;} } if (entered==4 || entered==5){ defensivemoves(); if (once==0){ firstoffence();} } if (entered>5){ if (once==0){ offensivemoves();} if (once==0){ defensivemoves();} if (once==0){ firstoffence();} } if (once!=0){writeforcomputer();scanboxes();checkcomputerwin();} return (once);}int firstoffence(){ /* offensive moves for computer*/ if (oxx1==1 && oxx2==2 && once==0){ boxtwo();once=1;} if (oxx1==1 && oxx3==2 && once==0){ boxthree();once=1;} if (oxx5==1 && oxx2==2 && once==0){ boxtwo();once=1;} if (oxx5==1 && oxx3==2 && once==0){ boxthree();once=1;} if (oxx5==1 && oxx4==2 && once==0){ boxfour();once=1;} if (oxx5==1 && oxx6==2 && once==0){ boxsix();once=1;} if (oxx5==1 && oxx9==2 && once==0){ boxnine();once=1;} if (oxx5==1 && oxx7==2 && once==0){ boxseven();once=1;} if (oxx1==1 && oxx4==2 && once==0){ boxfour();once=1;} if (oxx1==1 && oxx7==2 && once==0){ boxseven();once=1;} if (oxx1==1 && oxx9==2 && once==0){ boxnine();once=1;} if (oxx1==1 && oxx5==2 && once==0){ boxfive();once=1;} return (once);} int offensivemoves(){ /* offensive moves for computer*/ if (oxx1==1 && oxx2==1 && oxx3==2 && once==0){ boxthree();once=2;} if (oxx1==1 && oxx4==1 && oxx7==2 && once==0){ boxseven();once=2;} if (oxx1==1 && oxx7==1 && oxx4==2 && once==0){ boxfour();once=2;} if (oxx1==1 && oxx9==1 && oxx5==2 && once==0){ boxfive();once=2;} if (oxx2==1 && oxx3==1 && oxx1==2 && once==0){ boxone();once=2;} if (oxx1==1 && oxx3==1 && oxx2==2 && once==0){ boxtwo();once=2;} if (oxx4==1 && oxx7==1 && oxx1==2 && once==0){ boxone();once=2;} if (oxx2==1 && oxx5==1 && oxx8==2 && once==0){ boxeight();once=2;} if (oxx2==1 && oxx8==1 && oxx5==2 && once==0){ boxfive();once=2;} if (oxx5==1 && oxx8==1 && oxx2==2 && once==0){ boxtwo();once=2;} if (oxx3==1 && oxx6==1 && oxx9==2 && once==0){ boxnine();once=2;} if (oxx6==1 && oxx9==1 && oxx3==2 && once==0){ boxthree();once=2;} if (oxx3==1 && oxx9==1 && oxx6==2 && once==0){ boxsix();once=2;} if (oxx4==1 && oxx5==1 && oxx6==2 && once==0){ boxsix();once=2;} if (oxx5==1 && oxx6==1 && oxx4==2 && once==0){ boxfour();once=2;} if (oxx4==1 && oxx6==1 && oxx5==2 && once==0){ boxfive();once=2;} if (oxx7==1 && oxx8==1 && oxx9==2 && once==0){ boxnine();once=2;} if (oxx7==1 && oxx9==1 && oxx8==2 && once==0){ boxeight();once=2;} if (oxx8==1 && oxx9==1 && oxx7==2 && once==0){ boxseven();once=2;} if (oxx1==1 && oxx5==1 && oxx9==2 && once==0){ boxnine();once=2;} if (oxx5==1 && oxx9==1 && oxx1==2 && once==0){ boxone();once=2;} if (oxx1==1 && oxx9==1 && oxx5==2 && once==0){ boxfive();once=2;} if (oxx3==1 && oxx5==1 && oxx7==2 && once==0){ boxseven();once=2;} if (oxx3==1 && oxx7==1 && oxx5==2 && once==0){ boxfive();once=2;} if (oxx7==1 && oxx5==1 && oxx3==2 && once==0){ boxthree();once=2;} return (once);} int defensivemoves(){ /* Defensive moves for computer*/ if (oxx7==0 && oxx4==0 && oxx1==2 && once==0){ boxone();once=1;} if (oxx1==0 && oxx2==0 && oxx3==2 && once==0){ boxthree();once=1;} if (oxx5==0 && oxx3==0 && oxx7==2 && once==0){ boxseven();once=1;} if (oxx5==0 && oxx7==0 && oxx3==2 && once==0){ boxthree();once=1;} if (oxx1==0 && oxx4==0 && oxx7==2 && once==0){ boxseven();once=1;} if (oxx1==0 && oxx7==0 && oxx4==2 && once==0){ boxfour();once=1;} if (oxx3==0 && oxx7==0 && oxx5==2 && once==0){ boxfive();once=1;} if (oxx2==0 && oxx5==0 && oxx8==2 && once==0){ boxeight();once=1;} if (oxx2==0 && oxx3==0 && oxx1==2 && once==0){ boxone();once=1;} if (oxx2==0 && oxx8==0 && oxx5==2 && once==0){ boxfive();once=1;} if (oxx5==0 && oxx8==0 && oxx2==2 && once==0){ boxtwo();once=1;} if (oxx3==0 && oxx6==0 && oxx9==2 && once==0){ boxnine();once=1;} if (oxx3==0 && oxx9==0 && oxx6==2 && once==0){ boxsix();once=1;} if (oxx6==0 && oxx9==0 && oxx3==2 && once==0){ boxthree();once=1;} if (oxx4==0 && oxx5==0 && oxx6==2 && once==0){ boxsix();once=1;} if (oxx4==0 && oxx6==0 && oxx5==2 && once==0){ boxfive();once=1;} if (oxx6==0 && oxx5==0 && oxx4==2 && once==0){ boxfour();once=1;} if (oxx7==0 && oxx8==0 && oxx9==2 && once==0){ boxnine();once=1;} if (oxx7==0 && oxx9==0 && oxx8==2 && once==0){ boxeight();once=1;} if (oxx9==0 && oxx8==0 && oxx7==2 && once==0){ boxseven();once=1;} return (once);} int drawboard(){ setfillstyle(SOLID_FILL,8); bar(0,0,640,480); setlinestyle(SOLID_LINE,1,1); setcolor(15); line(5,50,634,50); setcolor(0); line(4,21,4,480); line(0,475,640,475); line(636,21,636,480); setfillstyle(SOLID_FILL,0); bar(1,1,639,20); setcolor(15); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); outtextxy(290,12,"Tic-tac-toe"); setcolor(7); settextstyle(DEFAULT_FONT,VERT_DIR,1); settextjustify(0,1); outtextxy(20,11,"0");settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); cx=20; setcolor(15); outtextxy(cx,43,"G"); cx+=textwidth("G"); cx=cx+1; setcolor(7); outtextxy(cx,43,"ame"); cx=120; setcolor(15); outtextxy(cx,43,"H"); setcolor(7); cx+=textwidth("H"); cx=cx+1; outtextxy(cx,43,"elp"); outtextxy(420,27,"Player -"); outtextxy(420,43,"Score -"); outtextxy(45,450,"Player 1 -"); outtextxy(45,465,"Score -"); outtextxy(445,450,"Player 2 -"); outtextxy(445,465,"Score -"); setcolor(15);/* board */ setlinestyle(SOLID_LINE,1,3); setcolor(15); line(200,175,450,175); line(200,275,450,275); line(275,100,275,350); line(375,100,375,350);setfillstyle(SOLID_FILL,8); bar(520,23,625,47); setcolor(15); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); counter=0; cx=495; while (counter10>320> if (letter1==1){ lettercolor=15;} if (letter1==2){ lettercolor=12;} boardvisible=1; entered=1; player=1; if (letter1==1){ checkxflag=1; lettercolor=15; checkoflag=0;} if (letter1==2){ checkxflag=0; lettercolor=12; checkoflag=1;} gameover=0; checkflag=0; boxrr=150; boxcc=175; boxr=125; boxc=150; boxon(); setcolor(15); outtextxy(510,45,&score1); ctr=1; while (ctr<10 1="" bar="" box="" boxc="" boxcc="" boxoff="" boxr="" boxrr="" ctr="1;" if="" int="" return="" setfillstyle="" strcpy="">150){ setlinestyle(SOLID_LINE,1,1); setcolor(8); line(boxc,boxr,boxcc+5,boxr); line(boxc,boxr,boxc,boxrr); line(boxc,boxrr,boxcc+5,boxrr); line(boxcc+5,boxr,boxcc+5,boxrr);}10>return 1;} int boxon(){ if (boxc==150){ setfillstyle(SOLID_FILL,15); bar(boxc,boxr,boxcc,boxrr); setfillstyle(SOLID_FILL,0); bar(boxc+1,boxr+1,boxcc-1,boxrr-1);} if (boxc>150){ setlinestyle(SOLID_LINE,1,1); setcolor(15); line(boxc,boxr,boxcc+5,boxr); line(boxc,boxr,boxc,boxrr); line(boxc,boxrr,boxcc+5,boxrr); line(boxcc+5,boxr,boxcc+5,boxrr); } return 1;} int clearboard(){ setfillstyle(SOLID_FILL,8); bar(25,100,575,400); boardvisible=0; /* board */ setlinestyle(SOLID_LINE,1,3); setcolor(15); line(200,175,450,175); line(200,275,450,275); line(275,100,275,350); line(375,100,375,350); boardvisible=1; entered=1; player=1; gameover=0; checkflag=0; boxrr=150; boxcc=175; boxr=125; boxc=150; boxon(); setfillstyle(SOLID_FILL,8); bar(520,23,625,47); setcolor(15); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); counter=0; cx=525; while (counter0){ rctr--;} if (rctr==0){ rctr=0;}} if (rx==350){ if (rctr>player1lastcounter){ rctr--;}} curs_off(); cx-=textwidth(&nkey); setfillstyle(SOLID_FILL,8); bar(cx,rx-10,cx+10,rx+10); if (cx<=250){ cx=250;} curs_on(); break; case 13: if (playertype1==1 && playertype2==1 && rctr==0){ messageboxc=125; messageboxr=125; messageboxcc=450; messageboxrr=200; midx=265; sound(100); delay(75); nosound(); savebox(); errorscreen(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,messageboxr+5,"Error"); setcolor(0); outtextxy(messageboxc+5,messageboxr+35,"Mandatory to enter a name."); getch(); restorebox(); rctr=0; curs_off(); if (rx==325 || rx==322){ cx=250; rx=322; curs_on();} if (rx==350 || rx==346){ cx=250; rx=346; curs_on();} err_flag=1;} if (playertype1==2 && playertype2==1 && rctr>0){ curs_off(); rctr=0; cx=250; rx=350;} if (playertype1==1 && rctr>0 && entered==1 && err_flag==0){ if (rx==325 || rx==322){ curs_off(); player1lastcounter=rctr; if (playertype2==1){ cx=250; rx=350;} curs_on(); entered=0;}} if (playertype2==2 && err_flag==0){ curs_off(); entered=2;} if (playertype2==1 && err_flag==0 && rctr>0 && entered==1){ if (rx==346 || rx==350){ player2lastcounter=player1lastcounter+rctr; rctr=0; curs_off(); entered=2;}} err_flag=0; break; default: if (start==0){ if (rctr<10 if="" rctr="" rx="" writename="">=player1lastcounter && rctr<20 1="" break="" pre="" return="" rx="=350){" writename=""> int writename(){ entered=1; err_flag=0; curs_off(); setcolor(15); outtextxy(cx,rx,&nkey); cx+=textwidth(&nkey); curs_on(); strcpy(&playername[rctr],&nkey); rctr++; return (rctr);} int menu(){ drawmenuscreen(); while (once<4 if="" incolor="">15){ incolor=1;} setcolor(incolor); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); outtextxy(10,35,"Press20>10>for help"); outtextxy(300,13,"GREYcells"); ikey=getch(); switch(ikey){ case 59: if (rx==50 || rx==75){ messageboxc=125; messageboxr=125; messageboxcc=515; messageboxrr=250; midx=295; savebox(); errorscreen(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,messageboxr+5,"Help"); scrollplayerhelp(); getch(); restorebox(); } if (rx==250 || rx==275){ messageboxc=125; messageboxr=125; messageboxcc=475; messageboxrr=275; midx=275; savebox(); errorscreen(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,messageboxr+5,"Help"); playerletterhelp(); getch(); restorebox(); } break; case 80: if (sharecounter==1 && rx<250 bar="" ctr="" if="" outtextxy="" setcolor="" setfillstyle="" settextjustify="" settextstyle="" uman="">1){ alertformoney(); getch(); cleardevice(); drawmenuscreen(); ctr=0;} } if (once<2 bar="" ctr="" if="" omputer="" outtextxy="" setcolor="" setfillstyle="" settextjustify="" settextstyle="" sharecounter="=0){" uman="">2){ ctr=0;} } break; case 72: if (sharecounter==1 && rx<250 13:="" 79:="" 88:="" bar="" break="" caps="" case="" checkoflag="1;" checkxflag="0;" ctr--="" ctr="" curs_off="" cx="" firstletter="" if="" ikey="" letter1="2;" letter2="1;" o="" omputer="" once--="" once="=0" outtextxy="" playerno1="1;" playerno2="1;" rx="5;}" secondletter="" setcolor="" setfillstyle="" settextjustify="" settextstyle="" sharecounter="=0){" strcpy="" uman="" x="">0){ if (ctr==1){ settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(cx,rx,"Human"); setfillstyle(SOLID_FILL,8); bar(145,135,300,165); setcolor(15); outtextxy(150,150,"Human"); rx=rx+25; playertype1=1;} if (ctr==2){ settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(cx,rx,"Computer"); setfillstyle(SOLID_FILL,8); bar(145,185,300,215); setcolor(15); outtextxy(150,200,"Computer"); playertype1=2;} ctr=0; } if (once>0 && once<2 ctr="">0){ if (ctr==1){ settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(cx,rx,"Human"); playertype2=1; player=0;} if (ctr==2){ settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(cx,rx,"Computer"); playertype2=2; player=0;} } if (playertype1==2){ menuerror=2; gameover=2; checkflag=1; error(); ctr=0; once=-1; player=1; setfillstyle(SOLID_FILL,8); bar(10,25,600,125); setcolor(15); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(100,50,"Player 1:"); outtextxy(100,75,"Player 2:"); playertype1=0; playertype2=0; cx=225; rx=50;} if (playertype1==2 && playertype2==2){ menuerror=1; gameover=2; checkflag=1; error(); ctr=0; once=-1; player=1; setfillstyle(SOLID_FILL,0); bar(10,10,600,125); setcolor(15); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(100,50,"Player 1:"); outtextxy(100,75,"Player 2:"); playertype1=0; playertype2=0; cx=225; rx=50;} if (player==0){ cx=425; rx=250; curs_on(); player=1; once=3;} if (rx==5){ ctr=0; rctr=0; lastrctr=0; entered=1; if (playertype1==1){ cx=250; rx=325;} if (playertype1==2){ cx=250; rx=350;} curs_on(); start=0; name(); curs_off(); cleardevice(); drawboard(); boxrr=150; boxcc=175; boxr=125; boxc=150; boxon(); start=4; menuon=0; ik=0; rx=0; once=4; } if (once<2 1="" bar="" break="" curs_off="" curs_on="" cx="" int="" once="" pre="" return="" rx-5="" rx="" setfillstyle=""> 4>int dropdownmenu(){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setfillstyle(SOLID_FILL,15); bar(menucol,menurow+2,menucoll,menuroww); setfillstyle(SOLID_FILL,0); bar(menucol+1,menurow+3,menucoll-1,menuroww-1);setfillstyle(SOLID_FILL,7); bar(menucol+4,menurow+5,menucoll-3,menurow+20); bar(menucol+4,menurow+25,menucoll-3,menurow+41); #if 0 bar(menucol+4,menurow+37,menucoll-4,menurow+53); #endif setlinestyle(SOLID_LINE,1,2); setcolor(15); line(menucol+4,menurow+5,menucoll-3,menurow+5); line(menucol+4,menurow+5,menucol+4,menurow+20);line(menucol+4,menurow+25,menucoll-3,menurow+25); line(menucol+4,menurow+25,menucol+4,menurow+41);setcolor(0); line(menucol+4,menurow+20,menucoll-3,menurow+20); line(menucoll-3,menurow+5,menucoll-3,menurow+20);line(menucol+4,menurow+41,menucoll-3,menurow+41); line(menucoll-3,menurow+25,menucoll-3,menurow+41);/* line in between menu items */ setcolor(15); line(menucol,menurow+22,menucoll,menurow+22); return 1;} int setstatus(){ switch(boxr){ case 125: if (boxc==150){ mee=2; error();} if (boxc==210){ if (oxx1!=2){ mee=2; error();} if (oxx1==2){ writetext();}} if (boxc==310){ if (oxx4!=2){ mee=2; error();} if (oxx4==2){ writetext();} } if (boxc==410){ if (oxx7!=2){ mee=2; error();} if (oxx7==2){ writetext();} } break; case 210: if (boxc==150){ mee=2; error();} if (boxc==210){ if (oxx2!=2){ mee=2; error();} if (oxx2==2){ writetext();} } if (boxc==310){ if (oxx5!=2){ mee=2; error();} if (oxx5==2){ writetext();} } if (boxc==410){ if (oxx8!=2){ mee=2; error();} if (oxx8==2){ writetext();} } break; case 295: if (boxc==150){ mee=2; error();} if (boxc==210){ if (oxx3!=2){ mee=2; error();} if (oxx3==2){ writetext();} } if (boxc==310){ if (oxx6!=2){ mee=2; error();} if (oxx6==2){ writetext();} } if (boxc==410){ if (oxx9!=2){ mee=2; error();} if (oxx9==2){ writetext();} } break;} if (player==1 && playertype1==1 && winflag==0){ writeforcomputer();check_xwin();} if (player==2 && playertype2==1 && winflag==0){ writeforcomputer();check_owin();} return (winflag);}int check_xwin(){ scanboxes(); if (winflag==0){ if (oxx1==0 && oxx4==0 && oxx7==0){ display_win();} if (oxx1==0 && oxx2==0 && oxx3==0){ display_win();} if (oxx1==0 && oxx5==0 && oxx9==0){ display_win();} if (oxx4==0 && oxx5==0 && oxx6==0){ display_win();} if (oxx7==0 && oxx8==0 && oxx9==0){ display_win();} if (oxx3==0 && oxx5==0 && oxx7==0){ display_win();} if (oxx3==0 && oxx6==0 && oxx9==0){ display_win();} if (oxx2==0 && oxx5==0 && oxx8==0){ display_win();} } return (winflag);} int check_owin(){ scanboxes(); if (winflag==0){ if (oxx1==1 && oxx4==1 && oxx7==1){ display_win();} if (oxx1==1 && oxx2==1 && oxx3==1){ display_win();} if (oxx1==1 && oxx5==1 && oxx9==1){ display_win();} if (oxx4==1 && oxx5==1 && oxx6==1){ display_win();} if (oxx7==1 && oxx8==1 && oxx9==1){ display_win();} if (oxx3==1 && oxx5==1 && oxx7==1){ display_win();} if (oxx3==1 && oxx6==1 && oxx9==1){ display_win();} if (oxx2==1 && oxx5==1 && oxx8==1){ display_win();} } return (winflag);} int writetext(){ boxoff(); setcolor(lettercolor); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(boxcc-15,boxrr-15,&key); err_flag=0; return (err_flag);} int writectext(){ boxoff(); setcolor(lettercolor); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(boxcc-15,boxrr-15,"O"); err_flag=0; return (err_flag);} int writeotext(){ boxoff(); setcolor(lettercolor); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(boxcc-15,boxrr-15,"X"); err_flag=0; return (err_flag);} int error(){ messageboxc=150; messageboxr=173; messageboxcc=500; messageboxrr=300; savebox(); midx=295; errorscreen(); if (mee==1){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,1); settextjustify(0,1); setcolor(4); outtextxy(messageboxc+5,messageboxr+5,"Game");} if (mee==2){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,1); settextjustify(0,1); setcolor(4); outtextxy(messageboxc+5,messageboxr+5,"Error");} if (soundon==1){ sound(275); delay(150); sound(375); delay(250); nosound();} if (menuerror==1){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(1); outtextxy(messageboxc+15,messageboxr+40,"Computer cannot"); outtextxy(messageboxc+15,messageboxr+55,"play from both sides !"); gameover=3; menuerror=0;} if (menuerror==2){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(1); outtextxy(messageboxc+10,messageboxr+40,"Computer cannot play the first move in"); outtextxy(messageboxc+10,messageboxr+55,"this version. This feature will be"); outtextxy(messageboxc+10,messageboxr+70,"provided in the next version of the"); outtextxy(messageboxc+10,messageboxr+85,"software !"); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); gameover=3; menuerror=0;}if (gameover==0 && checkflag==1){ settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); if (player==1){ letter=letter1; counter=0; cx=messageboxc+15; while (counter2>2>250>2>250> if (playertype2==2){ outtextxy(cx,messageboxr+90,"COMPUTER"); cx=cx+135;} outtextxy(cx,messageboxr+90,"wins !"); setcolor(15); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); sprintf(&score2,"%d",bctr); setcolor(15); outtextxy(535,465,&score2); outtextxy(495,43,&score2);}if (entered<9 1="" bar="" bctr="" boxc="150;" boxcc="175;" boxon="" boxr="125;" boxrr="150;" checkoflag="1;}" checkxflag="0;" count="" cx="" d="" entered="=9){" getch="" if="" int="" letter2="=2){" lettercolor="12;" outtextxy="" player2lastcounter="" player="2;" playername="" playertype2="=2){" pre="" restorebox="" return="" score2="" setcolor="" setfillstyle="" setplayer="" settextjustify="" settextstyle="" sprintf="" textwidth="" while="" winflag="1;">if (entered==2 || entered==4 || entered==6 || entered==8 || entered==10){ setfillstyle(SOLID_FILL,8); bar(490,23,635,48); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); if (playertype1==1){ setcolor(15); counter=0; cx=495; while (counter9>
int threed_menu(){ setlinestyle(SOLID_LINE,1,1); setcolor(15); line(menucoll-6,menurow+8,menucoll-6,menurow+17); line(menucol+7,menurow+17,menucoll-6,menurow+17); setcolor(0); line(menucol+7,menurow+7,menucoll-7,menurow+7); line(menucol+7,menurow+7,menucol+7,menurow+17); return 1;} int twod_menu(){ setlinestyle(SOLID_LINE,1,1); setcolor(7); line(menucol+7,menurow+7,menucoll-7,menurow+7); line(menucol+7,menurow+7,menucol+7,menurow+17); setcolor(7); line(menucoll-6,menurow+8,menucoll-6,menurow+17); line(menucol+7,menurow+17,menucoll-6,menurow+17); return 1;} int threed_menuitem2(){ setlinestyle(SOLID_LINE,1,1); setcolor(15); line(menucol+7,menurow+27,menucoll-8,menurow+27); line(menucol+7,menurow+27,menucol+7,menurow+39); setlinestyle(SOLID_LINE,1,1); setcolor(0); line(menucoll-6,menurow+27,menucoll-6,menurow+39); line(menucol+7,menurow+39,menucoll-6,menurow+39); return 1;} int twod_menuitem2(){ setlinestyle(SOLID_LINE,1,1); setcolor(7); line(menucol+7,menurow+27,menucoll-8,menurow+27); line(menucol+7,menurow+27,menucol+7,menurow+39); setlinestyle(SOLID_LINE,1,1); setcolor(7); line(menucoll-6,menurow+27,menucoll-6,menurow+39); line(menucol+7,menurow+39,menucoll-6,menurow+39); return 1;} int howtouse(){ messageboxc=125; messageboxr=125; messageboxcc=515; messageboxrr=320; midx=300; savebox(); errorscreen(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,messageboxr+5,"Help"); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,160,"How to use GREYcells Tic-tac-toe"); setcolor(7); outtextxy(messageboxc+5,185,"Arrow keys to navigate between the menus and"); outtextxy(messageboxc+5,200,"the boxes."); outtextxy(messageboxc+5,225,"After a game is over, select START from the"); outtextxy(messageboxc+5,240,"menu to go to the next game."); outtextxy(messageboxc+5,260,"To select a menu, depress ALT + the colored"); outtextxy(messageboxc+5,275,"letter. To select the oval menu, depress"); outtextxy(messageboxc+5,290,"ALT + Zero."); getch(); restorebox(); return 1;} int about(){ messageboxc=125; messageboxr=125; messageboxcc=515; messageboxrr=300; midx=300; savebox(); errorscreen(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,messageboxr+5,"Help"); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(3,1,3,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,155,"About GREYcells Tic-tac-toe"); setcolor(7); outtextxy(messageboxc+5,185,"A game developed by J.V.Ravichandran, Software"); outtextxy(messageboxc+5,200,"architect/Software consultant/Proprietor."); outtextxy(messageboxc+5,230,"Semantix Computers, B-10, Triveni Apartments,"); outtextxy(messageboxc+5,245,"Near 'H' Block, Vikas puri, New Delhi-110 018."); getch(); restorebox(); return 1;} int shareware(){ messageboxc=125; messageboxr=125; messageboxcc=525; messageboxrr=325; savebox(); if (soundon==1){ sound(275); delay(150); sound(225); delay(250); sound(375); delay(250); nosound();} midx=300; errorscreen(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,messageboxr+5,"Alert"); setusercharsize(3,1,3,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,155,"GREYcells Tic-tac-toe"); setcolor(12); outtextxy(messageboxc+5,messageboxr+60,"A game developed by J.V.Ravichandran, Software"); outtextxy(messageboxc+5,messageboxr+75,"architect/Software consultant/Proprietor."); settextstyle(SMALL_FONT,HORIZ_DIR,3); settextjustify(0,1); setusercharsize(2,2,3,3); setcolor(0); outtextxy(messageboxc+5,messageboxr+95,"This is a shareware version. To increase the no. of levels in the"); outtextxy(messageboxc+5,messageboxr+110,"game, please send Rs.100.00 only or TEN dollars for more levels."); outtextxy(messageboxc+5,messageboxr+125,"Cheque to be drawn in favor of Semantix Computers, New Delhi,"); outtextxy(messageboxc+5,messageboxr+140,"and mail it to"); setcolor(10); outtextxy(messageboxc+5,messageboxr+155,"Mr. J.V.Ravichandran, Proprietor, Semantix Computers,"); outtextxy(messageboxc+5,messageboxr+170,"B-10, Triveni Apartments, Vikas puri, New Delhi-110 018."); outtextxy(messageboxc+5,messageboxr+185,""); getch(); restorebox(); return 1;} int scrollplayerhelp(){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(0); outtextxy(messageboxc+5,messageboxr+40,"Use the arrow keys to scroll through the menu"); outtextxy(messageboxc+5,messageboxr+60,"options. Press <Enter> on the highlighted"); outtextxy(messageboxc+5,messageboxr+80,"option to select."); return 1;} int playerletterhelp(){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(0); outtextxy(messageboxc+5,messageboxr+40,"Enter capital letters X or O for the first"); outtextxy(messageboxc+5,messageboxr+60,"player. The letter of the opponent will be"); outtextxy(messageboxc+5,messageboxr+80,"automatically entered. Press <Enter> after"); outtextxy(messageboxc+5,messageboxr+100,"the auto selection of the letter for the"); outtextxy(messageboxc+5,messageboxr+120,"second player is displayed.");
return 1;} int playernamehelp(){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(0); outtextxy(messageboxc+5,messageboxr+40,"A name can contain a maximum of 10 characters."); outtextxy(messageboxc+5,messageboxr+60,"Press <Enter> to register the input value."); return 1;} int firstscreen(){ setfillstyle(SOLID_FILL,12); bar(100,100,540,380);
setlinestyle(SOLID_LINE,1,1); setcolor(0); line(103,103,103,377); line(103,103,537,103); line(537,103,537,377); line(103,377,537,377);
setcolor(15); line(300,180,300,290); line(340,180,340,290); line(265,210,375,210); line(265,260,375,260); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); sound(25); delay(50); nosound(); setcolor(15); outtextxy(315,233,"X"); delay(500); sound(35); delay(50); nosound(); setcolor(0); outtextxy(275,190,"O"); delay(500); sound(25); delay(50); nosound(); setcolor(15); outtextxy(355,275,"X"); delay(500); sound(35); delay(50); nosound(); setcolor(0); outtextxy(275,233,"O"); delay(500); sound(25); delay(50); nosound(); setcolor(15); outtextxy(275,275,"X"); delay(500); sound(35); delay(50); nosound(); setcolor(0); outtextxy(315,190,"O"); delay(500); sound(25); delay(50); nosound(); setcolor(15); outtextxy(315,275,"X"); soundctr=0; while (soundctr<10){ sound(250); delay(50); nosound(); sound(350); delay(50); nosound(); soundctr++; }
settextstyle(DEFAULT_FONT,HORIZ_DIR,3); settextjustify(1,1); setcolor(15); outtextxy(325,135,"GREYcells"); setcolor(0); outtextxy(325,165,"Tic-tac-toe"); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(1,1); setcolor(9); outtextxy(325,190,"A game developed by J.V.Ravichandran"); setcolor(11); outtextxy(325,215,"(c) Semantix computers, New Delhi, 1997."); settextjustify(0,1); setcolor(0); outtextxy(110,230,"GREYcells Tic-tac-toe is a shareware software and"); outtextxy(110,245,"you are free to circulate it in your circle of"); outtextxy(110,260,"friends or colleagues. If the software is found"); outtextxy(110,275,"interesting, then register the software with the"); outtextxy(110,290,"developer which will enable you to access higher"); outtextxy(110,305,"levels of interaction between the human player and"); outtextxy(110,320,"the computer. A registration fee of Rs.100.00 only"); outtextxy(110,335,"or TEN dollars, by cheque drawn in favour of Semantix"); outtextxy(110,350,"Computers, New Delhi, will entitle you to access"); outtextxy(110,365,"these enhanced features."); getch(); cleardevice(); return 1;} int drawmenuscreen(){ cx=225; rx=50; ctr=0; setfillstyle(SOLID_FILL,8); bar(0,0,640,480); setfillstyle(SOLID_FILL,0); bar(1,1,639,21); setfillstyle(SOLID_FILL,8); bar(1,1,30,20); setlinestyle(SOLID_LINE,1,1); setcolor(0); line(4,21,4,480); line(636,21,636,480); line(0,475,640,475); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(15); outtextxy(300,13,"GREYcells"); setcolor(7); settextstyle(DEFAULT_FONT,VERT_DIR,1); outtextxy(20,10,"0");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(incolor); outtextxy(10,35,"Press <F1> for help"); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); setcolor(15); outtextxy(100,50,"Player 1:"); outtextxy(100,75,"Player 2:"); outtextxy(150,150,"Human"); outtextxy(150,200,"Computer"); outtextxy(100,250,"Select letter for player 1 -"); outtextxy(100,275,"Select letter for player 2 -"); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); outtextxy(100,325,"Name of player 1 -"); outtextxy(100,350,"Name of player 2 -"); setfillstyle(SOLID_FILL,15); bar(145,135,300,165); setcolor(0); settextstyle(TRIPLEX_FONT,HORIZ_DIR,3); settextjustify(0,1); outtextxy(150,150,"Human"); ctr=1; ir=0; player=1; once=0; return 1;} int alertformoney(){ messageboxc=25; messageboxr=100; messageboxcc=615; messageboxrr=216; midx=300; errorscreen(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,1); settextjustify(0,1); setcolor(12); outtextxy(messageboxc+5,messageboxr+5,"Alert"); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setusercharsize(1,3,1,3); setcolor(0); outtextxy(30,125,"This is a shareware software. To access all the features in the software,"); outtextxy(30,140,"please send a cheque of Rs.100.00 only or TEN dollars drawn in favor of"); outtextxy(30,155,"Semantix computers, New Delhi and address it to,"); setcolor(12); cx=30; outtextxy(cx,170,"J.V.Ravichandran,"); cx+=textwidth("J.V.Ravichandran,"); cx++; setcolor(14); outtextxy(cx,170,"Proprietor/Software Architect/Consultant."); setcolor(10); outtextxy(30,185,"B-10, Triveni Apartments, Vikas puri, New Delhi - 110 018."); return 1;}
int errorscreen(){ setfillstyle(SOLID_FILL,9); bar(messageboxc,messageboxr,messageboxcc,messageboxrr); setfillstyle(SOLID_FILL,7); bar(messageboxc+1,messageboxr+1,messageboxcc-1,messageboxr+16); setfillstyle(SOLID_FILL,0); bar(messageboxc+2,messageboxr+2,messageboxc+45,messageboxr+15); setlinestyle(SOLID_LINE,1,1); setcolor(15); line(messageboxc+45,messageboxr,messageboxcc,messageboxr); line(messageboxc+45,messageboxr,messageboxcc,messageboxr); setfillstyle(SOLID_FILL,7); bar(messageboxc+1,messageboxrr-16,messageboxcc-65,messageboxrr-1); setcolor(15); line(messageboxc,messageboxrr-16,messageboxcc-65,messageboxrr-16); line(messageboxc,messageboxrr-16,messageboxc,messageboxrr-15);
setfillstyle(SOLID_FILL,0); bar(messageboxcc-63,messageboxrr-16,messageboxcc-1,messageboxrr-1); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setcolor(15); setusercharsize(1,3,1,1); settextjustify(0,1); outtextxy(midx,messageboxr+5,"GREYcells"); setcolor(13); outtextxy(messageboxc+5,messageboxrr-11,"Press any key to continue..."); return 1;} int savebox(){ size=imagesize(messageboxc,messageboxr,messageboxcc,messageboxrr); sbox=malloc(size); getimage(messageboxc,messageboxr,messageboxcc,messageboxrr,sbox); return 1;} int restorebox(){ putimage(messageboxc,messageboxr,sbox, COPY_PUT); free(sbox); return 1;} int writeforcomputer(){ if (player==2){ if (playertype2==1 || playertype2==2){ strcpy(&newstr,"1");}} if (player==1 && playertype1==1){ strcpy(&newstr,"0");} if (boxc==210 && boxr==125){ strcpy(&box[1],&newstr);} if (boxc==210 && boxr==210){ strcpy(&box[2],&newstr);} if (boxc==210 && boxr==295){ strcpy(&box[3],&newstr);} if (boxc==310 && boxr==125){ strcpy(&box[4],&newstr);} if (boxc==310 && boxr==210){ strcpy(&box[5],&newstr);} if (boxc==310 && boxr==295){ strcpy(&box[6],&newstr);} if (boxc==410 && boxr==125){ strcpy(&box[7],&newstr);} if (boxc==410 && boxr==210){ strcpy(&box[8],&newstr);} if (boxc==410 && boxr==295){ strcpy(&box[9],&newstr);} return 1;} int checkcomputerwin(){ /* offensive moves for computer*/ if (oxx1==1 && oxx2==1 && oxx3==1 && once==0){ once=2;} if (oxx1==1 && oxx4==1 && oxx7==1 && once==0){ once=2;} if (oxx2==1 && oxx5==1 && oxx8==1 && once==0){ once=2;} if (oxx3==1 && oxx6==1 && oxx9==1 && once==0){ once=2;} if (oxx4==1 && oxx5==1 && oxx6==1 && once==0){ once=2;} if (oxx7==1 && oxx8==1 && oxx9==1 && once==0){ once=2;} if (oxx1==1 && oxx5==1 && oxx9==1 && once==0){ once=2;} if (oxx3==1 && oxx5==1 && oxx7==1 && once==0){ once=2;} return (once);}
No comments:
Post a Comment