Microsoft MakeCode

Simon Says Help!

I am trying to figure a way out to make a Simon Says game on the CPX using blocks. I want to divide pixels into 4 sections, one for each of the colors (0-2 = red, 2-4 = blue, 5-7 = yellow, 7-9 = green), but I cannot figure a way to do that.

What I have is a way to add to the pattern and how to show the pattern (maybe).

Adafruit has an example of a code https://learn.adafruit.com/simon-game-clone-with-circuitplayground-express-and-circuitpython/light-design but I figure out how to translate to blocks.

Here is what I have so far:

Thank you in advance for any help!

Ooh! You’re giving me an excuse to dig out my Circuit Playground Express! Nice! Now, where did I put that thing…

Stay tuned! :smile:

1 Like

So, I used a simpler way to activate the LEDs using show ring. Feel free to alter the colors to your liking; I used the colors and locations used in the Adafruit article that you mentioned. Yes, you could do the same thing with a bit of math, but this just feels like it fits better with the Blocks environment.

1 Like

Now, we can handle the touch sensors. I added a variable, acceptInput, which is checked before the touch is processed. Right now, acceptInput is simply set to true. You don’t always want to be accepting input during the game, though, so we’ll need a way to ignore player input later.

Here’s how I did it:

Because we’ve assigned each color a number, when you’re building Simon’s sequence and accepting player input, you just need to use the numbers 1 through 4 instead of trying to create an array of colors or light patterns.

I’ll stop here for now so that you can give it a go. Good luck!

1 Like

So I was stuck on trying to have the player input the entire sequence before comparing it with the game sequence. Is there a way to the compare the values of two arrays using blocks? Eventually realized you have to check after every button press.

Here it is:

1 Like

YES! Good work!