/************************************************************************/ /* Designed & developed by J.V.RAVICHANDRAN. */ /* Started on 02/05/1998. */ /* 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 -- 15th May, 1998. */ /* Name of software -- GREYcells LUDO */ /* Nature of software -- Game */ /************************************************************************/ #include#include #include #include #include #include #include #include #include #include #include #define ALT 1 char *hotcoin[65]; char *player1inbox[6]; char *player2inbox[6]; char *player3inbox[6]; char *player4inbox[6]; int specialcoin1=0,specialcoin2=0,specialcoin3=0,specialcoin4=0; char terminator; int player1wincoin,player2wincoin,player3wincoin,player4wincoin,ik=2,pagectr,menu,esckey=1; int home,hotctr,oktoplace,okplace,okctr,hitctr,hotkey,score1,score2,score3,score4; int roww,col,row,radius,coininbox,coin,ok,row1,coll,col1,radius,color1,okk,number; int cursorctr=1,pickcoin,numberofcoinsinbox=0,boxctr,ptr,tothrowdice=0,putcoininbox=0; int gdriver = VGA, gmode=VGAHI, err_code,time_spent=0,incolor; int i,x,y,xx,yy,barx,bary,barxx,baryy,key,scorex,score,ix=0,cx; int messageboxc,messageboxr,messageboxcc,messageboxrr,midx,soundon=1; int startstatus=0; int menuon,menuflag,menuitem,item; int menucol,menurow,menucoll,menuroww,playerctr=0; int ic,cx,rx,player=0,entered=0,textcounter,lasttextcounter; int dicecol,dicerow,dicecoll,diceroww,dice1,dice2; char *str[45]; char *box[65]; char *whosecoininbox[65]; char newstr,coins,playercoin; int handle; void *sbox; void *cursorbox; unsigned size; unsigned cursorsize; int boxrow=200,boxcol=335,boxcoll=360,boxroww=225,soundok=1; int incolor,linecolor,bgcolor,coin,ctr,circrow,circcol,circcoll,circroww,circcolll,coinboxcolor,coinsinbox=6,coincolor; int seed,count,color,ccx=10,handle,ct,gamestart,sharecounter,coininbox; int w,h,vy,i,throw,gameactive=0,cursoron=0,origcirccol,origcircrow; int topbox=0,bottombox=0,leftbox=0,rightbox=0,makemove=0,player1coins=6,player2coins=6,player3coins=6,player4coins=6; int counter,lastcounter,player1hit=0,player2hit=0,player3hit=0,player4hit=0,startctr,endctr; main(){ initgraph(&gdriver, &gmode, ""); err_code = graphresult(); if (err_code !=grOk) { printf("Graphic initialization error...\n"); time_spent=0; while (time_spent<50){ time_spent++; delay(25);} exit(0); }
ct=access("termludo.$$$",0);
if (ct==-1){
messagebox();
settextstyle(GOTHIC_FONT,HORIZ_DIR,1);setcolor(14);cx=383;
outtextxy(cx,35,"Intruder alert ! Please contact");
outtextxy(cx,55,"the developer immediately.");
cursound();
getch();
ik=1;}
if (ct==0){
handle=_open("termludo.$$$", O_RDONLY | O_TEXT);
lseek(handle, 0L, SEEK_SET);
while (!eof(handle)){
read(handle,&terminator,4);}
chmod("termludo.$$$",S_IWRITE);
unlink("termludo.$$$");
_fmode=O_BINARY;
handle=_creat("termludo.$$$", FA_HIDDEN);
lseek(handle, 0L, SEEK_SET);
sscanf(&terminator,"%d",&counter);
counter++;
sprintf(&terminator,"%d",counter);
_write(handle,&terminator,4);
chmod("termludo.$$$",S_IREAD);
_close(handle);
if (counter<38){
ik=0;}
if (counter>38){
jingle();
ic=0;
ix=0;
coll=616;
firstscreen();
getch();
cleardevice();
ik=1;
sharecounter=1;}}
if (ik==0){
ic=0;
coll=616;
counter=0;
firstscreen();
repaint();
gamestart=2;
ix=1;}
while (ix==1){
key=getch();
switch(key){
case 8:
if (textcounter>1 && entered==1){
cx-=textwidth(&key);
setfillstyle(SOLID_FILL,1);
bar(cx,rx-3,cx+10,rx+8);
textcounter--;
setfillstyle(SOLID_FILL,12);
bar(cx+2,rx-3,cx+4,rx+8);}
break;
case 61:
if (gamestart==1 && gameactive==1){
if (tothrowdice==0){
assessnumberofcoins();
if (vy==5 || vy==1){
esckey=1;}
if (esckey==1){
if (coinsinbox==6){
cursound();}
if (coinsinbox<6){
dice1=vy;
putcoininbox=0;
vy=0;
placecoin();
saveboxcursor();
boxcursoron();
vy=dice1;
okk=0;
boxctr=0;
pickit();
makemove=1;
tothrowdice=2;}}
}}
break;
case 60:
jingle();
number=3;
time_spent=random(number);
if (time_spent==0){
srand(i);}
if (time_spent==1){
srand(h);}
if (time_spent==2){
srand(i);}
if (time_spent==3){srand(h);srand(i);}
break;
case 9:
if (gamestart==2){
if (menuon==0 && menuitem==2 && item==1){
if (ctr==0){
col=70;
coll=col;
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
coll+=textwidth("Rules & Regulations");
row=140;
messageboxc=col;
messageboxr=row;
messageboxcc=coll+15;
messageboxrr=row+20;
savebox();
setfillstyle(SOLID_FILL,10);
bar(col,row,coll+10,row+15);
setcolor(14);
outtextxy(75,150,"Rules & Regulations");}
if (ctr==1){
restorebox();
coll+=textwidth("How to play...");
messageboxc=col;
messageboxr=row;
messageboxcc=coll+15;
messageboxrr=row+20;
savebox();
setfillstyle(SOLID_FILL,10);
bar(col,row,coll+10,row+15);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(14);
outtextxy(75,170,"How to play...");}
if (ctr==2){
restorebox();
coll+=textwidth("Back");
messageboxc=col;
messageboxr=row;
messageboxcc=coll+15;
messageboxrr=row+20;
savebox();
setfillstyle(SOLID_FILL,10);
bar(col,row,coll+10,row+15);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(14);
outtextxy(75,190,"Back");}
ctr++;
row=row+20;
col=70;
coll=col;
if (ctr>3){
restorebox();
ctr=0;}
}
}
break;
case 32:
if (gamestart==1){
if (tothrowdice==2 && okk==0){
iscoininbox();
if (ok==5){opponentscoin();ok=3;}
if (ok==0){whosecoin();}
if (ok==0 || ok==-1){
ishotcoin();
boxctr=0;
pickcoin=3;
pickcoininbox();
if (coininbox==0){
restoreboxcursor();
redrawbox();
saveboxcursor();}
w=player;
whatcolorcoin();
player=w;
boxcursoron();
sizecoin();
drawcoin();
menuon=2;
makemove=1;
gameactive=1;
tothrowdice=3;}
if (ok==4){opponentscoin();ok=3;getch();pickit();}
if (ok==3){ok=0;pickcoin=2;}
}
if (tothrowdice==1){
throw=0;
startstatus=0;
makemove=0;
throwdice();
if (vy==1 || vy==5){
gameactive=1;
makemove=1;
assessnumberofcoins();
if (coinsinbox>0){
makemove=0;
tothrowdice=0;}}
if (vy!=1 && vy!=5){
assessnumberofcoins();
if (coinsinbox<6){
pickit();
makemove=1;
putcoininbox=0;
placecoin();
saveboxcursor();
boxcursoron();
okk=0;
tothrowdice=2;
makemove=1;}
if (coinsinbox==6){
okk=1;
tothrowdice=0;
makemove=0;
ct=4;
diceboxstart();}}
}
}
if (gamestart==2){
if (menuon==2){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
sound(100);
delay(50);
nosound();
soundon++;
if (soundon>1){soundon=0;}
if (soundon==0){
soundok=0;}
if (soundon==1){
soundok=1;}
restorebox();
setcolor(7);
settextstyle(DEFAULT_FONT,VERT_DIR,1);
settextjustify(0,1);
outtextxy(18,11,"0");
menu=0;
item=0;
menuon=0;
menuon=0;}}
break;
case ALT==1:
case 129:
if (gamestart==2 && menuon==0){
menu=1;
menucol=15;
menurow=14;
menucoll=164;
menuroww=36;
messageboxc=15;
messageboxr=14;
messageboxcc=164;
messageboxrr=36;
savebox();
dropdownmenu();
setcolor(12); settextstyle(DEFAULT_FONT,VERT_DIR,1); settextjustify(0,1); outtextxy(18,11,"0");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(15);
if (soundon==1){
outtextxy(menucol+75,menurow+13,"Sound ( ON )");}
if (soundon==0){
outtextxy(menucol+75,menurow+13,"Sound ( OFF )");}
menuon=2;}
break;
case 34:
if (gamestart==2 && menuon==0){
menu=0;
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(12);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(15);
outtextxy(cx,60,"ame");
menucol=10;
menurow=63;
menucoll=130;
menuroww=106;
messageboxc=menucol;
messageboxr=menurow;
messageboxcc=menucoll;
messageboxrr=menuroww;
savebox();
dropdownmenu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(8);
outtextxy(menucol+60,menurow+13,"Start");
outtextxy(menucol+60,menurow+33,"Quit");
item=0;
menuitem=1;
menuon=1;}
break;
case 35:
if (gamestart==2 && menuon==0){
ctr=0;
menu=0;
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=100;
setcolor(12);
outtextxy(cx,60,"H");
cx+=textwidth("H");
cx=cx+1;
setcolor(15);
outtextxy(cx,60,"elp");
menucol=100;
menurow=63;
menucoll=239;
menuroww=106;
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;
menuon=1;menuitem=2;}
break;
case 77:
if (gamestart==1 && gameactive==1 && makemove==1){
restoreboxcursor();
if (bottombox==2){
if (pickcoin==3){boxctr--;}
boxcol=275;
firstbox();
bottombox=1;}
if (bottombox==1 && boxcol==335 && boxrow==330){
if (pickcoin==3){
boxctr--;}
boxcol=boxcol+30;
boxcoll=boxcol+20;
boxroww=boxrow+20;
rightbox=2;
bottombox=0;}
if (bottombox==1 && boxcol<335 && boxrow==430){
if (pickcoin==3){
boxctr--;}
boxcol=boxcol+30;
firstbox();}
if (topbox==1 && boxcol<335 && boxrow==105){
if (pickcoin==3){
boxctr++;}
boxcol=boxcol+30;
firstbox();}
if (topbox==1 && boxcol==335 && boxrow==205){
if (pickcoin==3){
boxctr++;}
boxcol=boxcol+30;
boxcoll=boxcol+20;
boxroww=boxrow+20;
topbox=2;}
if (leftbox==2){
if (pickcoin==3){
boxctr++;}
boxcol=275;
boxcoll=boxcol+25;
boxroww=boxrow+20;
topbox=1;
leftbox=0;}
if (rightbox==1 && boxcol<465){
if (pickcoin==3 && boxrow==235){
if (hotkey==0){
boxctr++;}
if (hotkey==1){boxctr--;}}
if (pickcoin==3 && boxrow==265){
boxctr++;}
if (pickcoin==3 && boxrow==295){
boxctr--;}
boxcol=boxcol+25;
secondbox();}
if (leftbox==1 && boxcol<250){
if (pickcoin==3 && boxrow==235){
boxctr++;}
if (pickcoin==3 && boxrow==265){
if (hotkey==1){
boxctr++;}
if (hotkey==0){boxctr--;}}
if (pickcoin==3 && boxrow==295){
boxctr--;}
boxcol=boxcol+25;
secondbox();}
if (pickcoin==2){
if (boxrow==330 && boxcol<335){
boxcol=boxcol+30;firstbox();}
if (boxcol<335 && boxrow==205){
boxcol=boxcol+30;firstbox();}}
saveboxcursor();
boxcursoron();
updatebox();
if (pickcoin==3){
sizecoin();
drawcoin();}
}
break;
case 75: /* Left arrow */
if (gamestart==1 && gameactive==1 && makemove==1){
restoreboxcursor();
if (rightbox==1 && boxcol>365){
if (pickcoin==3 && boxrow==235){
boxctr--;}
if (pickcoin==3 && boxrow==295){
boxctr++;}
if (boxrow==265 && pickcoin==3){
if (hotkey==1){
boxctr++;}
if (hotkey==0){boxctr--;}}
boxcol=boxcol-25;
secondbox();}
if (topbox==2){
if (pickcoin==3){
boxctr--;}
boxcol=335;
firstbox();
topbox=1;}
if (topbox==1 && boxcol==275 && boxrow==205){
if (pickcoin==3){
boxctr--;}
boxcol=250;
boxcoll=boxcol+20;
boxroww=boxrow+20;
leftbox=2;
topbox=0;}
if (topbox==1 && boxcol>275 && boxrow==105){
if (pickcoin==3){
boxctr--;}
boxcol=boxcol-30;
firstbox();}
if (bottombox==1 && boxcol==275 && boxrow==330){
if (pickcoin==3){
boxctr++;}
boxcol=250;
boxcoll=boxcol+20;
boxroww=boxrow+20;
bottombox=2;}
if (bottombox==1 && boxrow==430 && boxcol>275){
if (pickcoin==3){
boxctr++;}
boxcol=boxcol-30;
firstbox();}
if (leftbox==1 && boxcol>150){
if (pickcoin==3 && boxrow==295){
boxctr++;}
if (pickcoin==3 && boxrow==265){
if (hotkey==1){boxctr--;}
if (hotkey==0){
boxctr++;}}
if (pickcoin==3 && boxrow==235){
boxctr--;}
boxcol=boxcol-25;
secondbox();}
if (rightbox==2){
if (pickcoin==3){
boxctr++;}
boxcol=boxcol-30;
firstbox();
bottombox=1;
rightbox=0;}
if (pickcoin==2){
if (boxcol>275 && boxrow==205){
boxcol=boxcol-30;firstbox();}
if (boxcol>275 && boxrow==330){
boxcol=boxcol-30;firstbox();}}
saveboxcursor();
boxcursoron();
updatebox();
if (pickcoin==3){
sizecoin();
drawcoin();}
}
break;
case 72:
if (gamestart==1 && gameactive==1 && makemove==1){
restoreboxcursor();
if (rightbox==1 && boxrow==235 && boxcol==365){
if (pickcoin==3){
boxctr--;}
boxrow=boxrow-30;
boxcoll=boxcol+20;
boxroww=boxrow+20;
topbox=2;
rightbox=0;}
if (rightbox==1 && boxcol==465 && boxrow>235){
if (pickcoin==3){
boxctr--;}
boxrow=boxrow-30;
secondbox();}
if (rightbox==2){
boxrow=295;
if (pickcoin==3){
boxctr--;}
secondbox();
rightbox=1;}
if (leftbox==1 && boxrow==235 && boxcol==250){
if (pickcoin==3){
boxctr++;}
boxrow=boxrow-30;
boxcoll=boxcol+20;
boxroww=boxrow+20;
leftbox=2;}
if (leftbox==1 && boxrow>235 && boxcol==150){
if (pickcoin==3){
boxctr++;}
boxrow=boxrow-30;
secondbox();}
if (bottombox==2){
if (pickcoin==3){
boxctr++;}
leftbox=1;
boxrow=295;
secondbox();
bottombox=0;}
if (bottombox==1 && boxrow>330){
if (pickcoin==3 && boxcol==275){
boxctr++;}
if (boxcol==305 && pickcoin==3){
if (hotkey==0){
boxctr--;}
if (hotkey==1){
boxctr++;}}
if (pickcoin==3 && boxcol==335){
boxctr--;}
boxrow=boxrow-25;
firstbox();}
if (topbox==1 && boxrow>105){
if (pickcoin==3 && boxcol==275){
boxctr++;}
if (pickcoin==3 && boxcol==335){
boxctr--;}
if (boxcol==305 && pickcoin==3){
if (hotkey==0){
boxctr++;}
if (hotkey==1){
boxctr++;}}
boxrow=boxrow-25;
firstbox();}
if (pickcoin==2){
if (boxcol==365 && boxrow>235){
boxrow=boxrow-30;secondbox();}
if (boxrow>235 && boxcol==250){
boxrow=boxrow-30;secondbox();}}
saveboxcursor();
boxcursoron();
updatebox();
if (pickcoin==3){
sizecoin();
drawcoin();}
}
break;
case 80:
if (gamestart==1 && gameactive==1 && makemove==1){
restoreboxcursor();
if (rightbox==1 && boxrow==295 && boxcol==365){
if (pickcoin==3){
boxctr++;}
boxrow=330;
boxcoll=boxcol+20;
boxroww=boxrow+20;
rightbox=2;}
if (rightbox==1 && boxcol==465 && boxrow<295){
if (pickcoin==3){
boxctr++;}
boxrow=boxrow+30;
secondbox();}
if (topbox==2){
if (pickcoin==3){
boxctr++;}
boxrow=235;
secondbox();
rightbox=1;
topbox=0;}
if (leftbox==2){
if (pickcoin==3){
boxctr--;}
boxrow=boxrow+30;
secondbox();
leftbox=1;}
if (leftbox==1 && boxrow==295 && boxcol==250){
if (pickcoin==3){
boxctr--;}
boxrow=330;
boxcoll=boxcol+20;
boxroww=boxrow+20;
bottombox=2;
leftbox=0;}
if (leftbox==1 && boxrow<295 && boxcol==150){
if (pickcoin==3){
boxctr--;}
boxrow=boxrow+30;
secondbox();}
if (bottombox==2){
boxcol=250;
boxrow=330;
cursound();
boxcoll=boxcol+20;
boxroww=boxrow+20;}
if (bottombox==1 && boxrow<430){
if (pickcoin==3 && boxcol==335){
boxctr++;}
if (pickcoin==3 && boxcol==275){
boxctr--;}
if (boxcol==305 && pickcoin==3){
if (hotkey==0){
boxctr++;}
if (hotkey==1){
boxctr--;}}
boxrow=boxrow+25;
firstbox();}
if (topbox==1 && boxrow<205){
if (pickcoin==3 && boxcol==275){
boxctr--;}
if (pickcoin==3 && boxcol==335){
boxctr++;}
if (boxcol==305 && pickcoin==3){
if (hotkey==0){
boxctr--;}
if (hotkey==1){
boxctr++;}}
boxrow=boxrow+25;
firstbox();}
if (pickcoin==2){
if (boxrow<295 && boxcol==250){
boxrow=boxrow+30;secondbox();}
if (boxcol==365 && boxrow<295){
boxrow=boxrow+30;secondbox();}}
saveboxcursor();
boxcursoron();
updatebox();
if (pickcoin==3){
sizecoin();
drawcoin();}
}
if (gamestart==2){
if (menuon==1 && menuitem==1){
if (item==0){
threed_menu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(15);
outtextxy(menucol+60,menurow+13,"Start");}
if (item==1){
twod_menu();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(8);
outtextxy(menucol+60,menurow+13,"Start");
setlinestyle(SOLID_LINE,1,1);
threed_menuitem2();
setcolor(15);
outtextxy(menucol+60,menurow+33,"Quit");}
if (item==2){
twod_menuitem2();
setcolor(8);
outtextxy(menucol+60,menurow+33,"Quit");}
sound(20);
delay(75);
nosound();
item++;
if (item==3){
item=0;}
}
if (menuon==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;}
}
}
break;
case 13:
if (textcounter==2 && entered==1){
textcounter--;
strcpy(&newstr,&str[textcounter]);
outtextxy(cx,rx,&newstr);
sscanf(&newstr,"%d",&playerctr);
if (playerctr<2){
playernobox();
player=playerctr;
entered=3;
textcounter=4;}
if (playerctr>1){
tothrowdice=1;
gameactive=0;
gamestart=1;
entered=3;
textcounter=4;}
}
if (gamestart==1 && gameactive==1){
if (tothrowdice==3){
if (boxctr!=vy){cursound();messagebox();
settextstyle(GOTHIC_FONT,HORIZ_DIR,1);
setcolor(14);
cx=383;
cursound();
outtextxy(cx,35,"Moved squares not equal to");
outtextxy(cx,55,"Dice value ! Move cursor only");
outtextxy(cx,75,"dice value n times !");getch();messagebox();}
if (boxctr==vy){
restoreboxcursor();
if (home==1){
updatecoin();diceboxstart();tothrowdice=1;okplace=1;pickcoin=2;
if (vy!=6 && vy!=12 && vy!=1 && vy!=5){ct=4;}
if (esckey==1){ct=0;esckey=0;}
if (vy==6 || vy==12){ct=0;}
home=0;hotkey=0;okctr=0;}
if (okplace==0){
iscoininbox();
if (ok!=5 && ok!=-1){
whosecoin();
if (ok==4){
messagebox();
putcoininbox=0;
pickcoin=2;
updatebox();
sizecoin();
drawcoin();
startstatus=0;
hotkey=0;
sendcoinbacktobox();
hitbox();
delay(2000);
putcoininbox=1;
pickcoin=2;
updatebox();
ct=0;}
if (ok==0){
ct=5;ok=1;}}
if (ok==5 || ok==-1){
sizecoin();
drawcoin();
hotkey=0;
startstatus=0;
putcoininbox=1;
pickcoin=2;
updatebox();
if (esckey==1){ct=0;esckey=0;}
if (vy!=6 && vy!=12 && vy!=1 && vy!=5){ct=4;}
if (vy==6 || vy==12){ct=0;}}
/* End of okplace=0 loop */
}
diceboxstart();
ct=0;
tothrowdice=1;}
}
if (tothrowdice==0){
if (vy==1 || vy==5){
assessnumberofcoins();
if (coinsinbox==0){
placecoin();
saveboxcursor();
boxcursoron();
tothrowdice=2;
hotkey=0;
okk=0;
pickcoin=2;
makemove=1;}
if (coinsinbox<=6){
placecoin();
sizecoin();
drawcoin();
hotkey=0;
putcoininbox=0;
pickcoin=2;
jingle();
ct=0;
diceboxstart();
makemove=0;tothrowdice=1;}}}
if (tothrowdice==4){
gameactive=3;}
}
if (gamestart==2){
if (menuon==0 && menuitem==2 && item==1){
if (ctr==1){restorebox();
coll=640;
counter=10;
w=11;handle=open("REGUL.HLP",O_RDONLY | O_TEXT);
ok=0;
writehelp();ok=3;w=0;counter=0;howtoplay();ctr=0;}
if (ctr==2){
coll=640;
w=11;
counter=11;
handle=open("howto.HLP",O_RDONLY | O_TEXT);
ok=0;
writehelp();w=0;counter=0;howtoplay();ctr=0;}
if (ctr==3){restorebox();
ok=0;repaint();gamestart=2;item=0;ctr=0;menuon=0;menuflag=0;}
}
if (menuon==1 && menuitem==1){
restorebox();
if (item==0){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(15);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");menuon=0;menuitem=0;}
if (item==1){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(15);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");
playernobox();
player=0;
textcounter=1;}
if (item==2){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(15);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");
ix=1;
ok=0;
cleardevice();
coll=616;
color=0;
ic=5;
ok=20;
counter=0;
firstscreen();
menuon=0;
count=1;
ix=0;}
}
if (menuon==1 && menuitem==2){
restorebox();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=100;
setcolor(15);
outtextxy(cx,60,"H");
setcolor(12);
cx+=textwidth("H");
cx=cx+1;
outtextxy(cx,60,"elp");
if (item==0){
sound(200);
delay(25);
nosound();menuon=0;menuitem=0;}
if (item==1){
counter=0;
ct=access("regul.hlp",0);
if (ct!=0){counter=-1;ctr=3;}
if (ct==0){
w=0;
counter=0;
howtoplay();ctr=0;menuon=0;}
}
if (item==2){
ct=access("howto.hlp",0);if (ct!=0){counter=-1;ctr=3;}
if (ct==0){
w=0;
counter=1;
ct=access("about.hlp",0);if (ct!=0){counter=-1;ctr=3;}
about();item=4;}
}
if (counter==-1){messagebox();cursound();cx=messageboxc+10;outtextxy(cx,35,"Help file(s) missing ! Please");
outtextxy(cx,55,"contact the developer !");getch();
item=4;}
if (item==4){
counter=0;
repaint();gamestart=2;item=0;}
menuon=0;}
}
if (gamestart==1 && gameactive!=1){
bgcolor=0;
incolor=15;
linecolor=12;
cleardevice();
board();
ix=1;
cursorctr=1;
item=0;
menuon=0;
menuflag=0;
makemove=2;
menuon=0;
gameactive=1;}
break;
case 27:
if (gamestart==1 && gameactive==1){
menuon=0;
gameactive=3;}
if (gamestart==2){
if (player==0 && entered==1){
cursound();
menuitem=0;
item=0;
gameactive=3;gamestart=3;entered=0;menuon=0;}
if (menuon==2){
restorebox();
setcolor(7);
settextstyle(DEFAULT_FONT,VERT_DIR,1);
settextjustify(0,1);
outtextxy(18,11,"0");
entered=0;
menuon=0;
menu=0;}
if (menuon==1 && menuitem==1){
restorebox();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=10;
setcolor(15);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");
menuon=0;
menuitem=0;
item=0;}
if (menuon==1 && menuitem==2){
restorebox();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
cx=100;
setcolor(15);
outtextxy(cx,60,"H");
setcolor(12);
cx+=textwidth("H");
cx=cx+1;
outtextxy(cx,60,"elp");}
menuon=0;
menuitem=0;
item=0;
}
if (gameactive==3){
gamestart=2;
repaint();
gamestart=2;
menuon=0;
gameactive=0;}
break;
default:
if (textcounter==1 && player==0){
entered=1;
setfillstyle(SOLID_FILL,1);
bar(cx+2,rx-3,cx+4,rx+8);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(15);
outtextxy(cx+2,rx+2,&key);
cx+=textwidth(&key);
setfillstyle(SOLID_FILL,5);
bar(cx+4,rx-3,cx+6,rx+8);
strcpy(&str[textcounter],&key);
textcounter++;}
break;
}
}
chmod("regul.hlp",S_IREAD);
chmod("howto.hlp",S_IREAD);
cleardevice();
closegraph();
return 0;
}
int screen(){
setfillstyle(SOLID_FILL,8);
bar(0,0,640,21);
setfillstyle(SOLID_FILL,12);
bar(1,1,25,20);
setfillstyle(SOLID_FILL,6);
bar(0,22,640,74);
settextstyle(DEFAULT_FONT,VERT_DIR,1);
settextjustify(0,1);
setcolor(7);
outtextxy(18,11,"0");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(15);
outtextxy(300,12,"GREYcells");
cx=10;
setcolor(15);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
outtextxy(cx,60,"G");
cx+=textwidth("G");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"ame");
cx=100;
setcolor(15);
outtextxy(cx,60,"H");
cx+=textwidth("H");
cx=cx+1;
setcolor(12);
outtextxy(cx,60,"elp");
setlinestyle(SOLID_LINE,1,1);
setcolor(15);
line(0,65,640,65);
return 1;}
int pickit(){
messagebox();
settextstyle(GOTHIC_FONT,HORIZ_DIR,1);
setcolor(14);
cx=380;
outtextxy(cx,35,"Move the cursor over your coin.");
outtextxy(cx,50,"Press to pick it.");
outtextxy(cx,65,"Move with the keys.");
outtextxy(cx,80,"Press to place it.");
return 1;}
int repaint(){
cleardevice();
gamestart=2;
counter=0;
bgcolor=15;
incolor=3;
linecolor=0;
screen();
board();
gamestart=2;
pagectr=0;
return 1;}
int board(){
setfillstyle(SOLID_FILL,bgcolor);
bar(0,75,640,480);
setfillstyle(SOLID_FILL,incolor); bar(275,100,365,450); setfillstyle(SOLID_FILL,incolor); bar(150,225,490,325); /* outline box */ setlinestyle(SOLID_LINE,1,1); setcolor(linecolor); line(275,100,275,450); line(365,100,365,450); line(275,100,365,100); line(275,450,365,450); /* centre box */ line(150,225,150,325); line(150,225,490,225); line(490,225,490,325); line(150,325,490,325);
/* top box lines */ setlinestyle(SOLID_LINE,1,1); setcolor(linecolor); line(335,100,335,225); line(305,100,305,225); /* top box squares */ line(275,125,365,125); line(275,150,365,150); line(275,175,365,175); /* Home box */ line(305,225,335,200); line(305,200,335,225); line(305,100,335,125); line(305,125,335,100); /* left box */ line(150,260,275,260); line(150,290,275,290); /* left box squares */ line(225,225,225,325); line(200,225,200,325); line(175,225,175,325); /* Home box */ line(150,290,175,260); line(150,260,175,290); line(275,260,250,290); line(275,290,250,260); /* right box */ line(365,260,490,260); line(365,290,490,290); /* right box squares */ line(415,225,415,325); line(440,225,440,325); line(465,225,465,325); /* Home box */ line(365,260,390,290); line(365,290,390,260); line(465,260,490,290); line(465,290,490,260); /* bottom box */ line(335,325,335,450); line(305,325,305,450); /* Bottom box squares */ line(275,375,365,375); line(275,400,365,400); line(275,425,365,425);
/* Home box */ line(335,325,305,350); line(335,350,305,325); line(335,450,305,425); line(335,425,305,450); /* 4 out squares */ line(250,200,250,350); line(250,350,390,350); line(250,200,390,200); line(390,200,390,350); /* 4 box cross lines */ line(250,225,275,200); line(275,225,250,200);
line(250,325,275,350); line(250,350,275,325);
line(365,350,390,325); line(365,325,390,350);
line(365,200,390,225); line(365,225,390,200); /* diagonal lines */ line(275,225,365,325); line(275,325,365,225); settextstyle(SMALL_FONT,HORIZ_DIR,1); setusercharsize(3,3,3,3); settextjustify(0,1); setcolor(10); outtextxy(300,90,"Player 2"); outtextxy(300,460,"Player 1"); settextstyle(SMALL_FONT,VERT_DIR,1); setusercharsize(3,3,3,3); settextjustify(0,1); outtextxy(495,275,"Player 3"); outtextxy(135,275,"Player 4");
if (gamestart==2){
/* Coin boxes*/
setfillstyle(SOLID_FILL,0);
bar(15,95,130,175);
setfillstyle(SOLID_FILL,8);
bar(15,95,130,110);
setfillstyle(SOLID_FILL,6);
bar(15,195,130,275);
setfillstyle(SOLID_FILL,7);
bar(15,195,130,210);
setfillstyle(SOLID_FILL,3);
bar(15,295,130,375);
setfillstyle(SOLID_FILL,11);
bar(15,295,130,310);
setfillstyle(SOLID_FILL,5);
bar(15,395,130,475);
setfillstyle(SOLID_FILL,13);
bar(15,395,130,410);
settextstyle(SMALL_FONT,HORIZ_DIR,1);
setusercharsize(2,1,1,1);
settextjustify(0,1);
setcolor(1);
outtextxy(21,102,"GREYcells");
outtextxy(21,202,"GREYcells");
outtextxy(21,302,"GREYcells");
outtextxy(21,402,"GREYcells");
circcolll=circcol+21;
circcoll=circcol+13;
fourcoins();
setfillstyle(SOLID_FILL,6);
bar(500,100,625,445);
setfillstyle(SOLID_FILL,14);
bar(501,120,510,425);
setfillstyle(SOLID_FILL,14);
bar(615,120,624,425);
setfillstyle(SOLID_FILL,6);
bar(510,120,615,425);
settextstyle(GOTHIC_FONT,HORIZ_DIR,3);
setcolor(2);
outtextxy(512,125,"GREYcells");
settextstyle(GOTHIC_FONT,HORIZ_DIR,3);
setusercharsize(1,1,14,1);
setcolor(2);
outtextxy(530,200,"Ludo");
settextstyle(GOTHIC_FONT,HORIZ_DIR,3);
setcolor(4);
outtextxy(555,175,"A");
outtextxy(540,210,"game");
outtextxy(555,245,"of");
outtextxy(545,280,"dice");
settextstyle(SMALL_FONT,HORIZ_DIR,1);
setusercharsize(3,3,3,3);
setcolor(1);
outtextxy(530,300,"for 4 players");
setcolor(3);
outtextxy(540,310,"Designed");
outtextxy(560,320,"&");
outtextxy(535,330,"developed");
outtextxy(550,340,"by");
outtextxy(518,350,"J.V.Ravichandran");
setcolor(8);
outtextxy(511,360,"(c) Semantix");
outtextxy(511,370,"computers,");
outtextxy(511,380,"New Delhi.");
ctr=0;
drawarrow();
}
if (gamestart==1){
/* Coin boxes*/
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
score1=0;
score2=0;
score3=0;
score4=0;
sprintf(&newstr,"%d",score1);
if (playerctr==2){
player=1;
while (player
settextstyle(SMALL_FONT,HORIZ_DIR,1);
setusercharsize(2,1,1,1);
settextjustify(0,1);
setcolor(9);
outtextxy(21,102,"Player 1");
outtextxy(21,202,"Player 2");
setfillstyle(SOLID_FILL,1);
bar(25,0,125,45);
setfillstyle(SOLID_FILL,4);
bar(25,46,125,75);
setcolor(9);
setlinestyle(SOLID_LINE,1,1);
line(25,0,125,0);
line(125,0,125,45);
setcolor(12);
line(25,46,125,46);
line(125,46,125,75);
settextstyle(SMALL_FONT,HORIZ_DIR,3);
setusercharsize(1,2,3,3);
setcolor(15);
outtextxy(40,5,"Player 1");
outtextxy(90,5,"Player 2");
radius=7;
ctr=1;
col=50;
row=30;
while (ctr<3){
setcolor(0);
circle(col,row,radius+3);
setfillstyle(SOLID_FILL,0);
floodfill(col,row,0);
setcolor(5);
setfillstyle(SOLID_FILL,5);
circle(col,row,radius+1);
floodfill(col,row,5);
writescore();
col=col+50;
ctr++;}
}
if (playerctr==3){
player=1;
while (player
/* To blank out the 4th box */
setfillstyle(SOLID_FILL,0);
bar(15,395,130,475);
setfillstyle(SOLID_FILL,1);
bar(25,0,175,45);
setfillstyle(SOLID_FILL,4);
bar(25,45,175,75);
setcolor(9);
setlinestyle(SOLID_LINE,1,1);
line(25,0,175,0);
line(175,0,175,75);
settextstyle(SMALL_FONT,HORIZ_DIR,1);
setusercharsize(2,1,1,1);
settextjustify(0,1);
setcolor(9);
outtextxy(21,102,"Player 1");
outtextxy(21,202,"Player 2");
outtextxy(21,302,"Player 3");
settextstyle(SMALL_FONT,HORIZ_DIR,3);
setusercharsize(1,2,3,3);
setcolor(15);
outtextxy(40,5,"Player 1");
outtextxy(90,5,"Player 2");
outtextxy(140,5,"Player 3");
radius=7;
ctr=1;
col=50;
row=30;
while (ctr<4){
setcolor(0);
circle(col,row,radius+3);
setfillstyle(SOLID_FILL,0);
floodfill(col,row,0);
setcolor(5);
setfillstyle(SOLID_FILL,5);
circle(col,row,radius+1);
floodfill(col,row,5);
writescore();
col=col+50;
ctr++;}
}
if (playerctr==4){
player=1;
while (player
setcolor(9);
setlinestyle(SOLID_LINE,1,1);
line(25,0,225,0);
line(225,0,225,45);
setcolor(0);
line(25,44,224,44);
setcolor(12);
line(25,45,225,45);
line(225,45,225,75);
settextstyle(SMALL_FONT,HORIZ_DIR,1);
setusercharsize(2,1,1,1);
settextjustify(0,1);
setcolor(9);
outtextxy(21,102,"Player 1");
outtextxy(21,202,"Player 2");
outtextxy(21,302,"Player 3");
outtextxy(21,402,"Player 4");
settextstyle(SMALL_FONT,HORIZ_DIR,3);
setusercharsize(1,2,3,3);
setcolor(15);
outtextxy(40,5,"Player 1");
outtextxy(90,5,"Player 2");
outtextxy(140,5,"Player 3");
outtextxy(190,5,"Player 4");
radius=7;
ctr=1;
col=50;
row=30;
while (ctr<5){
setcolor(0);
circle(col,row,radius+3);
setfillstyle(SOLID_FILL,0);
floodfill(col,row,0);
setcolor(4);
setfillstyle(SOLID_FILL,4);
circle(col,row,radius+1);
floodfill(col,row,4);
writescore();
col=col+50;
ctr++;}
}
/* coins */
coin=1;
ctr=0;
circrow=120;
circcol=25;
circcolll=circcol+21;
circcoll=circcol+13;
coincolor=8;
if (playerctr==4){
fourcoins();
cursorctr=1;
while (cursorctr<9){
strcpy(&player1inbox[cursorctr],"0");
strcpy(&player2inbox[cursorctr],"0");
strcpy(&player3inbox[cursorctr],"0");
strcpy(&player4inbox[cursorctr],"0");
cursorctr++;}
cursorctr=1;}
if (playerctr==2){
twocoins();
cursorctr=1;
while (cursorctr<9){
strcpy(&player1inbox[cursorctr],"0");
strcpy(&player2inbox[cursorctr],"0");
cursorctr++;}
cursorctr=1;}
if (playerctr==3){
threecoins();
cursorctr=1;
while (cursorctr<9){
strcpy(&player1inbox[cursorctr],"0");
strcpy(&player2inbox[cursorctr],"0");
strcpy(&player3inbox[cursorctr],"0");
cursorctr++;}
cursorctr=1;}
setfillstyle(SOLID_FILL,4);
bar(505,250,630,300);
setlinestyle(SOLID_LINE,1,1);
setcolor(12);
line(505,250,630,250);
line(630,250,630,300);
/* Coin counter box */
setfillstyle(SOLID_FILL,6);
bar(495,175,630,225);
bar(555,285,580,295);
/* Move counter Box */
bar(260,0,365,55);
setlinestyle(SOLID_LINE,1,1);
setcolor(7);
line(495,175,630,175);
line(630,175,630,225);
line(260,0,365,0);
line(365,0,365,55);
settextstyle(GOTHIC_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(14);
outtextxy(510,260,"Coins in Box");
outtextxy(500,185,"Whose coin(s) ?");
outtextxy(265,6,"Move count");
setcolor(10);
outtextxy(520,210,"Player");
cursorctr=0;
sprintf(&newstr,"%d",cursorctr);
settextstyle(GOTHIC_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(14);
outtextxy(300,35,&newstr);
sprintf(&playercoin,"%d",player);
sprintf(&coins,"%d",cursorctr);
messageboxc=200;
messageboxr=225;
messageboxcc=400;
messageboxrr=280;
startstatus=0;
savebox();
throwdicebox();
player1hit=0;
player2hit=0;
player3hit=0;
player4hit=0;
player1coins=6;
player2coins=6;
player3coins=6;
player4coins=6;
player1wincoin=6;
player2wincoin=6;
player3wincoin=6;
player4wincoin=6;
player=1;
hotkey=0;
hotctr=0;
hitctr=0;
col=50;
cursorctr=1;
while (cursorctr<65){
strcpy(&box[cursorctr],"0");
strcpy(&whosecoininbox[cursorctr],"0");
strcpy(&hotcoin[cursorctr],"0");
cursorctr++;}
cursorctr=1;
coininbox=0;
settextstyle(SMALL_FONT,VERT_DIR,1);
setusercharsize(3,3,3,3);
settextjustify(0,1);
setcolor(10);
outtextxy(10,60,"Score");
esckey=0;
specialcoin1=0;
specialcoin2=0;
specialcoin3=0;
specialcoin4=0;
yourmovebox();
menuon=0;
menuflag=0;
menuitem=0;
pagectr=0;
boxctr=0;
home=0;
entered=0;
textcounter=0;
h=7;
i=7;
srand(h);
number=3;
soundon=1;
makemove=2;}
/* DICE 1 */
setlinestyle(SOLID_LINE,1,1);
setcolor(15);
line(455,400,455,440);
line(490,400,490,440);
line(455,400,490,400);
line(455,440,490,440);
line(455,400,460,390);
line(490,400,495,390);
line(460,390,495,390);
line(495,390,495,425);
line(490,440,495,425);
/* DICE 2*/
line(515,400,515,440);
line(550,400,550,440);
line(515,400,550,400);
line(515,440,550,440);
line(515,400,520,390);
line(550,400,555,390);
line(520,390,555,390);
line(555,390,555,425);
line(550,440,555,425);
return 1;}
int diceboxstart(){
messageboxc=200;
messageboxr=225;
messageboxcc=400;
messageboxrr=280;
savebox();
throwdicebox();
tothrowdice=1;
makemove=2;
if (ct==4){
player++;
if (player>playerctr){player=1;}}
/* Blank previous dice value */
setfillstyle(SOLID_FILL,0);
bar(460,405,485,435);
bar(520,405,545,435);
yourmovebox();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(6);
outtextxy(580,215,&playercoin);
setcolor(6);
outtextxy(565,290,&coins);
return;}
int throwdicebox(){
setfillstyle(SOLID_FILL,14);
bar(200,225,400,280);
setfillstyle(SOLID_FILL,10);
bar(201,225,399,240);
setfillstyle(SOLID_FILL,0);
bar(250,250,350,275);
setfillstyle(SOLID_FILL,7);
bar(252,252,348,273);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(15);
outtextxy(270,234,"GREYcells");
setcolor(0);
outtextxy(263,263,"Throw dice");
setlinestyle(SOLID_LINE,1,1);
setcolor(15);
line(252,252,252,273);
line(252,252,348,252);
setcolor(8);
line(348,252,348,273);
line(252,273,348,273);
return 1;}
int throwdice(){
if (throw==0){
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(15);
outtextxy(263,263,"Throw dice");
setlinestyle(SOLID_LINE,1,1);
setcolor(0);
line(257,256,343,256);
line(343,256,343,270);
setcolor(15);
line(257,256,257,270);
line(257,270,343,270);
}
/* Display dice value */
setfillstyle(SOLID_FILL,14);
bar(500,325,630,370);
setfillstyle(SOLID_FILL,15);
bar(500,325,630,340);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(10);
outtextxy(510,350,"Dice value -");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(12);
outtextxy(533,332,"GREYcells");
dice1=0;
vy=0;
sprintf(&newstr,"%d",vy);
h=7;
i=7;
vy=random(h);
dice1=vy;
ic=1;
if (throw==0){
/* Dice 1 number */
if (vy==1){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(473,420,2);
throw=1;}
if (vy==2){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(463,420,2);
circle(482,420,2);
throw=1;}
if (vy==3){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(463,410,2);
circle(473,420,2);
circle(483,430,2);
throw=1;
}
if (vy==4){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(463,410,2);
circle(482,410,2);
circle(463,430,2);
circle(482,430,2);
throw=1;
}
if (vy==5){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(463,410,2);
circle(482,410,2);
circle(463,430,2);
circle(482,430,2);
circle(473,420,2);
throw=1;
}
if (vy==6){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(463,410,2);
circle(482,410,2);
circle(463,430,2);
circle(482,430,2);
circle(463,420,2);
circle(482,420,2);
throw=1;
}
}
vy=random(i);
dice2=vy;
if (throw==1){
if (vy==1){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(533,420,2);
}
if (vy==2){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(523,420,2);
circle(543,420,2);
}
if (vy==3){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(523,410,2);
circle(533,420,2);
circle(543,430,2);
}
if (vy==4){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(523,410,2);
circle(543,410,2);
circle(523,430,2);
circle(543,430,2);
}
if (vy==5){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(523,410,2);
circle(543,410,2);
circle(523,430,2);
circle(543,430,2);
circle(533,420,2);
}
if (vy==6){
setlinestyle(SOLID_LINE,1,3);
setcolor(15);
circle(523,410,2);
circle(543,410,2);
circle(523,430,2);
circle(543,430,2);
circle(523,420,2);
circle(543,420,2);
}
}
setcolor(14);
outtextxy(610,350,&newstr);
vy=dice1+dice2;
sprintf(&newstr,"%d",vy);
setcolor(12);
outtextxy(610,350,&newstr);
jingle();
messageboxc=200;
messageboxr=225;
restorebox();
if (vy==1 || vy==5){
messagebox();
settextstyle(GOTHIC_FONT,HORIZ_DIR,1);
setcolor(14);
cx=383;
outtextxy(cx,35,"Press to play a new");
outtextxy(cx,50,"coin or to continue");
outtextxy(cx,65,"with an existing coin on board !");}
return 1;}
GREYcells Ludo
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);}
No comments:
Post a Comment