ilgili | FORUM

Bilişim Dünyası => Bilgisayar ve İnternet => Programlama => Konuyu başlatan: Forum - 11 Kasım 2007, 12:53:29

Başlık: C++ `da Iki Kisilik Tas Oyunu
Gönderen: Forum - 11 Kasım 2007, 12:53:29
C++ Da Arkadasiniz Ile Oynayabileceginiz.. Tas Oyunu
 
 
Alıntı:
#include<iostream.h>
#include<windows.h>
#include<stdlib.h>
#include<iomanip.h>
#include <conio.h>
 
#define YES 1
#define NO 0
#define PLAYER1 1
#define PLAYER2 2
#define ENTER 13
#define SPACE 32
#define BACK 8
#define ESC 0x1b
#define UP 0x48
#define DOWN 0x50
#define LEFT 0x4b
#define RIGHT 0x4d
#define F1 0x3b
#define F2 0x3c
#define F3 0x3d
#define F4 0x3e
#define F5 0x3f
#define F6 0x40
#define F7 0x41
#define F8 0x42
#define F9 0x43
#define F10 0x44
 
enum Colors
{
BLACK,
BLUE,
GREEN,
TEAL,
MAROON,
PURPLE,
MUSTARD,
LIGHT_GRAY,
GRAY,
BRIGHT_BLUE,
LIME,
LIGHT_BLUE,
RED,
FUCHSIA,
YELLOW,
WHITE
};
void setcolor(int, int);
void resetboard(char[][7]);
void resetbool(bool [][7], bool [][7], bool [][7]);
void viewchar();
void displayboard(char[][7], bool[][7], bool[][7], char[], const int, const int);
int getboard(char[][7], bool [][7], bool[][7], bool[][7], char[], const int, const int);
void falling(char[][7], bool[][7], bool[][7], bool[][7], int, char[], int, const int);
int win(bool [][7], bool [][7]);
void winningboard(char[][7], bool[][7], bool[][7]);
 
main()
{
setcolor(BLACK, WHITE);
system("cls");
 
//size of the name arrays
const int size=50;
//BOOLEAN DOUBLE SUBSCRIPTED ARRAY
//keeps track of reds positions on the board
bool redboolboard[6][7];
//keeps track of blues positions on the board
bool blueboolboard[6][7];
//an array of the star charcters
bool cboard[6][7];
 
//CHARCTER ARRAYS
//player one's name
char playerone[size]={'\0'};
//player two's name
char playertwo[size]={'\0'};
//a string of star charcters
char board[6][7];
 
//BOOLEAN VARIABLES
//to stop a for loop
bool stop;
//to quit the game
bool quit;
 
//INTERGERS
//the position of the piece that will fall
int arrowpos=0;
//the value getboard returns
int number;
//in the for loop to convert names to uppercase
int d;
//to see if you want to continue
int yesorno;
//in the for loop to determine the pieces position
int x;
 
cout<<"Player one enter your name:"<<endl;
cin.getline(playerone, size);
system("cls");
cout<<"Player two enter your name:"<<endl;
cin.getline(playertwo, size);
system("cls");
while (1)
{
system("cls");
quit=false;
arrowpos=0;
resetboard(board);
resetbool(blueboolboard, redboolboard, cboard);
cout<<"PRESS ESCAPE AT ANY TIME TO QUIT"<<endl<<endl;
system("pause");
system("cls");
while (quit==false)
{
if(win(redboolboard, blueboolboard)!=0)
{
quit=true;
}
if (quit==false)
{
number=getboard(board, cboard, blueboolboard, redboolboard, playerone, size, PLAYER1);
stop=false;
}
else
{
number=8;
}
if (number==8)
{
quit=true;
}
else
{
system("cls");
if (cboard[5][number]==false)
{
falling(board, redboolboard, blueboolboard, cboard, number, playerone, size, PLAYER1);
cboard[5][number]=true;
system("cls");
redboolboard[5][number]=true;
}
else if(cboard[0][number]!=true)
{
for (x=4; x>=0; x--)
{
if (stop==false)
{
if (cboard[x][number]!=true)
{
falling(board, redboolboard, blueboolboard, cboard, number, playerone, size, PLAYER1);
redboolboard[x][number]=true;
system("cls");
cboard[x][number]=true;
stop=true;
}
}
}
}
}
//RED'S TURN
stop=false;
if (win(redboolboard, blueboolboard)!=0)
{
quit=true;
}
else if(quit!=true)
{
number=getboard(board, cboard, blueboolboard, redboolboard, playertwo, size, PLAYER2);
if (number==8 || win(redboolboard, blueboolboard)!=0)
{
quit=true;
}
if (quit==false)
{
if (cboard[5][number]==false)
{
falling(board, redboolboard, blueboolboard, cboard, number, playertwo, size, PLAYER2);
cboard[5][number]=true;
system("cls");
blueboolboard[5][number]=true;
}
else
{
for (x=4; x>=0; x--)
{
if (stop==false)
{
if (cboard[x][number]!=true)
{
falling(board, redboolboard, blueboolboard, cboard,number, playertwo, size, PLAYER2);
blueboolboard[x][number]=true;
cboard[x][number]=true;
system("cls");
stop=true;
}
}
}
}
}
}
}
system("cls");
winningboard(board, blueboolboard, redboolboard);
if (win(redboolboard, blueboolboard)==1)
{
for (d=0; d<size, playerone[d]!='\0'; d++)
{
//all caps
if (playerone[d]<=122 && playerone[d]>=97)
playerone[d]-=32;
cout<<playerone[d];
}
cout<<" WINS!!!";
}
else if (win(redboolboard, blueboolboard)==2)
{
for (d=0; d<size, playertwo[d]!='\0'; d++)
{
//all caps
if (playertwo[d]<=122 && playertwo[d]>=97)
playertwo[d]-=32;
cout<<playertwo[d];
}
cout<<" WINS!!!";
}
else
{
cout<<"it's a tie";
}
cout<<endl;
cout<<"PLAY AGAIN?\n1=NO\n2=YES"<<endl;
cin>>yesorno;
yesorno--;
if (yesorno==NO)
{
exit(1);
}
}
return 0;
}
void setcolor (int background, int letter)
{
int color=background*16+letter;
cout<<flush;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), color);
}
void viewchar()
{
char letter;
system("cls");
for (int x=0; x<=255; x++)
{
letter=x;
cout<<x<<": "<<letter<<"\t";
if(x%6==0)
{
cout<<endl;
}
}
system("pause");
}
 
void set_color (int background, int letter)
{
int color=background*16+letter;
cout<<flush;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), color);
}
void resetboard(char board[][7])
{
for (int row=0; row<6; row++)
{
for (int collumn=0; collumn<7; collumn++)
{
board[row][collumn]=15;
}
}
}
int getboard(char board [][7], bool cboard[][7], bool blueboolboard[][7], bool redboolboard[][7], char name[], const int num, const int who)
{
char letter;
char arrow[7]={' ',' ',' ',' ',' ',' ',' '};
int arrowpos;
int t;
displayboard(board, blueboolboard, redboolboard, name, num, who);
 
int r=0;
for (r; r<7; r++)
{
if (cboard[0][r]==false)
{
arrow[r]=15;
arrowpos=r;
break;
}
if (r==6 && cboard[0][6]==true)
{
return 8;
}
}
while (t!=13 && t!=27)
{
t=getch();
system("cls");
for (int a=0; a<20, name[a]+='\0'; a++)
{
cout<<name[a];
}
cout<<endl<<endl<<endl;
if (t==LEFT)
{
if (arrowpos!=0)
{
if (cboard[0][arrowpos-1]==false)
{
arrow[arrowpos]=' ';
arrowpos--;
arrow[arrowpos]=15;
}
else
{
for (int i=arrowpos-1; i>=0; i--)
{
if (cboard[0][i]==false)
{
arrow[i]=15;
arrow[arrowpos]=' ';
arrowpos=i;
break;
}
}
}
 
}
}
else if (t==RIGHT)
{
if (arrowpos!=6)
{
if (cboard[0][arrowpos+1]==false)
{
arrow[arrowpos]=' ';
arrowpos++;
arrow[arrowpos]=15;
}
else
{
for (int i=arrowpos+1; i<7; i++)
{
if (cboard[0][i]==false)
{
arrow[i]=15;
arrow[arrowpos]=' ';
arrowpos=i;
break;
}
}
}
}
}
cout<<" ";
setcolor(BLACK, LIME);
for (int w=0; w<7; w++)
{
if (who==PLAYER1)
{
setcolor(BLACK, RED);
}
else
{
setcolor(BLACK, LIGHT_BLUE);
}
cout<<arrow[w]<<' ';
}
setcolor(BLACK, WHITE);
cout<<endl;
for (int x=0; x<6; x++)
{
cout<<setw(5);
for (int y=0; y<7; y++)
{
if (blueboolboard[x][y])
{
setcolor(BLACK, LIGHT_BLUE);
cout<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
else if (redboolboard[x][y])
{
setcolor(BLACK, RED);
cout<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
else
{
setcolor(BLACK, YELLOW);
cout<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
}
cout<<endl;
}
setcolor(BLACK, BRIGHT_BLUE);
letter=219;
cout<<" "<<letter<<" "<<letter<<endl;
letter=30;
cout<<endl;
setcolor(BLACK, WHITE);
}
if (t!=27)
return arrowpos;
else
return 8;
}
void resetbool (bool blueboolboard[][7], bool redboolboard[][7], bool cboard[][7])
{
for (int x=0; x<6; x++)
{
for (int y=0; y<7; y++)
{
blueboolboard[x][y]=false;
redboolboard[x][y]=false;
cboard[x][y]=false;
}
}
}
void falling(char board[][7], bool redboolboard[][7], bool blueboolboard[][7], bool cboard[][7], int num, char name[], int number, const int who)
{
char letter;
int stop;
if (cboard[5][num]==false)
stop=5;
else
{
for (int q=4; q>=0; q--)
{
if (cboard[q][num]==false)
{
stop=q;
break;
}
}
}
for (int r=0; r<=stop; r++)
{
system("cls");
for (int a=0; a<20, name[a]!='\0'; a++)
{
cout<<name[a];
}
cerr<<endl<<endl<<endl<<endl;
if (who==PLAYER1)
{
redboolboard[r][num]=true;
}
if (who==PLAYER2)
{
blueboolboard[r][num]=true;
}
for (int x=0; x<6; x++)
{
cerr<<setw(5);
for (int y=0; y<7; y++)
{
if (blueboolboard[x][y])
{
setcolor(BLACK, LIGHT_BLUE);
cerr<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
else if (redboolboard[x][y])
{
setcolor(BLACK, RED);
cerr<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
else
{
setcolor(BLACK, YELLOW);
cerr<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
}
cerr<<endl;
}
if (who==PLAYER1)
{
redboolboard[r][num]=false;
}
if (who==PLAYER2)
{
blueboolboard[r][num]=false;
}
setcolor(BLACK, BRIGHT_BLUE);
letter=219;
cout<<" "<<letter<<" "<<letter<<endl;
letter=30;
cout<<endl;
setcolor(BLACK, WHITE);
cout<<endl;
Sleep(100);
}
}
void displayboard(char board [][7], bool blueboolboard[][7], bool redboolboard[][7], char name[], const int size, const int who)
{
char letter=15;
char arrow[7]={' ',' ',' ',' ',' ',' ',' '};
for (int a=0; a<20, name[a]!='\0'; a++)
cout<<name[a];
cout<<endl;
cout<<endl<<endl;
for (int i=0; i<7; i++)
{
if (redboolboard[0][i]==false && blueboolboard[0][i]==false)
{
arrow[i]=15;
break;
}
}
if (who==PLAYER1)
{
setcolor(BLACK, RED);
}
else if (who==PLAYER2)
{
setcolor(BLACK, LIGHT_BLUE);
}
cout<<" ";
for (int u=0; u<7; u++)
{
cout<<arrow[u]<<' ';
}
cout<<endl;
setcolor(BLACK, WHITE);
for (int x=0; x<6; x++)
{
cout<<setw(5);
for (int y=0; y<7; y++)
{
if (blueboolboard[x][y])
{
setcolor(BLACK, LIGHT_BLUE);
cout<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
else if (redboolboard[x][y])
{
setcolor(BLACK, RED);
cout<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
else
{
setcolor(BLACK, YELLOW);
cout<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
}
cout<<endl;
}
setcolor(BLACK, BRIGHT_BLUE);
letter=219;
cout<<" "<<letter<<" "<<letter<<endl;
letter=30;
cout<<endl;
setcolor(BLACK, WHITE);
}
int win(bool redboard [][7], bool blueboard [][7])
{
//int win1, win2, win3, win4;
//this is gona be a pain
//across
//1
if (redboard[0][0]==true && redboard[0][1]==true &&redboard[0][2]==true &&redboard[0][3]==true)
{
return PLAYER1;
}
if (blueboard[0][0]==true && blueboard[0][1]==true &&blueboard[0][2]==true &&blueboard[0][3]==true)
{
return PLAYER2;
}
//2
if (redboard[0][1]==true && redboard[0][2]==true &&redboard[0][3]==true &&redboard[0][4]==true)
{
return PLAYER1;
}
if (blueboard[0][1]==true && blueboard[0][2]==true &&blueboard[0][3]==true &&blueboard[0][4]==true)
{
return PLAYER2;
}
//3
if (redboard[0][2]==true && redboard[0][3]==true &&redboard[0][4]==true &&redboard[0][5]==true)
{
return PLAYER1;
}
if (blueboard[0][2]==true && blueboard[0][3]==true &&blueboard[0][4]==true &&blueboard[0][5]==true)
{
return PLAYER2;
}
//4
if (redboard[0][3]==true && redboard[0][4]==true &&redboard[0][5]==true &&redboard[0][6]==true)
{
return PLAYER1;
}
if (blueboard[0][3]==true && blueboard[0][4]==true &&blueboard[0][5]==true &&blueboard[0][6]==true)
{
return PLAYER2;
}
//5
if (redboard[1][0]==true && redboard[1][1]==true &&redboard[1][2]==true &&redboard[1][3]==true)
{
return PLAYER1;
}
if (blueboard[1][0]==true && blueboard[1][1]==true &&blueboard[1][2]==true &&blueboard[1][3]==true)
{
return PLAYER2;
}
//6
if (redboard[1][1]==true && redboard[1][2]==true &&redboard[1][3]==true &&redboard[1][4]==true)
{
return PLAYER1;
}
if (blueboard[1][1]==true && blueboard[1][2]==true &&blueboard[1][3]==true &&blueboard[1][4]==true)
{
return PLAYER2;
}
//7
if (redboard[1][2]==true && redboard[1][3]==true &&redboard[1][4]==true &&redboard[1][5]==true)
{
return PLAYER1;
}
if (blueboard[1][2]==true && blueboard[1][3]==true &&blueboard[1][4]==true &&blueboard[1][5]==true)
{
return PLAYER2;
}
//8
if (redboard[1][3]==true && redboard[1][4]==true &&redboard[1][5]==true &&redboard[1][6]==true)
{
return PLAYER1;
}
if (blueboard[1][3]==true && blueboard[1][4]==true &&blueboard[1][4]==true &&blueboard[1][5]==true)
{
return PLAYER2;
}
//9
if (redboard[2][0]==true && redboard[2][1]==true &&redboard[2][2]==true &&redboard[2][3]==true)
{
return PLAYER1;
}
if (blueboard[2][0]==true && blueboard[2][1]==true &&blueboard[2][2]==true &&blueboard[2][3]==true)
{
return PLAYER2;
}
//10
if (redboard[2][1]==true && redboard[2][2]==true &&redboard[2][3]==true &&redboard[2][4]==true)
{
return PLAYER1;
}
if (blueboard[2][1]==true && blueboard[2][2]==true &&blueboard[2][3]==true &&blueboard[2][4]==true)
{
return PLAYER2;
}
//11
if (redboard[2][2]==true && redboard[2][3]==true &&redboard[2][4]==true &&redboard[2][5]==true)
{
return PLAYER1;
}
if (blueboard[2][2]==true && blueboard[2][3]==true &&blueboard[2][4]==true &&blueboard[2][5]==true)
{
return PLAYER2;
}
//12
if (redboard[2][3]==true && redboard[2][4]==true &&redboard[2][5]==true &&redboard[2][6]==true)
{
return PLAYER1;
}
if (blueboard[2][3]==true && blueboard[2][4]==true &&blueboard[2][5]==true &&blueboard[2][6]==true)
{
return PLAYER2;
}
//13
if (redboard[3][0]==true && redboard[3][1]==true &&redboard[3][2]==true &&redboard[3][3]==true)
{
return PLAYER1;
}
if (blueboard[3][0]==true && blueboard[3][1]==true &&blueboard[3][2]==true &&blueboard[3][3]==true)
{
return PLAYER2;
}
//14
if (redboard[3][1]==true && redboard[3][2]==true &&redboard[3][3]==true &&redboard[3][4]==true)
{
return PLAYER1;
}
if (blueboard[2][1]==true && blueboard[3][2]==true &&blueboard[3][3]==true &&blueboard[3][4]==true)
{
return PLAYER2;
}
//15
if (redboard[3][2]==true && redboard[3][3]==true &&redboard[3][4]==true &&redboard[3][5]==true)
{
return PLAYER1;
}
if (blueboard[3][2]==true && blueboard[3][3]==true &&blueboard[3][4]==true &&blueboard[3][5]==true)
{
return PLAYER2;
}
//16
if (redboard[3][3]==true && redboard[3][4]==true &&redboard[2][5]==true &&redboard[2][6]==true)
{
return PLAYER1;
}
if (blueboard[3][3]==true && blueboard[3][4]==true &&blueboard[2][5]==true &&blueboard[2][6]==true)
{
return PLAYER2;
}
//17
if (redboard[4][0]==true && redboard[4][1]==true &&redboard[4][2]==true &&redboard[4][3]==true)
{
return PLAYER1;
}
if (blueboard[4][0]==true && blueboard[4][1]==true &&blueboard[4][2]==true &&blueboard[4][3]==true)
{
return PLAYER2;
}
//18
if (redboard[4][1]==true && redboard[4][2]==true &&redboard[4][3]==true &&redboard[4][4]==true)
{
return PLAYER1;
}
if (blueboard[4][1]==true && blueboard[4][2]==true &&blueboard[4][3]==true &&blueboard[4][4]==true)
{
return PLAYER2;
}
//19
if (redboard[4][2]==true && redboard[4][3]==true &&redboard[4][4]==true &&redboard[4][5]==true)
{
return PLAYER1;
}
if (blueboard[4][2]==true && blueboard[4][3]==true &&blueboard[4][4]==true &&blueboard[4][5]==true)
{
return PLAYER2;
}
//20
if (redboard[4][3]==true && redboard[4][4]==true &&redboard[4][5]==true &&redboard[4][6]==true)
{
return PLAYER1;
}
if (blueboard[4][3]==true && blueboard[4][4]==true &&blueboard[4][5]==true &&blueboard[4][6]==true)
{
return PLAYER2;
}
//21
if (redboard[5][0]==true && redboard[5][1]==true &&redboard[5][2]==true &&redboard[5][3]==true)
{
return PLAYER1;
}
if (blueboard[5][0]==true && blueboard[5][1]==true &&blueboard[5][2]==true &&blueboard[5][3]==true)
{
return PLAYER2;
}
//22
if (redboard[5][1]==true && redboard[5][2]==true &&redboard[5][3]==true &&redboard[5][4]==true)
{
return PLAYER1;
}
if (blueboard[5][1]==true && blueboard[5][2]==true &&blueboard[5][3]==true &&blueboard[5][4]==true)
{
return PLAYER2;
}
//23
if (redboard[5][2]==true && redboard[5][3]==true &&redboard[5][4]==true &&redboard[5][5]==true)
{
return PLAYER1;
}
if (blueboard[5][2]==true && blueboard[5][3]==true &&blueboard[5][4]==true &&blueboard[5][5]==true)
{
return PLAYER2;
}
//24
if (redboard[5][3]==true && redboard[5][4]==true &&redboard[5][5]==true &&redboard[5][6]==true)
{
return PLAYER1;
}
if (blueboard[5][3]==true && blueboard[5][4]==true &&blueboard[5][5]==true &&blueboard[5][6]==true)
{
return PLAYER2;
}
 
//down
//25
if (redboard[0][0]==true && redboard[1][0]==true && redboard[2][0]==true && redboard[3][0]==true)
{
return PLAYER1;
}
if (blueboard[0][0]==true && blueboard[1][0]==true && blueboard[2][0]==true && blueboard[3][0]==true)
{
return PLAYER2;
}
//26
if (redboard[1][0]==true && redboard[2][0]==true && redboard[3][0]==true && redboard[4][0]==true)
{
return PLAYER1;
}
if (blueboard[1][0]==true && blueboard[2][0]==true && blueboard[3][0]==true && blueboard[4][0]==true)
{
return PLAYER2;
}
//27
if (redboard[2][0]==true && redboard[3][0]==true && redboard[4][0]==true && redboard[5][0]==true)
{
return PLAYER1;
}
if (blueboard[2][0]==true && blueboard[3][0]==true && blueboard[4][0]==true && blueboard[5][0]==true)
{
return PLAYER2;
}
//28
if (redboard[0][1]==true && redboard[1][1]==true && redboard[2][1]==true && redboard[3][1]==true)
{
return PLAYER1;
}
if (blueboard[0][1]==true && blueboard[1][1]==true && blueboard[2][1]==true && blueboard[3][1]==true)
{
return PLAYER2;
}
//29
if (redboard[1][1]==true && redboard[2][1]==true && redboard[3][1]==true && redboard[4][1]==true)
{
return PLAYER1;
}
if (blueboard[1][1]==true && blueboard[2][1]==true && blueboard[3][1]==true && blueboard[4][1]==true)
{
return PLAYER2;
}
//30
if (redboard[2][1]==true && redboard[3][1]==true && redboard[4][1]==true && redboard[5][1]==true)
{
return PLAYER1;
}
if (blueboard[2][1]==true && blueboard[3][1]==true && blueboard[4][1]==true && blueboard[5][1]==true)
{
return PLAYER2;
}
//31
if (redboard[0][2]==true && redboard[1][2]==true && redboard[2][2]==true && redboard[3][2]==true)
{
return PLAYER1;
}
if (blueboard[0][2]==true && blueboard[1][2]==true && blueboard[2][2]==true && blueboard[3][2]==true)
{
return PLAYER2;
}
//32
if (redboard[1][2]==true && redboard[2][2]==true && redboard[3][2]==true && redboard[4][2]==true)
{
return PLAYER1;
}
if (blueboard[1][2]==true && blueboard[2][2]==true && blueboard[3][2]==true && blueboard[4][2]==true)
{
return PLAYER2;
}
//33
if (redboard[2][2]==true && redboard[3][2]==true && redboard[4][2]==true && redboard[5][2]==true)
{
return PLAYER1;
}
if (blueboard[2][2]==true && blueboard[3][2]==true && blueboard[4][2]==true && blueboard[5][2]==true)
{
return PLAYER2;
}
//34
if (redboard[0][3]==true && redboard[1][3]==true && redboard[2][3]==true && redboard[3][3]==true)
{
return PLAYER1;
}
if (blueboard[0][3]==true && blueboard[1][3]==true && blueboard[2][3]==true && blueboard[3][3]==true)
{
return PLAYER2;
}
//35
if (redboard[1][3]==true && redboard[2][3]==true && redboard[3][3]==true && redboard[4][3]==true)
{
return PLAYER1;
}
if (blueboard[1][3]==true && blueboard[2][3]==true && blueboard[3][3]==true && blueboard[4][3]==true)
{
return PLAYER2;
}
//36
if (redboard[2][3]==true && redboard[3][3]==true && redboard[4][3]==true && redboard[5][3]==true)
{
return PLAYER1;
}
if (blueboard[2][3]==true && blueboard[3][3]==true && blueboard[4][3]==true && blueboard[5][3]==true)
{
return PLAYER2;
}
//37
if (redboard[0][4]==true && redboard[1][4]==true && redboard[2][4]==true && redboard[3][4]==true)
{
return PLAYER1;
}
if (blueboard[0][4]==true && blueboard[1][4]==true && blueboard[2][4]==true && blueboard[3][4]==true)
{
return PLAYER2;
}
//38
if (redboard[1][4]==true && redboard[2][4]==true && redboard[3][4]==true && redboard[4][4]==true)
{
return PLAYER1;
}
if (blueboard[1][4]==true && blueboard[2][4]==true && blueboard[3][4]==true && blueboard[4][4]==true)
{
return PLAYER2;
}
//39
if (redboard[2][4]==true && redboard[3][4]==true && redboard[4][4]==true && redboard[3][5]==true)
{
return PLAYER1;
}
if (blueboard[2][4]==true && blueboard[3][4]==true && blueboard[4][4]==true && blueboard[3][5]==true)
{
return PLAYER2;
}
//40
if (redboard[0][5]==true && redboard[1][5]==true && redboard[2][5]==true && redboard[3][5]==true)
{
return PLAYER1;
}
if (blueboard[0][5]==true && blueboard[1][5]==true && blueboard[2][5]==true && blueboard[3][5]==true)
{
return PLAYER2;
}
//41
if (redboard[1][5]==true && redboard[2][5]==true && redboard[3][5]==true && redboard[4][5]==true)
{
return PLAYER1;
}
if (blueboard[1][5]==true && blueboard[2][5]==true && blueboard[3][5]==true && blueboard[4][5]==true)
{
return PLAYER2;
}
//42
if (redboard[2][5]==true && redboard[3][5]==true && redboard[4][5]==true && redboard[5][5]==true)
{
return PLAYER1;
}
if (blueboard[2][5]==true && blueboard[3][5]==true && blueboard[4][5]==true && blueboard[5][5]==true)
{
return PLAYER2;
}
//43
if (redboard[0][6]==true && redboard[1][6]==true && redboard[2][6]==true && redboard[3][6]==true)
{
return PLAYER1;
}
if (blueboard[0][6]==true && blueboard[1][6]==true && blueboard[2][6]==true && blueboard[3][6]==true)
{
return PLAYER2;
}
//44
if (redboard[1][6]==true && redboard[2][6]==true && redboard[3][6]==true && redboard[4][6]==true)
{
return PLAYER1;
}
if (blueboard[1][6]==true && blueboard[2][6]==true && blueboard[3][6]==true && blueboard[4][6]==true)
{
return PLAYER2;
}
//45
if (redboard[2][6]==true && redboard[3][6]==true && redboard[4][6]==true && redboard[5][6]==true)
{
return PLAYER1;
}
if (blueboard[2][6]==true && blueboard[3][6]==true && blueboard[4][6]==true && blueboard[5][6]==true)
{
return PLAYER2;
}
//diagonal bottomleft to top right
//46
if (redboard[3][0]==true && redboard[2][1]==true && redboard[1][2]==true && redboard[0][3]==true)
{
return PLAYER1;
}
if (blueboard[3][0]==true && blueboard[2][1]==true && blueboard[1][2]==true && blueboard[0][3]==true)
{
return PLAYER2;
}
//47
if (redboard[5][3]==true && redboard[4][4]==true && redboard[3][5]==true && redboard[2][6]==true)
{
return PLAYER1;
}
if (blueboard[5][3]==true && blueboard[4][4]==true && blueboard[3][5]==true && blueboard[2][6]==true)
{
return PLAYER2;
}
//48
if (redboard[4][0]==true && redboard[3][1]==true && redboard[2][2]==true && redboard[1][3]==true)
{
return PLAYER1;
}
if (blueboard[4][0]==true && blueboard[3][1]==true && blueboard[2][2]==true && blueboard[1][3]==true)
{
return PLAYER2;
}
//49
if (redboard[3][1]==true && redboard[2][2]==true && redboard[1][3]==true && redboard[0][4]==true)
{
return PLAYER1;
}
if (blueboard[3][1]==true && blueboard[2][2]==true && blueboard[1][3]==true && blueboard[0][4]==true)
{
return PLAYER2;
}
//50
if (redboard[5][2]==true && redboard[4][3]==true && redboard[3][4]==true && redboard[2][5]==true)
{
return PLAYER1;
}
if (blueboard[5][2]==true && blueboard[4][3]==true && blueboard[3][4]==true && blueboard[2][5]==true)
{
return PLAYER2;
}
//51
if (redboard[4][3]==true && redboard[3][4]==true && redboard[2][5]==true && redboard[1][6]==true)
{
return PLAYER1;
}
if (blueboard[4][3]==true && blueboard[3][4]==true && blueboard[2][5]==true && blueboard[1][6]==true)
{
return PLAYER2;
}
//52
if (redboard[5][1]==true && redboard[4][2]==true && redboard[3][3]==true && redboard[2][4]==true)
{
return PLAYER1;
}
if (blueboard[5][1]==true && blueboard[4][2]==true && blueboard[3][3]==true && blueboard[2][4]==true)
{
return PLAYER2;
}
//53
if (redboard[4][2]==true && redboard[3][3]==true && redboard[2][4]==true && redboard[1][5]==true)
{
return PLAYER1;
}
if (blueboard[4][2]==true && blueboard[3][3]==true && blueboard[2][4]==true && blueboard[1][5]==true)
{
return PLAYER2;
}
//54
if (redboard[3][3]==true && redboard[2][4]==true && redboard[1][5]==true && redboard[0][6]==true)
{
return PLAYER1;
}
if (blueboard[3][3]==true && blueboard[2][4]==true && blueboard[1][5]==true && blueboard[0][6]==true)
{
return PLAYER2;
}
//55
if (redboard[5][0]==true && redboard[4][1]==true && redboard[3][2]==true && redboard[2][3]==true)
{
return PLAYER1;
}
if (blueboard[5][0]==true && blueboard[4][1]==true && blueboard[3][2]==true && blueboard[2][3]==true)
{
return PLAYER2;
}
//56
if (redboard[4][1]==true && redboard[3][2]==true && redboard[2][3]==true && redboard[1][4]==true)
{
return PLAYER1;
}
if (blueboard[4][1]==true && blueboard[3][2]==true && blueboard[2][3]==true && blueboard[1][4]==true)
{
return PLAYER2;
}
//57
if (redboard[3][2]==true && redboard[2][3]==true && redboard[1][4]==true && redboard[0][5]==true)
{
return PLAYER1;
}
if (blueboard[3][2]==true && blueboard[2][3]==true && blueboard[1][4]==true && blueboard[0][5]==true)
{
return PLAYER2;
}
//diagonal top left to bottom right
//58
if (redboard[2][0]==true && redboard[3][1]==true && redboard[4][2]==true && redboard[5][3]==true)
{
return PLAYER1;
}
if (blueboard[2][0]==true && blueboard[3][1]==true && blueboard[4][2]==true && blueboard[5][3]==true)
{
return PLAYER2;
}
//59
if (redboard[0][3]==true && redboard[1][4]==true && redboard[2][5]==true && redboard[3][6]==true)
{
return PLAYER1;
}
if (blueboard[0][3]==true && blueboard[1][4]==true && blueboard[2][5]==true && blueboard[3][6]==true)
{
return PLAYER2;
}
//60
if (redboard[1][0]==true && redboard[2][1]==true && redboard[3][2]==true && redboard[4][3]==true)
{
return PLAYER1;
}
if (blueboard[1][0]==true && blueboard[2][1]==true && blueboard[3][2]==true && blueboard[4][3]==true)
{
return PLAYER2;
}
//61
if (redboard[2][1]==true && redboard[3][2]==true && redboard[4][3]==true && redboard[5][4]==true)
{
return PLAYER1;
}
if (blueboard[2][1]==true && blueboard[3][2]==true && blueboard[4][3]==true && blueboard[5][4]==true)
{
return PLAYER2;
}
//62
if (redboard[0][2]==true && redboard[1][3]==true && redboard[2][4]==true && redboard[3][5]==true)
{
return PLAYER1;
}
if (blueboard[0][2]==true && blueboard[1][3]==true && blueboard[2][4]==true && blueboard[3][5]==true)
{
return PLAYER2;
}
//63
if (redboard[1][3]==true && redboard[2][4]==true && redboard[3][5]==true && redboard[4][6]==true)
{
return PLAYER1;
}
if (blueboard[1][3]==true && blueboard[2][4]==true && blueboard[3][5]==true && blueboard[4][6]==true)
{
return PLAYER2;
}
//64
if (redboard[0][1]==true && redboard[1][2]==true && redboard[2][3]==true && redboard[3][4]==true)
{
return PLAYER1;
}
if (blueboard[0][1]==true && blueboard[1][2]==true && blueboard[2][3]==true && blueboard[3][4]==true)
{
return PLAYER2;
}
//65
if (redboard[1][2]==true && redboard[2][3]==true && redboard[3][4]==true && redboard[4][5]==true)
{
return PLAYER1;
}
if (blueboard[1][2]==true && blueboard[2][3]==true && blueboard[3][4]==true && blueboard[4][5]==true)
{
return PLAYER2;
}
//66
if (redboard[2][3]==true && redboard[3][4]==true && redboard[4][5]==true && redboard[5][6]==true)
{
return PLAYER1;
}
if (blueboard[2][3]==true && blueboard[3][4]==true && blueboard[4][5]==true && blueboard[5][6]==true)
{
return PLAYER2;
}
//67
if (redboard[0][0]==true && redboard[1][1]==true && redboard[2][2]==true && redboard[3][3]==true)
{
return PLAYER1;
}
if (blueboard[0][0]==true && blueboard[1][1]==true && blueboard[2][2]==true && blueboard[3][3]==true)
{
return PLAYER2;
}
//68
if (redboard[1][1]==true && redboard[2][2]==true && redboard[3][3]==true && redboard[4][4]==true)
{
return PLAYER1;
}
if (blueboard[1][1]==true && blueboard[2][2]==true && blueboard[3][3]==true && blueboard[4][4]==true)
{
return PLAYER2;
}
//69
if (redboard[2][2]==true && redboard[3][3]==true && redboard[4][4]==true && redboard[5][5]==true)
{
return PLAYER1;
}
if (blueboard[2][2]==true && blueboard[3][3]==true && blueboard[4][4]==true && blueboard[5][5]==true)
{
return PLAYER2;
}
return 0;
//yes this function was a pain int the ass to make
}
 
void winningboard(char board[][7], bool blueboolboard [][7], bool redboolboard[][7])
{
char letter;
cout<<endl<<endl<<endl<<endl;
for (int x=0; x<6; x++)
{
cout<<setw(5);
for (int y=0; y<7; y++)
{
if (blueboolboard[x][y])
{
setcolor(BLACK, LIGHT_BLUE);
cout<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
else if (redboolboard[x][y])
{
setcolor(BLACK, RED);
cout<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
else
{
setcolor(BLACK, YELLOW);
cout<<board[x][y]<<' ';
setcolor(BLACK, WHITE);
}
}
cout<<endl;
}
setcolor(BLACK, BRIGHT_BLUE);
letter=219;
cout<<" "<<letter<<" "<<letter<<endl;
letter=30;
cout<<endl;
setcolor(BLACK, WHITE);
}//1241 Lines


ALINTIDIR