The Reflex Game is a two player game played through the Arduino Iot cloud. One player is on the carrier and the other is on the Iot cloud. For rules and how to play go to "play".
Starting up:When you turn on the carrier it should look like this:
That means it’s trying to connect to your network. Make sure you enter your WiFi name and password correctly otherwise it will not connect.
When it is connected to the arduino IoT cloud it should look like this:
Button 0 toggles sound off and on and you can look at the rules on button 4. For the cloud player you need to type “rules” on the chat box. To start, press button 2.
Start playing:When button 2 is pressed you then have to wait for the cloud player to type “ready” to start.
Play:On the first round the carrier player must press button 0, 1, 3, and 4 ten times and the cloud player must press the according buttons.
It should look like this for the cloud player:
After ten rounds the interval will turn on. It should look like this:
When the interval ends it should look like this:
After the interval the game is in reverse; the cloud player must press the buttons ten times. This times how long the carrier player takes to press the equivalent buttons.
Ending:When the game ends you can either: win, loose, or in some very rare cases (or if you try and simulate it) a draw, it should look like this:
To setup the controls for the cloud player you must create a new cloud thing, call it whatever you want, eg: the Reflex game, and the following variables:
- DownB; read/write
- UpB; read/write
- LeftB; read/write
- RightB; read/write
- Down; read only
- Up; read only
- Left; read only
- Right; read only
- texts; read/write
Then, plug in the code at the bottom of the page then create a new dashboard. Call it something; eg: PINEAPPLES, then positon all of the buttons, status leds, and chat box. There are two options; a desktop/laptop version and a phone/tablet version. Here are both:
Then the setup will be complete. Now you can play!
Code explanation:So in short, every time the player who is in charge of pressing the buttons (in round 1 it’s the carrier player, round 2 it’s the cloud player) 1 will be added to an integer variable called countRound. When it gets to ten, it turns the boolean round1 to false and gameInterval to true.
That disables the code that runs round 1 while enabling the interval. When the interval gets to 0 gameInterval gets set to false which allows round 2 to start.
To time how long it takes between a player activacting a button and the other player deactivating it, you use the millis() function.
There is an unsigned long called stopWatchStart which saves the timing of when the button was activated and stores it. Then when it is deactivated by the other player there is another unsigned long called stopWatch which saves the time of when the button was deactivated and adds it to the players time like this:player1Time
=
stopWatchStart
-=
stopWatch
or player2Time
=
stopWatchStart
-=
stopWatch
for player 2.
And that is the core structure of the program explained. Okay it wasn’t that short but that’s the shortest I can do. Look at the full code to find out how it works in depth.
Summary:And that is The Reflex Game! I hope you will like it.
Please tell me if you find a bug or if you have any suggestions.
Oh and comment if you find and complete the secret🤔🤔
Comments