Hello everyone, I'm trying to make a simple C++ game but I came across with some problems which are giving me a hard time.
I'll post a portion of code so you can understand my 'problem' better.
Code:
void main()
{
char cord1('1');
char cord2('2');
char cord3('3');
char cord4('4');
char cord5('5');
char cord6('6');
char cord7('7');
char cord8('8');
char cord9(' ');
bool WinGame = true;
cout<<" " <<cord1 <<" | " <<cord2 <<" | " <<cord3 <<endl;
cout<<"-----+-----+-----" <<endl;
cout<<" " <<cord4 <<" | " <<cord5 <<" | " <<cord6 <<endl;
cout<<"-----+-----+-----" <<endl;
cout<<" " <<cord7 <<" | " <<cord8 <<" | " <<cord9 <<endl <<endl;
int Play;
cout<<"Wich piece do you wish to move?: ";
cin>>Play;
cin.ignore();
When the user inserts an integer from 1 to 8 (which are part of the game board), THAT integer is supposed to swap with the empty square.
Example:
1 | 2 | 3
4 | 5 | 6
7 | 8 |
Wich piece do you wish to move?: 1
| 2 | 3
4 | 5 | 6
7 | 8 | 1
I made some research and I know there is a "swap" function somewhat, I just don't know how to implement it (yet).
Thanks in advance, hope you can give me a hand.
PS. The code is NOT complete. It is just an example as to how I defined the slots of the game board