Question: At the beginning of your game code include a welcome message and list the rules of the game using output functions so that the player

At the beginning of your game code include a welcome message and list the rules of the game using output functions so that the player understands how to play the game. Use the menu function to allow the player a moment to read the instructions and confirm they want to start playing the game. 2. You will need to create a looping structure around your entire game code (excluding the clear and clc at the top of your script file) to play the game until the user wants to stop. 3. Create the game play area using the pcolor, colormap, and set functions. Since these are functions not covered in the class, I will simply provide you the code below that you can copy and paste into your program (note that I am also using the figure function in a different way here to define the name of the Window and I am using the hold function to ensure that everything done after this will remain on the same plot/game play area): figure('Name','Matlab Memory Match') hold on X =[123; 123; 123]; Y = X'; mymap =[100; 010; 001; 110; 000]; C =[345; 125; 555]; pcolor(X,Y,C) colormap(mymap) set(gca,'XTick',[], 'YTick', [])4. I am not going to explicitly call out each instance of where you should use them, but you will need to add in pauses using the pause function to give the user/player time to see things throughout the game. Make sure you add these in and adjust them, as needed. 5. You will want to create a separate, nested loop structure (nested within the loop structure mentioned in step 2) that will keep the game going until the player does not guess the sequence correctly.
6. For this game, we have four squares representing four different color areas which can be selected by the program as part of a given sequence. These can be selected in any order and the same color (square) can be selected multiple times. You will want to generate a vector of sequence values for the first sequence to show the player. The first sequence must have three colors selected, one by one. I recommend using the randi function to generate a vector of pseudorandom integers (14, for the 4 different colors on the plot/play area). The length of this vector will initially be 3 and then it will increase by 1 for each subsequent sequence. The sequence will be different each time. 7. Then, for each element of that vector (consisting of pseudorandom numbers 14), you would want to show text in the center of that particular square which shows the name of the color using the text function. You can look in the Matlab documentation for information on using the text function to set the location where it will be displayed on the plot/play area, and the font size. You will also need to use the pause function here to give a small amount of time for the user/player to see the color before using the delete function to remove this text. You need to define which number (14) represents which square (this is up to you) and where exactly to place it. For each of the elements in the vector from the previous step, if it is a 1, you place it in one location with a specific label, if it is a 2, you place it in a different location with a different label, etc. 8. You will want to use the ginput function to collect clicks from the user/player. This function allows the user/player to click on the plot/game play area to make selections. The x and y coordinates of the clicks will be stored. Please see the function in the Matlab documentation for how to properly set up this function to store these values. You will initially want to allow 3 clicks, then 4, then 5, etc. The variable names that you choose to store your x values and y values in will be vectors. 9. Next, you will want to check to see if each selected location matches with the pseudorandomly generated locations shown to the user/player on the plot/game play area. For each location, in order, you could check to see if it is a 1,2,3, or 4, and then check to see if the location on the plot/game play area for the players guess matches the defined area for that color. Note that the GREEN area should be defined as a click with an X position greater than or equal to 2 and less than 3 and a Y position greater than or equal to 2 and less than 3. The RED area should be defined as a click with an X position greater than or equal to 1 and less than 2 and a Y position greater than or equal to 2 and less than 3. The BLUE area should be defined as a click with an X position greater than or equal to 1 and less than 2 and a Y position greater than or equal to 1 and less than 2. The YELLOW area should be defined as a click with an X position greater than or equal to 2 and less than 3 and a Y position greater than or equal to 1 and less than 2.10. If the conditions in the step above are met, you could increment a variable. Then, after going through the who

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!