This week, I took a look at a bunch of other Storyline 2 Memory games that were available online, and all of these card-flipping games left me longing for Simon.
Everyone who was born in the 70s or 80s knows how awesome the game Simon was. The anticipation of the crazy pattern alone was enough to drive you crazy, and Simon gave immediate feedback, which sometimes was soul-crushing when you were incorrect.
Creating the buttons was easy. Thinking through the logistics of how to make it work was not so easy. I contemplated using a million layers (blah). It could have worked, but it was a workaround (boo). I toyed around with the possibility of using true/false variables, but this only really worked when I used two colors (one time each: blue, yellow).
I knew it was a matter of assigning numerical values to actions, but all I could think was this was going to turn into a crazy mathematical sequence from high school algebra or something. You remember…
5 (+3), 8 (+3), 11 (+3), 14 (+3)…
I also knew that I couldn’t have the value of any two clicks equal the same number. For instance, if the pattern was blue (+1), yellow (+1), I needed the computer to know that the person clicked blue, not yellow. With the same values assigned to both, this wouldn’t work.
I also knew that I might want the pattern to contain two of the same color in a row, so counting userClicks became important.
I actually have to give it up to my husband who mentioned prime numbers, and I tried that out…tada! It worked. Let’s explore how and why (for the first light pattern: blue then yellow).
First I created two variables, clickNumber and sumTotal.
clickNumber = how many times the person has clicked
sumTotal = each colored button has a value assigned to it, and when you click on a button, it adds the value of the button
- blue = 1
- yellow = 3
- green = 5
- red = 7
Setting Variables to Zero
Then on the slide, you have to set the variables to equal 0 at the start of the slide so the math is done properly and matches up with your values later.
Officially Assigning a Value to Each Color
Now, I said above that each color has a number associated to it. You actually have to create the number values as triggers.
When the user clicks blue, add 1 to the clickNumber (you clicked one time).
When the user click blue, add 1 to the sumTotal. (1 = blue).
For the first click (which is blue), the variable will have +1 added to it because blue = +1.
Notice above that each color has a different sumTotal associated with the color. G(reen) = 5, R(ed) = 7…yadda yadda.
Associating the Incorrect Response to an Incorrect Click
If you remember, Simon doesn’t reward you for tapping each correct button. It just keeps moving onto more difficult patterns if you press the easier patterns correctly. However, it does let you know when you are incorrect!
I made an incorrect layer that redirects you to the lights pattern again, and I also made a correct layer (for when you are finished the whole correct pattern, i.e., press blue then press yellow…correct!). Whenever the number of clicks doesn’t match up to the value it’s supposed to, the incorrect layer will display.
You can see in the trigger below that if the first click (clickNumber = 1) adds a value to the sumTotal that is NOT equal to 1, it will show the Incorrect layer; this means the player must have clicked another button (besides blue) since yellow, green, or red are not equal to +1.
On the second click (which is supposed to be yellow), the user should technically have these values:
- sumTotal = 1 (from blue) + 3 (from yellow) = 4
- clickNumber = 1 (from blue) + 1 (from yellow) = 2 total clicks
So we set up a trigger to show the Incorrect layer if the second click (clickNumber = 2) adds a value to the sumTotal which makes the sumTotal NOT equal to 4, it will show the Incorrect layer.
Associating the Correct Response to User Behavior
If you’ve followed the pattern correctly (blue then yellow), you will be automatically taken to the next “level” with a more difficult pattern.
So you need to show the Correct layer when the sumTotal variable changes and becomes correct, 4 (because 1 [blue] + 3 [yellow] = 4). This total of 4 should only happen with 2 clicks (so the clickNumber is equal to 2).
Making More Difficult Patterns
And for more difficult patterns, you add more of the Associating the Incorrect Response to an Incorrect Click steps. For example, if on the 3rd click you wanted the user to press blue again, then you would add another Incorrect trigger that says:
- sumTotal not equal to 5 (1 [blue] + 3 [yellow] + 1 [blue]
- clickNumber equal to 3 (3rd click)
Check out the demo or download the .story file to take a closer look.
Also, feel free to download the button files to change the colors as you wish.
Memory Game Buttons by Lauren Franza is licensed under a Creative Commons Attribution 4.0 International License.