NEED HELP IN C++(SOS GAME)

Need help in what to , and where to start in scoring on each player who forms an SOS(for player one) and OSO(for player two) on the grid , until the whole grid is full . The more points they got , will be the winner . PLS help Thnks, IM using Bloodshed Dev C++.




[#include <iostream>
#include <stdlib.h>
using namespace std;

void displayScreen();
void welcome();
void howtoPlay();
void gameinfo();
void gamePlay();
void table();
void tryAgain();
void ExOne();
void GameEx();
void contGame();
void playerone();
void playertwo();
void overnum();
void occupated();
void wincheck();
void wincheck1();

int player1score = 0;
int player2score = 0;
char array[]={'1','2','3','4','5','6','7','8','9','10','11','1 2','13','14','15','16','17','18','19','20','21','2 2','23','24'};


int main()
{
displayScreen();
return 0;
}
void displayScreen()
{
cout<<"\n\n\t\t\t Welcome to S.O.S game!!!"<<endl<<endl;
char choose;

cout<<endl<<"\t ================================================== ======"<<endl;
cout<<" [1] Start The Game"<<endl;
cout<<endl;
cout<<" [2] How To Play The Game"<<endl;
cout<<endl;
cout<<" [3] Gameinfo"<<endl;
cout<<endl;
cout<<" [4] Exit"<<endl;
cout<<endl<<"\t ================================================== ======"<<endl;
cout<<endl;

cout<<"\t\t\tEnter A Number In The Menu That You Want: ";
cin>>choose;
system("cls");

switch(choose)
{
case '1':
gamePlay(); //PUPUNTA SIYA KAY GAMEPLAY
break;

case '2':
howtoPlay(); //PUPUNTA SIYA KAY HOWTOPLAY
break;

case '3':
gameinfo();
break;

case '4':
cout<<"\t\t\t Thank You For Using Our Program"<<endl<<endl;
break;

default:
cout<<"\t\t\t\tInvalid Input!"<<endl;
tryAgain();
break;
}
}

void gamePlay(){
table();
playerone();
}

void table(){

cout<< "\n";
cout<< "\t\t\t |======|======|======|======|======|======|"<<endl ;
cout<< "\tPLayer 1 :"<<player1score<<" | | | | | | |" << endl;
cout<< "\tPLayer 2 :"<<player2score<<" | "<<array[0]<<" | "<<array[1]<<" | "<<array[2]<<" | "<<array[3]<<" | "<<array[4]<<" | "<<array[5]<<" |" << endl;
cout<< "\t\t\t | | | | | | |" << endl;
cout<< "\t\t\t |======|======|======|======|======|======|"<<endl ;
cout<< "\t\t\t | | | | | | |" << endl;
cout<< "\t\t\t | "<<array[6]<<" | "<<array[7]<<" | "<<array[8]<<" | "<<array[9]<<" | "<<array[10]<<" | "<<array[11]<<" |" << endl;
cout<< "\t\t\t | | | | | | |" << endl;
cout<< "\t\t\t |======|======|======|======|======|======|"<<endl ;
cout<< "\t\t\t | | | | | | |" << endl;
cout<< "\t\t\t | "<<array[12]<<" | "<<array[13]<<" | "<<array[14]<<" | "<<array[15]<<" | "<<array[16]<<" | "<<array[17]<<" |" << endl;
cout<< "\t\t\t | | | | | | |" << endl;
cout<< "\t\t\t |======|======|======|======|======|======|"<<endl ;
cout<< "\t\t\t | | | | | | |" << endl;
cout<< "\t\t\t | "<<array[18]<<" | "<<array[19]<<" | "<<array[20]<<" | "<<array[21]<<" | "<<array[22]<<" | "<<array[23]<<" |" << endl;
cout<< "\t\t\t | | | | | | |" << endl;
cout<< "\t\t\t |======|======|======|======|======|======|"<<endl ;


}

void tryAgain()
{
char tryA;
cout<<"\t\tInput letter M if you want to go back to main menu"<<endl;
cin>>tryA;
if (tryA=='m' || tryA=='M')
{
system("cls");
main();
}
else
{
cout<<"\t\t\t\t Invalid Input"<<endl;
tryAgain();//BABALIK SIYA KAY TRYAGAIN
}
}

void howtoPlay()
{
cout<<"\t\tThis Is A Simple Program Made In C++ Called S.O.S game"<<endl;
cout<<"\t\tThe object of the game is for each player to attempt to create "<<endl;
cout<<"\t\t(on their turn) the straight sequence S-O-S among connected"<<endl;
cout<<"\t\tsquares(either diagonally, horizontally, or vertically), "<<endl;
cout<<"\t\tand to create as many such sequences as they can."<<endl;
cout<<"\t\tThe Player One's Legend is 'S' and Player Two's Legend Is 'O'"<<endl;
cout<<"\t\tThis Is A Sample Output If Player One Choose Box 1 and"<<endl;
cout<<"\t\t\t Player Two Choose Box 5"<<endl<<endl;
GameEx();
cout<<"\t\tA Player Wins a point If He/She Forms a (SOS) in a straight"<<endl;
cout<<"\t\tor Diagonal Line , the many the word SOS has been formed,"<<endl;
cout<<"\t\tthe more points you will get"<<endl;
cout<<"\t\tThis Is A Sample Of A Player's Move Who will have 1 Point"<<endl<<endl;
ExOne(); //PUPUNTA SIYA KAY EXONE NAMAN
cout<<"\t\tif a player succeeds in creating an SOS, that player immediately";
cout<<"\t\ttakes another turn, and continues to do so until no SOS can be"<<endl;
cout<<"\t\tcreated on their turn. Otherwise turns alternate between players ";
cout<<"\t\tafter each move."<<endl<<endl;
contGame(); //PUPUNTA SIYA KAY CONTGAME
}

void gameinfo()
{
cout<<" "<<endl<<endl;
cout<<"\tSOS is a (usually two-player but may be more) game played with "<<endl;
cout<<"\tpaper and pencil,typically played by children. "<<endl;
cout<<"\tIt is similar to tic-tac-toe but with more complexity. "<<endl;
cout<<"\tBefore play begins, a grid of n × n squares (with n being 3 or more)"<<endl;
cout<<"\tis drawn. The first player to move "<<endl;
cout<<"\t(which can be chosen by, e.g., a coin toss) writes either "<<endl;
cout<<"\tS or O in one of the squares, whereupon it becomes the "<<endl;
cout<<"\tsecond player's turn. The second player has "<<endl;
cout<<"\tthe option of writing an S or O in an empty square."<<endl<<endl;
cout<<"\t\tby: http://en.wikipedia.org/wiki/SOS_(game) "<<endl<<endl;
contGame();
}
void contGame()
{
char cont;
cout<<endl;
cout<<"\t\t\tDo You Want To Proceed To The Game [y/n]: ";
cin>>cont;
//KAPAG Y, PUNTA NA SIYA AGAD KAY GAMEPLAY
if(cont=='y' || cont=='Y')
{
system("cls");
gamePlay();
}

else if(cont=='n' || cont=='N')
{
system("cls");
main();
}

else
{
cout<<"\t\t\t\t Invalid Input"<<endl;
contGame();
}
}

void GameEx()
{


cout<<"\t\t\t|===========|===========|===========| "<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<"S"<<" | "<<array[1]<<" | "<<array[2]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========| "<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[3]<<" | "<<"O"<<" | "<<array[5]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========| "<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[6]<<" | "<<array[7]<<" | "<<array[8]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========| "<<endl;
cout<<endl;


}

void ExOne()
{


cout<<"\t\t\t|===========|===========|===========| "<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<"S"<<" | "<<array[1]<<" | "<<array[2]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========| "<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[3]<<" | "<<"O"<<" | "<<array[5]<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========| "<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t| "<<array[6]<<" | "<<array[7]<<" | "<<"S"<<" |"<<endl;
cout<<"\t\t\t| | | |"<<endl;
cout<<"\t\t\t|===========|===========|===========| "<<endl;
cout<<endl;

}

void overnum(){
cout<<"Please choose numbers 1 to 24 only!"<<endl;
}
void occupated(){
cout<< "That block is already taken, choose another one!"<<endl;
}

void playerone(){
int x,z;
cout<<"Player 1, please choose a block number: ";
cin>>x;
cout<<endl;
system("cls");
table();
z=1;
while(z==1){
if (x<1||x>24){overnum();playerone();}
if (array[x-1]=='S'||array[x-1]=='O'){
occupated();
playerone();
}
else {
z=0;
array[x-1]='S';}
wincheck();
}


}

void playertwo(){
int x,z;
cout<<"Player 2, please choose a block number: ";
cin>>x;
cout<<endl;
system("cls");
table();
z=1;
while(z==1){
if (x<1||x>24){overnum();playertwo();}
if (array[x-1]=='S'||array[x-1]=='O'){
occupated();
playertwo();
}
else
{
z=0;
array[x-1]='O';
}
wincheck1();
}
}



void wincheck(){

if (array[21]=='S'&& array[22]=='O'&&array[23]=='S' || array[3]=='S'&& array[4]=='O'&&array[5]=='S'){
player1score++;
}
else {system("cls");table();playertwo();}
}

void wincheck1(){

if (array[21]=='S'&& array[22]=='O'&&array[23]=='S' || array[3]=='S'&& array[4]=='O'&&array[5]=='S'){
player1score++;
}
else {system("cls");table();playerone();}
}
]
Topic archived. No new replies allowed.