int yourmovebox(){ messagebox(); cx=385; settextstyle(GOTHIC_FONT,HORIZ_DIR,2); setcolor(14); outtextxy(cx,50,"Your move !"); signal(); return 1;} int boxcursoron(){ setfillstyle(SOLID_FILL,12); bar(boxcol+3,boxrow-3,boxcoll+2,boxroww-2); setfillstyle(SOLID_FILL,9); bar(boxcol+7,boxrow,boxcoll-2,boxroww-5); cursoron=1; return 1;} int jingle(){ if (soundok==1){ sound(900); delay(50); sound(800); delay(50); sound(500); delay(50); sound(600); delay(50); sound(900); delay(50); sound(800); delay(50); sound(500); delay(50); sound(600); delay(50); nosound();
sound(700); delay(50); sound(800); delay(50); sound(900); delay(50); sound(600); delay(50); sound(800); delay(50); nosound();} return 1;} 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); if (menu==0){bar(menucol+4,menurow+25,menucoll-3,menurow+41);} 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); if (menu==0){ 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); if (menu==0){ 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 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 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 saveboxcursor(){ cursorsize=imagesize(boxcol,boxrow-3,boxcoll+2,boxroww); cursorbox=malloc(cursorsize); getimage(boxcol,boxrow-3,boxcoll+2,boxroww,cursorbox); return 1;} int restoreboxcursor(){ putimage(boxcol,boxrow-3,cursorbox, COPY_PUT); free(cursorbox); 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"); return 1;} int fourcoins(){ /* coins */ coin=1; ctr=0; circrow=120; circcol=25; circcolll=circcol+21; circcoll=circcol+13; coincolor=8; while (ctr<4){ drawcoin(); coin++; circcol=circcol+35; circcolll=circcol+21; circcoll=circcol+13; if (coin==7){ ctr++; coincolor=11; circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=220;}
if (coin==13){ ctr++; coincolor=13; circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=320;} if (coin==19){ ctr++; coincolor=6; circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=420;} if (coin==25){ctr++;} if (coin>0 && coin<7){ if (circcol>115){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=circrow+30;}} if (coin>6 && coin<13){ if (circcol>115){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=circrow+30;}}
if (coin>12 && coin<19){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; if (circcol>115){ circrow=circrow+30;}} if (coin>18 && coin<25){ if (circcol>115){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=circrow+30;}} } ctr=0; circrow=320; circcol=25; circcolll=circcol+21; circcoll=circcol+13; coincolor=13; while (ctr<6){ drawcoin(); coin++; circcol=circcol+35; circcolll=circcol+21; circcoll=circcol+13; if (circcol>115){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=circrow+30;} ctr++; } return 1;} int whatcolorcoin(){ if (w==1){ coincolor=8;} if (w==2){ coincolor=11;} if (w==3){ coincolor=13;} if (w==4){ coincolor=6;} return (coincolor);} int twocoins(){ coin=1; ctr=0; circrow=120; circcol=25; circcolll=circcol+21; circcoll=circcol+13; coincolor=8; while (ctr<2){ drawcoin(); coin++; circcol=circcol+35; circcolll=circcol+21; circcoll=circcol+13; if (coin==7){ ctr++; coincolor=11; circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=220;} if (coin>0 && coin<7){ if (circcol>115){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=circrow+30;}} if (coin>6 && coin<13){ if (circcol>115){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=circrow+30;}} if (coin==13){ctr++;} } return 1;} int threecoins(){ coin=1; ctr=0; circrow=120; circcol=25; circcolll=circcol+21; circcoll=circcol+13; coincolor=8; while (ctr<3){ drawcoin(); coin++; circcol=circcol+35; circcolll=circcol+21; circcoll=circcol+13; if (coin==7){ ctr++; coinboxcolor=11; circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=220;}
if (coin==13){ ctr++; coincolor=13; circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=320;} if (coin>0 && coin<7){ if (circcol>115){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=circrow+30;}} if (coin>6 && coin<13){ if (circcol>115){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=circrow+30;}} if (coin>12 && coin<19){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; if (circcol>115){ circrow=circrow+30;}} if (coin==19){ctr++;} } ctr=0; circrow=320; circcol=25; circcolll=circcol+21; circcoll=circcol+13; coincolor=13; while (ctr<6){ drawcoin(); coin++; circcol=circcol+35; circcolll=circcol+21; circcoll=circcol+13; if (circcol>115){ circcol=25; circcolll=circcol+21; circcoll=circcol+13; circrow=circrow+30;} ctr++; } return 1;} int messagebox(){ messageboxc=375; messageboxr=0; messageboxcc=640; messageboxrr=125; midx=485; errorscreen(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setcolor(12); settextjustify(0,1); outtextxy(messageboxc+5,messageboxr+9,"Alert"); if (player==1){ cx=385; setcolor(14); ct=1; outtextxy(cx,25,"Player 1 !");} if (player==2){ cx=385; setcolor(14); ct=2; outtextxy(cx,25,"Player 2 !");} if (player==3){ cx=385; setcolor(14); ct=3; outtextxy(cx,25,"Player 3 !");}
if (player==4){ cx=385; setcolor(14); ct=4; outtextxy(cx,25,"Player 4 !");} return 1;} int placecoin(){ if (player==1){ topbox=0; leftbox=0; bottombox=1; rightbox=0; if (vy==1 || vy==5){ startstatus=1; if (player1coins<=6){ putcoininbox=1; origcirccol=25; origcircrow=120; assessnumberofcoins(); coinstatus();} coincolor=10; drawcoin(); player1coins--; if (player1coins<=0){player1coins=0;} assessnumberofcoins(); } coincolor=8; boxcol=305; boxrow=330; boxcoll=boxcol+25; boxroww=boxrow+20; circcol=boxcol; circrow=boxrow; } if (player==2){ topbox=1; leftbox=0; bottombox=0; rightbox=0; if (vy==1 || vy==5){ startstatus=2; if (player2coins<=6){ origcirccol=25; origcircrow=220; putcoininbox=1; assessnumberofcoins(); coinstatus();} coincolor=9; drawcoin(); player2coins--; if (player2coins<=0){player2coins=0;} assessnumberofcoins(); } boxcol=305; boxrow=205; boxcoll=boxcol+25; boxroww=boxrow+20; coincolor=11; circcol=boxcol; circrow=boxrow; } if (player==3){ topbox=0; leftbox=0; bottombox=0; rightbox=1; if (vy==1 || vy==5){ startstatus=3; if (player3coins<=6){ origcirccol=25; origcircrow=320; putcoininbox=1; assessnumberofcoins(); coinstatus();} coincolor=3; drawcoin(); player3coins--; if (player3coins<=0){player3coins=0;} assessnumberofcoins(); } boxcol=365; boxrow=265; boxcoll=boxcol+20; boxroww=boxrow+20; circcol=boxcol; circrow=boxrow; coincolor=13; } if (player==4){ topbox=0; leftbox=1; bottombox=0; rightbox=0; if (vy==1 || vy==5){ startstatus=4; if (player4coins<=6){ origcirccol=25; origcircrow=420; putcoininbox=1; assessnumberofcoins(); coinstatus();} coincolor=14; drawcoin(); player4coins--; if (player4coins<=0){player4coins=0;} assessnumberofcoins(); } boxcol=250; boxcoll=boxcol+20; boxrow=265; boxroww=boxrow+20; circcol=boxcol; circrow=boxrow; coincolor=6; } updatebox(); startctr=cursorctr; return 1;} int firstbox(){ boxcoll=boxcol+25; boxroww=boxrow+20; return 1;} int secondbox(){ boxcoll=boxcol+20; boxroww=boxrow+25; return 1;} int cursound(){ if (soundok==1){ sound(200); delay(50); nosound();} return 1;} int sizecoin(){ if (bottombox==1 || topbox==1){ circcol=boxcol+4; circcolll=circcol+21; circcoll=circcol+13; circrow=boxrow-5;} if (leftbox==1 || rightbox==1 || leftbox==2 || bottombox==2 || topbox==2 || rightbox==2){ circcol=boxcol+3; circcolll=boxcoll+2; circcoll=circcol+12; circrow=boxrow-5;} return 1;} int sendcoinbacktobox(){ sscanf(&box[cursorctr],"%d",&y); sscanf(&whosecoininbox[cursorctr],"%d",&w); i=y; numberofcoinsinbox=0; assessnumberofcoins(); while (numberofcoinsinbox0){score1=score1-10;} col=50; writescore(); origcircrow=120; circrow=origcircrow; coincolor=8;} if (w==2){ if (score2>0){score2=score2-10;} col=100; writescore(); origcircrow=220; circrow=origcircrow; coincolor=11;} if (w==3){ if (score3>0){score3=score3-10;} col=150; writescore(); origcircrow=320; circrow=origcircrow; coincolor=13;} if (w==4){ if (score4>0){score4=score4-10;} col=200; writescore(); origcircrow=420; circrow=origcircrow; coincolor=6;} numberofcoinsinbox++; } while (y>0){ if (coinsinbox==5){ circcol=origcirccol; circrow=origcircrow;} if (coinsinbox==4){ circcol=origcirccol+35; circrow=origcircrow;} if (coinsinbox==3){ circcol=origcirccol+70; circrow=origcircrow;} if (coinsinbox==2){ circcol=origcirccol; circrow=origcircrow+30;} if (coinsinbox==1){ circcol=origcirccol+35; circrow=origcircrow+30;} if (coinsinbox==0){ circcol=origcirccol+70; circrow=origcircrow+30;} circcolll=circcol+21; circcoll=circcol+13; drawcoin(); if (w==1){player1coins++;} if (w==2){player2coins++;} if (w==3){player3coins++;} if (w==4){player4coins++;} assessnumberofcoins(); y--;} numberofcoinsinbox=i; return (numberofcoinsinbox);} int drawcoin(){ setfillstyle(SOLID_FILL,coincolor); bar(circcol+8,circrow+5,circcoll,circrow+15); bar(circcol,circrow+15,circcolll,circrow+20); /* circcolll=circcol+21 circcoll=circcol+13*/ return 1;} int coinstatus(){ if (coinsinbox==1){ circcol=origcirccol+70; circcolll=circcol+21; circcoll=circcol+13; circrow=origcircrow+30;} if (coinsinbox==2){ circcol=origcirccol+35; circcolll=circcol+21; circcoll=circcol+13; circrow=origcircrow+30;} if (coinsinbox==3){ circcol=origcirccol; circcolll=circcol+21; circcoll=circcol+13; circrow=origcircrow+30;} if (coinsinbox==4){ circcol=origcirccol+70; circcolll=circcol+21; circcoll=circcol+13; circrow=origcircrow;} if (coinsinbox==5){ circcol=origcirccol+35; circcolll=circcol+21; circcoll=circcol+13; circrow=origcircrow;} if (coinsinbox==6){ circcol=origcirccol; circrow=origcircrow; circcolll=circcol+21; circcoll=circcol+13;} return 1;} int assessnumberofcoins(){ if (player==1){ coinsinbox=player1coins;} if (player==2){ coinsinbox=player2coins;} if (player==3){ coinsinbox=player3coins;} if (player==4){ coinsinbox=player4coins;} return 1;} int signal(){ radius=7; if (soundok==1){ sound(700); delay(150); nosound();} setlinestyle(SOLID_LINE,1,1); setcolor(4); setfillstyle(SOLID_FILL,4); circle(col,row,radius+1); floodfill(col,row,4); if (player==1){ col=50;} if (player==2){ col=100;} if (player==3){ col=150;} if (player==4){ col=200;} delay(500); setcolor(2); setlinestyle(SOLID_LINE,1,1); setfillstyle(SOLID_FILL,2); circle(col,row,radius+1); floodfill(col,row,2); if (soundok==1){ sound(900); delay(150); nosound();} return 1;} int playernobox(){ messageboxc=150; messageboxr=173; messageboxcc=500; messageboxrr=300; midx=300; errorscreen(); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); setcolor(12); settextjustify(0,1); outtextxy(messageboxc+5,messageboxr+9,"Start"); setcolor(15); outtextxy(165,225,"How many players ? -"); cx=165; cx+=textwidth("How many players ? -"); cx=cx+10; rx=225; setfillstyle(SOLID_FILL,1); bar(cx,rx-5,cx+30,rx+10); setlinestyle(SOLID_LINE,1,1); setcolor(0); line(cx+2,rx-4,cx+2,rx+9); line(cx+2,rx-4,cx+28,rx-4); setcolor(15); line(cx+2,rx+9,cx+28,rx+9); line(cx+28,rx-4,cx+28,rx+9); setfillstyle(SOLID_FILL,12); bar(cx+2,rx-3,cx+4,rx+8); return 1;} int updatebox(){ switch(boxcol){ case 305: if (boxrow==205){ cursorctr=16;} if (boxrow==180){ cursorctr=17;} if (boxrow==155){ cursorctr=18;} if (boxrow==130){ cursorctr=19;} if (boxrow==105){ cursorctr=20;} if (boxrow==330){ cursorctr=1;} if (boxrow==355){ cursorctr=2;} if (boxrow==380){ cursorctr=3;} if (boxrow==405){ cursorctr=4;} if (boxrow==430){ cursorctr=5;} break; case 275: if (boxrow==205){ cursorctr=30;} if (boxrow==180){ cursorctr=29;} if (boxrow==155){ cursorctr=28;} if (boxrow==130){ cursorctr=27;} if (boxrow==105){ cursorctr=26;} if (boxrow==430){ cursorctr=6;} if (boxrow==405){ cursorctr=7;} if (boxrow==380){ cursorctr=8;} if (boxrow==355){ cursorctr=9;} if (boxrow==330){ cursorctr=10;} break; case 335: if (boxrow==205){ cursorctr=25;} if (boxrow==180){ cursorctr=24;} if (boxrow==155){ cursorctr=23;} if (boxrow==130){ cursorctr=22;} if (boxrow==105){ cursorctr=21;} if (boxrow==330){ cursorctr=15;} if (boxrow==355){ cursorctr=14;} if (boxrow==380){ cursorctr=13;} if (boxrow==405){ cursorctr=12;} if (boxrow==430){ cursorctr=11;} break; } switch(boxrow){ case 295: if (boxcol==365){ cursorctr=40;} if (boxcol==390){ cursorctr=39;} if (boxcol==415){ cursorctr=38;} if (boxcol==440){ cursorctr=37;} if (boxcol==465){ cursorctr=36;} if (boxcol==250){ cursorctr=60;} if (boxcol==225){ cursorctr=59;} if (boxcol==200){ cursorctr=58;} if (boxcol==175){ cursorctr=57;} if (boxcol==150){ cursorctr=56;} break; case 265: if (boxcol==365){ cursorctr=31;} if (boxcol==390){ cursorctr=32;} if (boxcol==415){ cursorctr=33;} if (boxcol==440){ cursorctr=34;} if (boxcol==465){ cursorctr=35;} if (boxcol==250){ cursorctr=46;} if (boxcol==225){ cursorctr=47;} if (boxcol==200){ cursorctr=48;} if (boxcol==175){ cursorctr=49;} if (boxcol==150){ cursorctr=50;} break; case 235: if (boxcol==365){ cursorctr=45;} if (boxcol==390){ cursorctr=44;} if (boxcol==415){ cursorctr=43;} if (boxcol==440){ cursorctr=42;} if (boxcol==465){ cursorctr=41;} if (boxcol==250){ cursorctr=55;} if (boxcol==225){ cursorctr=54;} if (boxcol==200){ cursorctr=53;} if (boxcol==175){ cursorctr=52;} if (boxcol==150){ cursorctr=51;} break; case 330: /* rightbox=2*/ if (boxcol==365){ cursorctr=64;} /* bottombox=2 */ if (boxcol==250){ cursorctr=61;} break; case 205: /* top box=2 */ if (boxcol==365){ cursorctr=63;} /* leftbox=2*/ if (boxcol==250){ cursorctr=62;} break; } if (putcoininbox==1){placecoininbox();} if (pickcoin==3 && hotkey==0){checkifhomecol();} if (pickcoin==2 || pickcoin==3){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(6); outtextxy(580,215,&playercoin); setcolor(6); outtextxy(565,290,&coins); sscanf(&whosecoininbox[cursorctr],"%d",&coininbox); sprintf(&playercoin,"%d",coininbox); sscanf(&box[cursorctr],"%d",&coininbox); sprintf(&coins,"%d",coininbox); setcolor(15); outtextxy(580,215,&playercoin); outtextxy(565,290,&coins);} if (pickcoin==3){ setfillstyle(SOLID_FILL,6); bar(285,30,340,50); settextstyle(GOTHIC_FONT,HORIZ_DIR,3); settextjustify(0,1); sprintf(&newstr,"%d",boxctr); setcolor(14); outtextxy(300,35,&newstr);} return 1;}
int hitbox(){ strcpy(&box[cursorctr],"0"); sscanf(&box[cursorctr],"%d",&coininbox); sprintf(&box[cursorctr],"%d",coininbox); settextstyle(GOTHIC_FONT,HORIZ_DIR,1); setcolor(14); cx=385; jingle(); outtextxy(cx,35,"It's a hit !"); y=0; while (y0){ if (player==1){ sscanf(&player1inbox[cursorctr],"%d",&specialcoin1); if (specialcoin1>0){ specialcoin1--;} if (specialcoin1==0){ sprintf(&player1inbox[cursorctr],"%d","0");} } if (player==2){ sscanf(&player2inbox[cursorctr],"%d",&specialcoin2); if (specialcoin2>0){ specialcoin2--;} if (specialcoin2==0){ sprintf(&player2inbox[cursorctr],"%d","0");} } if (player==3){ sscanf(&player3inbox[cursorctr],"%d",&specialcoin3); if (specialcoin3>0){ specialcoin3--;} if (specialcoin3==0){ sprintf(&player3inbox[cursorctr],"%d","0");} } if (player==4){ sscanf(&player4inbox[cursorctr],"%d",&specialcoin4); if (specialcoin4>0){ specialcoin4--;} if (specialcoin4==0){ sprintf(&player4inbox[cursorctr],"%d","0");} } } w=player; whatcolorcoin(); player=w; } if (cursorctr!=5 || cursorctr!=50 || cursorctr!=61 || cursorctr!=62 || cursorctr!=62 || cursorctr!=63 || cursorctr!=64 || cursorctr!=20 || cursorctr!=35){ if (coininbox>0){ sscanf(&whosecoininbox[cursorctr],"%d",&w); whatcolorcoin();}} return (coininbox);} int iscoininbox(){ if (cursorctr!=5 || cursorctr!=50 || cursorctr!=61 || cursorctr!=62 || cursorctr!=62 || cursorctr!=63 || cursorctr!=64 || cursorctr!=20 || cursorctr!=35){ ptr=strcmp(&box[cursorctr],"0"); if (ptr==0){ok=5;} if (ptr>0 || ptr<0){ok=0;} } if (cursorctr==5 || cursorctr==50 || cursorctr==61 || cursorctr==62 || cursorctr==62 || cursorctr==63 || cursorctr==64 || cursorctr==20 || cursorctr==35){ ok=-1;} return (ok);} int whosecoin(){ sprintf(&playercoin,"%d",player); ptr=strcmp(&whosecoininbox[cursorctr],&playercoin); if (ptr==0){ok=0;} if (ptr<0 || ptr>0){ ok=4;} return (ok);} int whosecoinisleft(){ sscanf(&player1inbox,"%d",&specialcoin1); if (specialcoin1>0){ coincolor=8;} sscanf(&player2inbox,"%d",&specialcoin2); if (specialcoin2>0){coincolor=11;} sscanf(&player3inbox,"%d",&specialcoin3); if (specialcoin3>0){ coincolor=13;} sscanf(&player4inbox,"%d",&specialcoin4); if (specialcoin4>0){coincolor=6;} return (coincolor);} int redrawbox(){ if (cursorctr<61){ incolor=15;} if (cursorctr>=61){ incolor=0;} setfillstyle(SOLID_FILL,incolor); bar(boxcol+1,boxrow-4,boxcoll+4,boxroww-1); if (leftbox==2 || rightbox==2){ setlinestyle(SOLID_LINE,1,1); setcolor(12); /* 4 box cross lines */ line(boxcol,boxrow-5,boxcoll+5,boxroww); line(boxcol,boxroww,boxcoll+5,boxrow-5);} if (bottombox==2 || topbox==2){ setcolor(12); /* 4 box cross lines */ line(boxcol,boxrow-5,boxcoll+5,boxroww); line(boxcol,boxroww,boxcoll+5,boxrow-5);} if (cursorctr==1 || cursorctr==5 || cursorctr==16 || cursorctr==31 || cursorctr==35 || cursorctr==46 || cursorctr==50 || cursorctr==20){ setlinestyle(SOLID_LINE,1,1); setcolor(12); if (leftbox==1 || rightbox==1){ /* 4 box cross lines */ line(boxcol,boxrow-5,boxcoll+5,290); line(boxcol,290,boxcoll+5,boxrow-5);} if (bottombox==1 || topbox==1){ /* 4 box cross lines */ line(boxcol,boxrow-5,boxcoll+5,boxroww); line(boxcol,boxroww,boxcoll+5,boxrow-5);}} return 1;} int opponentscoin(){ messagebox(); settextstyle(GOTHIC_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(14); cx=380; if (ok>0 && ok<5){ setcolor(0); outtextxy(cx,50,"Sorry ! Opponents' coin !");} if (ok==5){ setcolor(0); outtextxy(cx,50,"Sorry ! No coin in box !");} return 1;} int announcewinner(){ jingle(); messagebox(); settextstyle(GOTHIC_FONT,HORIZ_DIR,1);setcolor(14);cx=383; if (player==1 && player1wincoin==6){ outtextxy(cx,35,"Player 1 !");} if (player==2 && player2wincoin==6){ outtextxy(cx,35,"Player 2 !");} if (player==3 && player3wincoin==6){ outtextxy(cx,35,"Player 3 !");} if (player==4 && player4wincoin==6){ outtextxy(cx,35,"Player 4 !");} outtextxy(cx,55,"You win !"); tothrowdice=4; return 1;} int firstscreen(){ if (ix==0 || ic==5){ tablet(); settextstyle(SIMPLEX_FONT,HORIZ_DIR,1); settextjustify(0,1); setusercharsize(1,4,1,4); setcolor(3); outtextxy(35,125,"This is a"); outtextxy(35,145,"shareware software."); outtextxy(35,165,"To continue using"); outtextxy(35,185,"this software, please send a"); outtextxy(35,205,"cheque of Rs.800.00 only or $20.00"); outtextxy(35,225,"drawn in favor of"); setcolor(12); outtextxy(35,250,"J.V.Ravichandran"); setcolor(12); outtextxy(35,270,"Proprietor/Software Architect/Consultant."); setcolor(0); outtextxy(35,290,"and address it to"); settextstyle(BOLD_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(2); outtextxy(105,340,"B - 10,"); outtextxy(105,360,"Triveni Apartments,"); outtextxy(105,380,"Vikas puri, New Delhi-18"); outtextxy(105,395,"(c) Semantix Computers, New Delhi, 1998.");
delay(1000);} if (ic!=5){ col=609; row=415;
while (col>30){setlinestyle(SOLID_LINE,1,1);setcolor(15);line (col,26,col,row);row=row-2;col=col-3;delay(30); if (col==370 || col==371 || col==372 || col==373 || col==374 || col==375){ settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1); setcolor(10); outtextxy(375,225,"(Ludo)");} } } sound(2900); delay(250); nosound(); if (ix==0){color=4;} if (ix==1){color=2;} setlinestyle(SOLID_LINE,1,3); setcolor(color); line(x,173,x+5,175); line(y,173,y+5,175); line(xx,173,xx+5,175);
if (ok==20){ col=30; row=26; while (col<610){row1=row+2;setlinestyle(SOLID_LINE,1,1);setcolor(0);line (col,26,col,row1);row=row+2;col=col+3;delay(30);}} settextstyle(GOTHIC_FONT,HORIZ_DIR,1); setcolor(10); outtextxy(475,250,"The royal game"); outtextxy(535,295,"of dice !");
logo(); delay(4000); setcolor(2); settextstyle(COMPLEX_FONT,HORIZ_DIR,1); settextjustify(0,1); setusercharsize(1,3,1,1); outtextxy(175,295,"Designed & developed"); cx=175; cx+=textwidth("Designed & developed"); setcolor(14); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1); settextjustify(0,1); setusercharsize(1,3,1,1); outtextxy(cx,335,"by"); cx+=textwidth("by"); setcolor(4); settextstyle(COMPLEX_FONT,0,1); settextjustify(0,1); setusercharsize(1,3,1,1); outtextxy(cx+10,355,"J.V.Ravichandran"); getch(); return 1;} int about(){ ok=1; ctr=0; counter=1; handle=open("about.HLP",O_RDONLY | O_TEXT); coll=630; ic=6; writehelp(); return 1;} int howtoplay(){ ok=3; coll=630; ic=6; tablet(); ok=3; logo(); settextstyle(TRIPLEX_SCR_FONT,HORIZ_DIR,1); settextjustify(0,1); setusercharsize(1,2,1,2); setcolor(10); outtextxy(50,40,"How to play LUDO"); return 1;} int drawbox(){ if (player==1){ color=10; color1=14; col=15; row=95; coll=130; row1=175;} if (player==2){ color=9; color1=1; row=row+100; row1=row+80;} if (player==3){ color=3; color1=12; row=row+200; row1=row+80;} if (player==4){ color=14; color1=10; row=row+300; row1=row+80;} setfillstyle(SOLID_FILL,color); bar(col,row,coll,row1); setfillstyle(SOLID_FILL,color1); bar(col,row,coll,row+15); return 1;} int tablet(){ setfillstyle(SOLID_FILL,15); bar(25,20,coll,420); setfillstyle(SOLID_FILL,7); bar(25,20,coll,23); setfillstyle(SOLID_FILL,0); bar(coll-4,24,coll,416); setfillstyle(SOLID_FILL,7); bar(coll-3,20,coll,420); setfillstyle(SOLID_FILL,8); bar(25,22,28,420); bar(25,417,coll-2,420); setlinestyle(SOLID_LINE,1,1); setcolor(15); line(25,20,29,24); line(coll,20,coll-4,24); line(25,420,29,416); line(coll,420,coll-4,416); setlinestyle(SOLID_LINE,1,1); setcolor(0); line(29,24,coll-5,24);
setlinestyle(SOLID_LINE,1,1); if (ix==0){color=0;} if (ix==1){color=14;} /* 3 circles */ setcolor(color); circle(310,220,25); setfillstyle(SOLID_FILL,color); floodfill(310,220,color); setcolor(color); circle(94,75,25); setfillstyle(SOLID_FILL,color); floodfill(94,75,color); setcolor(color); circle(540,372,25); setfillstyle(SOLID_FILL,color); floodfill(540,372,color);
if (ix==0){ col=609; row=415; while (col>30){setlinestyle(SOLID_LINE,1,1);setcolor(0);line (col,26,col,row);row=row-2;col=col-3;}color=2;} if (ix==1){color=4;} settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3); settextjustify(0,1); setusercharsize(3,1,1,1); setcolor(color); outtextxy(200,100,"GREYcells"); if (ix==0){color=4;} if (ix==1){color=2;} settextstyle(GOTHIC_FONT,HORIZ_DIR,3); settextjustify(0,1); setusercharsize(2,1,1,1); setcolor(color); outtextxy(325,175,"Dayakattai"); cx=325; cx+=textwidth("D"); setcolor(color); outtextxy(cx,165,"~"); cx=325; cx+=textwidth("Day"); cx=cx+10; x=cx; cx=325; cx+=textwidth("Dayak"); cx=cx+10; y=cx; cx=325; cx+=textwidth("Dayakatt"); cx=cx+10; xx=cx;
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1); settextjustify(0,1); if (ix==0){color=10;} if (ix==1){color=7;} setcolor(10); outtextxy(375,225,"(Ludo)"); if (ic==6){ settextstyle(SCRIPT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(9); outtextxy(95,370,"GREYcells series of business applications"); settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(14); outtextxy(95,390,"Complete Business Solutions. Total Quality Softwares."); settextstyle(TRIPLEX_SCR_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(4); outtextxy(100,400,"A product of J.V.Ravichandran");} if (counter==1){ settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1); settextjustify(0,1); setusercharsize(2,1,1,1); setcolor(1); outtextxy(28,40,"About the software");} if (counter==10){ settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1); setusercharsize(1,2,1,1); settextjustify(0,1); setcolor(1); outtextxy(50,35,"Rules & Regulations");} if (counter==11){ settextstyle(SANS_SERIF_FONT,HORIZ_DIR,1); setusercharsize(1,2,1,1); settextjustify(0,1); setcolor(1); outtextxy(50,35,"How to play...");} return 1;} int logo(){ /* logo */ setlinestyle(SOLID_LINE,1,1); col=40; col1=60; row=345; row1=370; ctr=0; setcolor(1); while (ctr<10){ line(col,row,col,row1); line(col,row,col1,row); line(col1,row,col,row1); col++; row1--; col1--; row++; ctr++;} line(col1+1,row,col,row1); col=75; coll=60; col1=90; row=395; row1=410; ctr=0; setcolor(2); while (ctr<15){ line(col,row,col1,row1); line(col,row,coll,row1); line(coll,row1,col1,row1); row++; coll++; col1--; ctr++;} setcolor(14); circle(55,385,12); setfillstyle(SOLID_FILL,14); floodfill(55,385,14); settextstyle(SIMPLEX_FONT,HORIZ_DIR,1); settextjustify(0,1); setusercharsize(1,4,1,4); setcolor(12); outtextxy(35,320,"SEMANTIX Computers"); if (ok==3){ settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(4); outtextxy(75,150,"Rules & Regulations"); outtextxy(75,170,"How to play..."); outtextxy(75,190,"Back"); ctr=0;} return (ctr);} int drawarrow(){ col=305; row=330; settextstyle(SMALL_FONT,HORIZ_DIR,1); setusercharsize(3,3,3,3); settextjustify(0,1); setcolor(4); outtextxy(307,330,"Start"); setcolor(1); outtextxy(309,340,"Home"); setcolor(4); outtextxy(309,205,"Home"); setcolor(1); outtextxy(307,215,"Start"); settextstyle(SMALL_FONT,VERT_DIR,1); setusercharsize(3,3,3,3); settextjustify(0,1); setcolor(4); outtextxy(365,275,"Start"); setcolor(1); outtextxy(375,275,"Home"); setcolor(4); outtextxy(260,275,"Start"); setcolor(1); outtextxy(250,275,"Home"); return 1;} int updatewincoins(){ if (player==1){ player1wincoin++;} if (player==2){ player2wincoin++;} if (player==3){ player3wincoin++;} if (player==4){ player4wincoin++;} return 1;} int writehelp(){ ic=6; tablet(); logo(); cx=35; rx=70; ic=1; settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1); setcolor(4); lseek(handle,0L,SEEK_SET); ptr=2; while (!eof(handle)){ read(handle,&str[1],1); if (cx>560){ ptr=strcmp(&str[1]," "); if (ptr==0){ cx=35; rx=rx+20;}} if (ptr!=0){ outtextxy(cx,rx,&str[1]); cx+=textwidth(&str[1]);} if (rx>310 && pagectr==1){getch();w=11;} if (rx>310 && w>=10){ setcolor(10); outtextxy(300,320,"Press any key ..."); pagectr++; getch(); coll=640; ok=2; ic=6; tablet(); logo(); rx=70; cx=35; settextstyle(DEFAULT_FONT,HORIZ_DIR,1); settextjustify(0,1);} if (cx==35 && ptr==0){ptr=2;} } getch(); close(handle); return (ctr);} int checkifhomecol(){ if (player==1 && player1hit==1){ if (boxcol==305 && boxrow>330){ home=1; hotkey=1;}} if (player==2 && player2hit==1){ if (boxcol==305 && boxrow<205){ home=1; hotkey=1;}} if (player==3 && player3hit==1){ if (boxrow==265 && boxcol>365){ home=1; hotkey=1;}} if (player==4 && player4hit==1){ if (boxrow==265 && boxcol<250){ home=1; hotkey=1;}} return (hotkey);} int updatecoin(){ checkifwincol(); if (okctr==1){jingle();updatewincoins();announcewinner();sscanf(&hotcoin [hitctr],"%d",&hotctr);oktoplace=0;okplace=1;okctr=0;ct=0;hotkey=0;home=0;} if (okctr==0){ if (hotkey==1){sscanf(&hotcoin[hitctr],"%d",&hotctr);} putcoininbox=0; updatebox(); checkifcoininboxishot(); putcoininbox=1; updatebox(); sizecoin(); drawcoin(); if (hotctr>0){ hotctr++;} if (hotctr==0){ hotctr=1;} sprintf(&hotcoin[cursorctr],"%d",hotctr); okplace=1;} return (ct);} int ishotcoin(){ hotkey=0; hotctr=0; hitctr=cursorctr; if (player==1 && boxcol==305 && boxrow>=330){ sscanf(&hotcoin[cursorctr],"%d",&hotctr); if (hotctr>0){hotctr--;hotkey=1;}} if (player==2 && boxcol==305 && boxrow>=330){ sscanf(&hotcoin[cursorctr],"%d",&hotctr); if (hotctr>0){hotctr--;hotkey=1;}} if (player==3 && boxrow==265 && boxcol>=365){ sscanf(&hotcoin[cursorctr],"%d",&hotctr); if (hotctr>0){hotctr--;hotkey=1;}} if (player==4 && boxrow==265 && boxcol>=150){ sscanf(&hotcoin[cursorctr],"%d",&hotctr); if (hotctr>0){hotctr--;hotkey=1;}} return (hotkey);} int checkifwincol(){ okctr=0; if (player==1){ if (boxcol==305 && boxrow==330){ okctr=1;}} if (player==2){ if (boxcol==305 && boxrow==205){ okctr=1;}} if (player==3){ if (boxrow==265 && boxcol==365){ okctr=1;}} if (player==4){ if (boxrow==265 && boxcol==250){ okctr=1;}} return (okctr);} int checkifcoininboxishot(){ sscanf(&box[cursorctr],"%d",&coininbox); if (coininbox>0){ sscanf(&hotcoin[cursorctr],"%d",&hotctr);} if (coininbox==0){ hotctr=0;} return (hotctr);}