Play SIMON on your Internet Button!

First of all, let me tell you that I did not write the code for this game - but I would like to share how I found it, for anyone looking to jump right into playing with their Internet Button.

First of all, you need to get unboxed & connected. ([Instructions][1])
Log into WebIDE and get familiar with the interface. ([Instructions][2])
Go to Libraries, and in the search field under Community Libraries, search for SIMON. One result should show up, called SIMON. (Surprise!)
Click on SIMON.
Click the USE THIS EXAMPLE button. You can then title your game, save the code, or flash your device with it!

After you have completed the above, check out some of the inner workings:
Start from the Code tab in WebIDE. Click “Game” or whatever you titled your SIMON app.
Listed under Included Libraries, you should see SIMON. Click on that.
Then under Files, you should see Game.cpp, Simon.cpp and Simon.h.
In Simon.cpp, starting at line 82, you’ll see an interesting setting correlating the button you push to start the game, and the difficulty of the game.

void Simon::ready() {
    Position read = anyButtonOn();
    
    switch (read) {
        case None:
            return;
        case Top:
            difficulty = 4;
            break;
        case Right:
            difficulty = 9;
            break;
        case Bottom:
            difficulty = 14;
            break;
        case Left:
            difficulty = 29;
            break;
    }
    celebrate();
}

Time to celebrate! :smile:
[1]: https://docs.particle.io/guide/getting-started/button/photon/
[2]: https://docs.particle.io/guide/getting-started/build/photon/

6 Likes

this is amazing!!!

Awesome! We need more Button-based games!

2 Likes