Once we have our random countdown time figured out, the game logic is very simple:
- Turn off all of the NeoPixels.
- Wait the determined countdown time.
- If a player presses a button during this time, they drew too soon (misdraw).
- Once countdown time has elapsed, turn on all of the NeoPixels.
- Look for the first (quickest) button press.
- Which ever button was pressed first is the Quick Draw winner.
This is pretty straight forward. We've got two players, we've got two buttons. So we can assign them as shown in the figure below.
This could be anything, but to keep it simple we'll just turn on all the NeoPixels to white when the countdown completes.
When all of the lights come on (all white), press your button as fast as you can.
We can use the NeoPixels on the left to indicate Player 1's outcome, and the NeoPixels on the right to indicate Player 2's outcome. There are two possible outcomes: a misdraw if a player draws too soon, or a game with a winning outcome.
PLAYER 1 MISDRAW!
If all of the lights on the Player 1 side turn red, Player 1 misdrew (pressed the button too soon).
PLAYER 2 MISDRAW!
If all of the lights on the Player 2 side turn red, Player 2 misdrew (pressed the button too soon).
PLAYER 1 WON!
If all of the lights on the Player 1 side turn green, Player 1 was the quickest.
PLAYER 2 WON!
If all of the lights on the Player 2 side turn green, Player 2 was the quickest.