View Ravichandran J.V.'s profile on LinkedIn RJV 's Blog: Ludo Tweet @ravichandranjv

Translate

Ludo

GREYcells Ludo
/************************************************************************/
/* 		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;}

No comments: