Memory matching game in c++

SoccerBoss
Category:
Programming
Price: $5 USD

Question description

Hi, I need help with this memory matching game that I am trying to program. here are the instructions:


Select a Theme and have 50 words associated with it:

 Words must have a common theme - your choice

Examples: Like Periodic Table Elements, or Sports teams, or Types of cars…

Max number characters in each word is eight(8)

Have one Term describing category/theme you picked. This is the FACE term…

Menu:

Start Options

·  New Game Option

·  Exit Game Option

Level of Play – Use selects at start of game

  4 x 4 grid (Easy)

  6 x 6 grid (Moderate)

  8 X 8 grid (Difficult)

Speed  of Play – At start of game, User selects time interval for clicked-on term-pair to display

  1 seconds  (Difficult)

  3 seconds (Moderate)

  5 seconds (Easy)

Populate Grid with Term

  At start of game – program places the same face/theme term in all squares in the visible grid

If 4 x 4 grid, randomly pick 8 terms, place each image name twice in 2-Dim array.

If 6 x 6 grid, randomly pick 18 terns, place each image name twice in 2-Dim array.

If 8 x 8 grid, randomly pick 32 terms, place each image name twice in 2-Dim array.

The 2-Dim Array corresponds to grid on screen.

During the course of play, the face/theme term in the grid is replaced by a

  corresponding array  terms,  when user selects a grid square

Game Play

1)  User selects a FIRST square, the theme/face term  in the grid square is replace with correspond stored term, from the 2-dim array

2)  User selects a SECOND square, the term theme/face in the second grid square is replace with the corresponding stored term, from the 2-dim array

3)  The computer compares the terms for the two selected squares.

If they are the same, the terms remain on the screen and can no longer be selected.

If they are different, the term remain the screen for 1, 3 or 5 seconds, depending on user selection at the beginning of the game.  After that elapse time, those two grid terms are replaced with the face/theme term.

I'm not entirely sure how to make the gameboard itself or how to double the 50 words and randomize them.

And here is my code so far:

#include <string>

#include <ctime>

#include <cstdlib>

#include <iostream>

#include <algorithm>

#include <iomanip>

using namespace std;

void gridEasy(void);

void randomizeTheme(string theme[]);

int main()

{

string theme[16] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p" };

int playGame;

int grid;

bool firstRun = true;

cout << "Would you like to play a memory matching game?" << endl;

cout << "press 1 to play, press 0 to exit" << endl;

cin >> playGame;

if (playGame == 1)//if the player wants to play the game, run this line of code

{

cout << "Please choose your grid: " << endl << endl;

cout << "1. 4 x 4 grid (Easy)" << endl;

cout << "2. 6 x 6 grid (Medium)" << endl;

cout << "3. 8 x 8 grid (Hard)" << endl << endl;

cin >> grid;

}

else if (playGame == 0) {//if the player wants to exit, run this line of code

return 0;

}

else{

return 0;

}

if (grid == 1)

{

return 16;

}

else if (grid == 2)

{

return 32;

}

else if (grid == 3)

{

return 64;

}

else

{

do

{

cout << "Please choose your grid: " << endl << endl;

cout << "1. 4 x 4 grid (Easy)" << endl;

cout << "2. 6 x 6 grid (Medium)" << endl;

cout << "3. 8 x 8 grid (Hard)" << endl << endl;

if (!firstRun)

{

system("CLS");

cout << "Not a correct response, please try again." << endl;

cin.clear();

cin.ignore(INT_MAX, '\n');

}

firstRun = false;

} while (!(cin >> grid));

gridEasy();

srand(time(0));

randomizeTheme(theme);

for (int i = 0; i < 16; i++)

{

cout << theme[i] << endl;

}

system("Pause");

return 0;

}

}

void gridEasy(void)

{

for (int r = 0; r < 4; r++)

{

for (int c = 0; c < 4; c++)

{

cout << "-----------------------------" << endl;

cout << "|" << setw(9) << r + 1 << setw(9) << "|" << endl;

cout << "-----------------------------" << endl;

}

}

cout << "--------------------------------------------------------------------------------";

}

void randomizeTheme(string theme[])

{

random_shuffle(theme, theme + 16);

}


Tutor Answer

(Top Tutor) Daniel C.
(997)
School: Boston College
PREMIUM TUTOR
Studypool has helped 1,244,100 students
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1830 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors