Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Number and types of inputs: 4 capacitive touch pads 2. How long will the starting sequence be: 2 lights 3. Describe how your

   

1. Number and types of inputs: 4 capacitive touch pads 2. How long will the starting sequence be: 2 lights 3. Describe how your game will show the sequence to the player: show a light to the players 4. Describe what it means for the player to "win" the game: the player is able to recall the colors/ lights 10 times 5. Give your game a name: Flashing Lights 6. Two verification procedures that explain how to test your game to ensure it works properly. One should be for a player that "wins" and the other for a player that "loses". These are instructions for the human player, not for the computer: The player is to touch the touch pads in the order that the lights flashed. If done correctly, another light is added to the sequence. If done incorrectly, all lights flash red. If done correctly all the way to pattern 10, a victory sound plays. 7. Write out the steps of the computer program in a Word document using plain language. For example: "make sound #1" or "check if user guess and current sequence value are the same". This is called pseudocode. These are instructions for the computer: display pattern #1 (flash light 1 blue, then flash light 2 yellow), check if user guess and current pattern is the same, display pattern #2 (flash light 1 blue, then flash light 2 yellow, then flash light 3 red), check if user guess and current pattern is the same... (all the way to pattern #10) a-g is based off the bolded info in 1-7 a. On start, create a variable called sequence and set it equal to an empty array. Create a function called addValue that (1) adds a random number to the end of sequence and (2) writes sequence to the console. Each number should represent an input for your game. For the Simon game, this might be 1=blue, 2=yellow, 3=red, and 4=green. Test the function. b. Modify the code so it uses addValue to generate the starting sequence for your game. c. Write a function called showValue that accepts a number as a parameter and shows this input to the user. For the Simon game, if the parameter was num=1, then the function would light the blue button and play sound #1. If the parameter was num=2, then the function would light the yellow button and play sound #2. Test the function. d. Write a function called showAll that uses your showValue function to show the player the current sequence. If the Simon game sequence was "1, 3, 4" then it would light the blue, then red, then green buttons and play the corresponding sounds. Call this function after you create the sequence. e. Now you will start to write the code that "reads" the player's guesses. For each of your game's inputs, create an event that calls the showValue function. For the Simon game, this would light the blue button and play sound #1 when the user pressed the blue button. f. Now that you can "read" the guess, you need to compare it to the sequence. The variable sequence is an array with indices 0, 1, 2, ..., length-1. If the Simon sequence was "1, 3, 4", then index 0 of the sequence would be "1", index 1 would be "3", and index 2 would be "4". The total length of the sequence is 3. To track where we are in the sequence, we will use a variable called sequencelndex. i. Set the sequencelndex variable to 0 (zero) at the end of your showAll function. ii. Create a function called checkGuess that accepts a number as a parameter. The parameter will represent the input that the user guessed. For the Simon game, if the user guesses the blue button, the parameter would be 1. Use this new checkGuess function to compare the user guess (input parameter) to the correct value (value stored in the sequence variable at the sequencelndex index). 1. If they match, write "CORRECT!" to the console and increase the value of sequencelndex by 1 (one). The program is now ready to accept a guess for the next value in the sequence. 2. If they do not match, write "WRONG!" to the console. Communicate to the user that they lost the game, then set sequence to an empty array. g. Now, modify the checkGuess function to check if the player completed the sequence. If they did, make the sequence longer and show the user the new sequence (hint: you already wrote this code).

Step by Step Solution

3.50 Rating (163 Votes )

There are 3 Steps involved in it

Step: 1

Lets break down the problem step by step and provide explanations for each part a On start Create an empty array called sequence Define a function called addValue that Generates a random number repres... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microeconomics An Intuitive Approach with Calculus

Authors: Thomas Nechyba

1st edition

538453257, 978-0538453257

More Books

Students also viewed these Programming questions

Question

4-2. What items are typically included in the job description?

Answered: 1 week ago