I am a newbie and have been working on this project for several days. I have received help thus far from Dani and it's been fruitful.
The project entails a "memory matching" game with 16 cards, labeled 1-8 in pairs. The cards are "shuffled" and placed face down on a table--User inputs choices for 2 cards (based on x-y coordinates) and those 2 choices are "flipped" up. If they are a match, they stay up, if not, they must be "pushed" off the board with ****. Game continues until all cards are up. I am at the outputting asterisks stage, and don't quite know how to proceed. The project also formats the "table" with 1-4 and dashes "around" the x and y so that the player can "see" coordinates to choose from. I have most of my display doing that, except I can't seem to get the 1-4 to correspond appropriately on the x axis. If I could get the table formatted properly, and have my "cards" face down (****), then I could move on to my conditionals and random for "shuffling." Thank you for an help
#include <iostream>
using namespace std;
int card_face[4][4];
int card_value[4][4];
int fill_values();
int card_defacer();
int show_grid();
int main(){
fill_values();
card_defacer();
show_grid();
}
int fill_values() //Defining Function establishes 16 cards with paired numbers from 1-8
{
card_value[0][0]=1;
card_value[0][1]=2;
card_value[0][2]=3;
card_value[0][3]=4;
card_value[1][0]=5;
card_value[1][1]=6;
card_value[1][2]=7;
card_value[1][3]=8;
card_value[2][0]=1;
card_value[2][1]=2;
card_value[2][2]=3;
card_value[2][3]=4;
card_value[3][0]=5;
card_value[3][1]=6;
card_value[3][2]=7;
card_value[3][3]=8;
return 0;
}
int card_defacer()
{
for(int x = 0; x < 4; x++)
for(int y = 0; y < 4; y++)
card_face[x][y]=0;
return 0;
}
int show_grid()// Function that will show the "playing table" and output values of only "pairs" other values will be "*******"
{
// cout << "USER enter a coordinate choice for your card: " << endl; //these are only ideas
// cin >> choice1;
// cout << User, enter your second choice: " << endl;
// cin >> choice2;
cout<<" " << "1 2 3 4 " << endl; //this 1-4 works and lays over (y)
cout <<" " <<"-------------------------"<< endl; // 1-4 indicators separated from table
cout << endl;
cout <<endl;
cout <<"|1";// not placing the number in the right place - causes first horizontal of card_value to indent
//cout<<"1"<<"|"<<endl;
for(int x = 0; x < 4; x++){
for (int y = 0; y < 4; y++){
cout <<" "<< card_value[x][y]<< " ";
}
cout << endl;
cout << endl;
}
return 0;
}