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

Translate

TicTacToe - I

GREYcells Tic-Tac-Toe
int threed_menu(){
	setlinestyle(SOLID_LINE,1,1);
	setcolor(15);
	line(menucoll-6,menurow+8,menucoll-6,menurow+17);
	line(menucol+7,menurow+17,menucoll-6,menurow+17);
	setcolor(0);
	line(menucol+7,menurow+7,menucoll-7,menurow+7);
	line(menucol+7,menurow+7,menucol+7,menurow+17);
return 1;}
int twod_menu(){
	setlinestyle(SOLID_LINE,1,1);
	setcolor(7);
	line(menucol+7,menurow+7,menucoll-7,menurow+7);
	line(menucol+7,menurow+7,menucol+7,menurow+17);
	setcolor(7);
	line(menucoll-6,menurow+8,menucoll-6,menurow+17);
	line(menucol+7,menurow+17,menucoll-6,menurow+17);
return 1;}
int threed_menuitem2(){
	setlinestyle(SOLID_LINE,1,1);
	setcolor(15);
	line(menucol+7,menurow+27,menucoll-8,menurow+27);
	line(menucol+7,menurow+27,menucol+7,menurow+39);
	setlinestyle(SOLID_LINE,1,1);
	setcolor(0);
	line(menucoll-6,menurow+27,menucoll-6,menurow+39);
	line(menucol+7,menurow+39,menucoll-6,menurow+39);
return 1;}
int twod_menuitem2(){
	setlinestyle(SOLID_LINE,1,1);
	setcolor(7);
	line(menucol+7,menurow+27,menucoll-8,menurow+27);
	line(menucol+7,menurow+27,menucol+7,menurow+39);
	setlinestyle(SOLID_LINE,1,1);
	setcolor(7);
	line(menucoll-6,menurow+27,menucoll-6,menurow+39);
	line(menucol+7,menurow+39,menucoll-6,menurow+39);
return 1;}
int howtouse(){
	messageboxc=125;
	messageboxr=125;
	messageboxcc=515;
	messageboxrr=320;
	midx=300;
	savebox();
	errorscreen();
	settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
	setusercharsize(1,3,1,1);
	settextjustify(0,1);
	setcolor(12);
	outtextxy(messageboxc+5,messageboxr+5,"Help");
	settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
	settextjustify(0,1);			
	setcolor(12);
	outtextxy(messageboxc+5,160,"How to use GREYcells Tic-tac-toe");
	setcolor(7);
	outtextxy(messageboxc+5,185,"Arrow keys to navigate between the menus and");
	outtextxy(messageboxc+5,200,"the boxes.");
	outtextxy(messageboxc+5,225,"After a game is over, select START from the");
	outtextxy(messageboxc+5,240,"menu to go to the next game.");
	outtextxy(messageboxc+5,260,"To select a menu, depress ALT + the colored");
	outtextxy(messageboxc+5,275,"letter. To select the oval menu, depress");
	outtextxy(messageboxc+5,290,"ALT + Zero.");
	getch();
	restorebox();
return 1;}
int about(){
	messageboxc=125;
	messageboxr=125;
	messageboxcc=515;
	messageboxrr=300;
	midx=300;
	savebox();
	errorscreen();
	settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
	setusercharsize(1,3,1,1);
	settextjustify(0,1);
	setcolor(12);
	outtextxy(messageboxc+5,messageboxr+5,"Help");
	settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
	setusercharsize(3,1,3,1);
	settextjustify(0,1);			
	setcolor(12);
	outtextxy(messageboxc+5,155,"About GREYcells Tic-tac-toe");
	setcolor(7);
	outtextxy(messageboxc+5,185,"A game developed by J.V.Ravichandran, Software");
	outtextxy(messageboxc+5,200,"architect/Software consultant/Proprietor.");
	outtextxy(messageboxc+5,230,"Semantix Computers, B-10, Triveni Apartments,");
	outtextxy(messageboxc+5,245,"Near 'H' Block, Vikas puri, New Delhi-110 018.");
	getch();
	restorebox();
return 1;}
int shareware(){
	messageboxc=125;
	messageboxr=125;
	messageboxcc=525;
	messageboxrr=325;
	savebox();
	if (soundon==1){
		sound(275);
		delay(150);
		sound(225);
		delay(250);
		sound(375);
		delay(250);
		nosound();}
	midx=300;
	errorscreen();
	settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
	setusercharsize(1,3,1,1);
	settextjustify(0,1);
	setcolor(12);
	outtextxy(messageboxc+5,messageboxr+5,"Alert");
	setusercharsize(3,1,3,1);
	settextjustify(0,1);			
	setcolor(12);
	outtextxy(messageboxc+5,155,"GREYcells Tic-tac-toe");
	setcolor(12);
	outtextxy(messageboxc+5,messageboxr+60,"A game developed by J.V.Ravichandran, Software");
	outtextxy(messageboxc+5,messageboxr+75,"architect/Software consultant/Proprietor.");
	settextstyle(SMALL_FONT,HORIZ_DIR,3);
	settextjustify(0,1);
	setusercharsize(2,2,3,3);
	setcolor(0);
	outtextxy(messageboxc+5,messageboxr+95,"This is a shareware version. To increase the no. of levels in the");	
	outtextxy(messageboxc+5,messageboxr+110,"game, please send Rs.100.00 only or TEN dollars for more levels.");
	outtextxy(messageboxc+5,messageboxr+125,"Cheque to be drawn in favor of Semantix Computers, New  Delhi,");
	outtextxy(messageboxc+5,messageboxr+140,"and mail it to");
	setcolor(10);
	outtextxy(messageboxc+5,messageboxr+155,"Mr. J.V.Ravichandran, Proprietor, Semantix Computers,");
	outtextxy(messageboxc+5,messageboxr+170,"B-10, Triveni Apartments, Vikas puri, New Delhi-110 018.");
	outtextxy(messageboxc+5,messageboxr+185,"");
	getch();
	restorebox();
return 1;}
int scrollplayerhelp(){
	settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
	settextjustify(0,1);			
	setcolor(0);
	outtextxy(messageboxc+5,messageboxr+40,"Use the arrow keys to scroll through the menu");
	outtextxy(messageboxc+5,messageboxr+60,"options. Press <Enter> on the highlighted");
	outtextxy(messageboxc+5,messageboxr+80,"option to select.");
return 1;}
int playerletterhelp(){
	settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
	settextjustify(0,1);			
	setcolor(0);
	outtextxy(messageboxc+5,messageboxr+40,"Enter capital letters X or O for the first");
	outtextxy(messageboxc+5,messageboxr+60,"player. The letter of the opponent will be");
	outtextxy(messageboxc+5,messageboxr+80,"automatically entered. Press <Enter> after");
	outtextxy(messageboxc+5,messageboxr+100,"the auto selection of the letter for the");
	outtextxy(messageboxc+5,messageboxr+120,"second player is displayed.");
return 1;}
int playernamehelp(){
	settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
	settextjustify(0,1);			
	setcolor(0);
	outtextxy(messageboxc+5,messageboxr+40,"A name can contain a maximum of 10 characters.");
	outtextxy(messageboxc+5,messageboxr+60,"Press <Enter> to register the input value.");
return 1;}
int firstscreen(){
setfillstyle(SOLID_FILL,12);
bar(100,100,540,380);
setlinestyle(SOLID_LINE,1,1);
setcolor(0);
line(103,103,103,377);
line(103,103,537,103);
line(537,103,537,377);
line(103,377,537,377);
setcolor(15);
line(300,180,300,290);
line(340,180,340,290);
line(265,210,375,210);
line(265,260,375,260);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
settextjustify(0,1);
sound(25);
delay(50);
nosound();
setcolor(15);
outtextxy(315,233,"X");
delay(500);
sound(35);
delay(50);
nosound();
setcolor(0);
outtextxy(275,190,"O");
delay(500);
sound(25);
delay(50);
nosound();
setcolor(15);
outtextxy(355,275,"X");
delay(500);
sound(35);
delay(50);
nosound();
setcolor(0);
outtextxy(275,233,"O");
delay(500);
sound(25);
delay(50);
nosound();
setcolor(15);
outtextxy(275,275,"X");
delay(500);
sound(35);
delay(50);
nosound();
setcolor(0);
outtextxy(315,190,"O");
delay(500);
sound(25);
delay(50);
nosound();
setcolor(15);
outtextxy(315,275,"X");
soundctr=0;
while (soundctr<10){
sound(250);
delay(50);
nosound();
sound(350);
delay(50);
nosound();
soundctr++;
}
settextstyle(DEFAULT_FONT,HORIZ_DIR,3);
settextjustify(1,1);
setcolor(15);
outtextxy(325,135,"GREYcells");
setcolor(0);
outtextxy(325,165,"Tic-tac-toe");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(1,1);
setcolor(9);
outtextxy(325,190,"A game developed by J.V.Ravichandran");
setcolor(11);
outtextxy(325,215,"(c) Semantix computers, New Delhi, 1997.");
settextjustify(0,1);
setcolor(0);
outtextxy(110,230,"GREYcells Tic-tac-toe is a shareware software and");
outtextxy(110,245,"you are free to circulate it in your circle of");
outtextxy(110,260,"friends or colleagues. If the software is found");
outtextxy(110,275,"interesting, then register the software with the");
outtextxy(110,290,"developer which will enable you to access higher");
outtextxy(110,305,"levels of interaction between the human player and");
outtextxy(110,320,"the computer. A registration fee of Rs.100.00 only");
outtextxy(110,335,"or TEN dollars, by cheque drawn in favour of Semantix");
outtextxy(110,350,"Computers, New Delhi, will entitle you to access");
outtextxy(110,365,"these enhanced features.");
getch();
cleardevice();
return 1;}
int drawmenuscreen(){
cx=225;
rx=50;
ctr=0;
setfillstyle(SOLID_FILL,8);
bar(0,0,640,480);
setfillstyle(SOLID_FILL,0);
bar(1,1,639,21);
setfillstyle(SOLID_FILL,8);
bar(1,1,30,20);
setlinestyle(SOLID_LINE,1,1);
setcolor(0);
line(4,21,4,480);
line(636,21,636,480);
line(0,475,640,475);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(15);
outtextxy(300,13,"GREYcells");
setcolor(7);
settextstyle(DEFAULT_FONT,VERT_DIR,1);
outtextxy(20,10,"0");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
setcolor(incolor);
outtextxy(10,35,"Press <F1> for help");
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
settextjustify(0,1);
setcolor(15);
outtextxy(100,50,"Player 1:");
outtextxy(100,75,"Player 2:");
outtextxy(150,150,"Human");
outtextxy(150,200,"Computer");
outtextxy(100,250,"Select letter for player 1 -");
outtextxy(100,275,"Select letter for player 2 -");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
settextjustify(0,1);
outtextxy(100,325,"Name of player 1 -");
outtextxy(100,350,"Name of player 2 -");
setfillstyle(SOLID_FILL,15);
bar(145,135,300,165);
setcolor(0);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
settextjustify(0,1);
outtextxy(150,150,"Human");
ctr=1;
ir=0;
player=1;
once=0;
return 1;}
int alertformoney(){
			messageboxc=25;
			messageboxr=100;
			messageboxcc=615;
			messageboxrr=216;
			midx=300;
			errorscreen();
			settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
			setusercharsize(1,3,1,1);
			settextjustify(0,1);
			setcolor(12);
			outtextxy(messageboxc+5,messageboxr+5,"Alert");
			settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
			setusercharsize(1,3,1,3);
			setcolor(0);
			outtextxy(30,125,"This is a shareware software. To access all the features in the software,");
			outtextxy(30,140,"please send a cheque of Rs.100.00 only or TEN dollars drawn in favor of");
			outtextxy(30,155,"Semantix computers, New Delhi and address it to,");
			setcolor(12);
			cx=30;
			outtextxy(cx,170,"J.V.Ravichandran,");
			cx+=textwidth("J.V.Ravichandran,");
			cx++;
			setcolor(14);
			outtextxy(cx,170,"Proprietor/Software Architect/Consultant.");
			setcolor(10);
			outtextxy(30,185,"B-10, Triveni Apartments, Vikas puri, New Delhi - 110 018.");
return 1;}

 

