Simon Says - Follow me!

Index

Stats

2,141 visits, 5,139 views

Translations

This tutorial hasn't been translated.

Tools

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

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