Hey All i am making a connect four game. I have done most of the code but need help in some bits
1) Which is how to code to see if there a win from vertical, horizontal or diagonal. - The Grid is 7 by 7. - I no idea how to code this and if i need in a function on its own or in the main game loop, also do i need make one for both p1 and p2? or will one just do??
2) After someone wins I want be able to score the result of both p1 and p2 (win lost or a draw) into a notepad file. I also want make a function to get that notepad to bubble sort all the top 20 players and show them in ranking order. Also is there a way of getting the notepad file not to allow ppl to edit the scores without playing the game??
For Exampple for the ranks:-
Joe blongs Won 5 Lost 4 Draw 4
Joe1 blogs1 Won 5 Lost 4 Draw 4
Joe2 blogs Won 5 Lost 0 Draw 0
Joe3 blogs1 Won 4 Lost 0 Draw 0
Below is the code I have so far...
void gamestart()
{
system("cls");
player player1;
player player2;
player1.counter = 'X';
player2.counter = 'O';
cout<<"Player 1 Please Enter Your First Name\n";
cout<<endl;
cin >> player1.name;
cout<<endl;
cout<<"Player 2 Please Enter Your First Name\n";
cout<<endl;
cin>>player2.name;
cout<<endl;
cout<<player1.name<<" Vs "<<player2.name;
cout<<endl;
cout<<endl;
while (bool game = true)
{
int choice,move = 1;
system("cls");
cout<<player1.name<< " Your Counter Is A "<<player1.counter;
cout<<endl;
cout<<endl;
cout<<player2.name<< " Your Counter Is A "<<player2.counter;
cout<<endl;
cout<<endl;
drawGrid();
if (move = 1) {
do {
do {
cout<<player1.name<<" Please Enter A Column 1 To 7\n";
cout<<endl;
cin>>choice;
choice--;
} while ((choice <0) ||(choice >7));
} while (frame[choice].count ==7);
}
{ drawGrid();
addCounter(player1.counter,choice);
move++;
}
system("cls"); // clears p1 - SOLVES THE BOARD PRINTING TWICE!
if (move = 2) {
do {
do {
cout<<player1.name<< " Your Counter Is A "<<player1.counter;
cout<<endl;
cout<<endl;
cout<<player2.name<< " Your Counter Is A "<<player2.counter;
cout<<endl;
cout<<endl;
drawGrid();
cout<<player2.name<<" Please Enter A Column 1 To 7\n";
cout<<endl;
cin>>choice;
choice--;
} while ((choice <0) ||(choice >7));
} while (frame[choice].count ==7);
}
{ addCounter(player2.counter,choice);
move++;
}
} // end main game loop
} // end game start
Thanks.