int errorscreen(){
		setfillstyle(SOLID_FILL,9);
		bar(messageboxc,messageboxr,messageboxcc,messageboxrr);
		setfillstyle(SOLID_FILL,7);
		bar(messageboxc+1,messageboxr+1,messageboxcc-1,messageboxr+16);
		setfillstyle(SOLID_FILL,0);
		bar(messageboxc+2,messageboxr+2,messageboxc+45,messageboxr+15);
		setlinestyle(SOLID_LINE,1,1);
		setcolor(15);
		line(messageboxc+45,messageboxr,messageboxcc,messageboxr);
		line(messageboxc+45,messageboxr,messageboxcc,messageboxr);
		setfillstyle(SOLID_FILL,7);
		bar(messageboxc+1,messageboxrr-16,messageboxcc-65,messageboxrr-1);
		setcolor(15);
		line(messageboxc,messageboxrr-16,messageboxcc-65,messageboxrr-16);
		line(messageboxc,messageboxrr-16,messageboxc,messageboxrr-15);
		setfillstyle(SOLID_FILL,0);
		bar(messageboxcc-63,messageboxrr-16,messageboxcc-1,messageboxrr-1);
		settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
		setcolor(15);
		setusercharsize(1,3,1,1);
		settextjustify(0,1);
		outtextxy(midx,messageboxr+5,"GREYcells");
		setcolor(13);
		outtextxy(messageboxc+5,messageboxrr-11,"Press any key to continue...");
return 1;}
int savebox(){
	size=imagesize(messageboxc,messageboxr,messageboxcc,messageboxrr);
	sbox=malloc(size);
	getimage(messageboxc,messageboxr,messageboxcc,messageboxrr,sbox);
return 1;}
int restorebox(){
	putimage(messageboxc,messageboxr,sbox, COPY_PUT);
	free(sbox);
return 1;}
int writeforcomputer(){
if (player==2){
if (playertype2==1 || playertype2==2){
strcpy(&newstr,"1");}}
if (player==1 && playertype1==1){
strcpy(&newstr,"0");}
if (boxc==210 && boxr==125){
strcpy(&box[1],&newstr);}
if (boxc==210 && boxr==210){
strcpy(&box[2],&newstr);}
if (boxc==210 && boxr==295){
strcpy(&box[3],&newstr);}
if (boxc==310 && boxr==125){
strcpy(&box[4],&newstr);}
if (boxc==310 && boxr==210){
strcpy(&box[5],&newstr);}
if (boxc==310 && boxr==295){
strcpy(&box[6],&newstr);}
if (boxc==410 && boxr==125){
strcpy(&box[7],&newstr);}
if (boxc==410 && boxr==210){
strcpy(&box[8],&newstr);}
if (boxc==410 && boxr==295){
strcpy(&box[9],&newstr);}
return 1;}
int checkcomputerwin(){
/* offensive moves for computer*/
if (oxx1==1 && oxx2==1 && oxx3==1 && once==0){
once=2;}
if (oxx1==1 && oxx4==1 && oxx7==1 && once==0){
once=2;}
if (oxx2==1 && oxx5==1 && oxx8==1 && once==0){
once=2;}
if (oxx3==1 && oxx6==1 && oxx9==1 && once==0){
once=2;}
if (oxx4==1 && oxx5==1 && oxx6==1 && once==0){
once=2;}
if (oxx7==1 && oxx8==1 && oxx9==1 && once==0){
once=2;}
if (oxx1==1 && oxx5==1 && oxx9==1 && once==0){
once=2;}
if (oxx3==1 && oxx5==1 && oxx7==1 && once==0){
once=2;}
return (once);}

No comments: