Simon Says - Follow me!

2

Index

Stats

5,881 visits, 12,236 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 1 Jan, 2012. Last updated 19 Feb, 2019

Let Simon speak

Now that simons string is prepared, we want it to presented to the user. This is done by the following event:

Please note, that the event is called every second - you could change that value to speed up the playback.

It only gets executed if the repeatflag is set to one and the loopcounter is under the value of the string length of simonSays (Rember? This is the string holding all the buttons/notes played by simon)

The actual play back is done by this function call:

Here we take advantage of the fact, that we can use the call function with a string, that represents the name of the subroutine.

So we append the string play with one of the four values "Red", "Blue", "Green" or "Yellow" by looking it up in the array.

To get the right array cell, we need to Know the value of the last "word" simon said. the is done by calling

int( tokenat (simonSays, loop, ""))

This returns an integer, that represents the character that will be found at the loopth place (starting with 0) within the simonSays* string.

For example: If simonSays looks like this "0023141" and loop is set to 4, the integer that is returned is 1.

The second cell within our array holds the value "Red", so the function we will call is playRed.

Please note, that within the next event, we will set the repeatflag and the loopvalue back to zero. Stopping the eventcalling.

  • 0 Comments

Want to leave a comment? Login or Register an account!