top of page
Quarantine-Medical-Disease.jpg

About Code Four's Project

There's a pandemic. If you're following all the rules set by medicine, you should be thoroughly bored out of your skull by now. This game was created in hopes of alleviating some of that boredom. 
This will be like no board game you've played before. Most of the time you have to do it all yourself: roll the dice, pick up a card, and read off every challenge and bicker about whether you completed it properly or on time. No more of that. With this game, we've created a computer will handle almost all of the annoying parts of board games for you! Forget where you were because your dog knocked the board around? The C++ program on your computer will remember. Wonder if you did the challenge right? Arduino and C++ will let you know! Not only will the computer aid you in your play, but this game will get you active! There are roughly 30 fitness challenges within this game ready to get your blood flowing after being stagnant inside for so long... So what are you waiting for? Go get your materials ready to play!

About Our Game: About

Our Problem Statement

After taking all the criteria discussed in the problem statement linked below into consideration, we came up with a game that we feel best meets them: Treehouse Toppers

About Our Game: Text
d2060a00-ac16-4c42-8fd5-08d536f5ac16_edited_edited_edited.jpg

About our electronics

          The electronics used in this project are pretty standard pieces used in many, many other projects. Let's start with what you'll need...

          The RedBoard and breadboard themselves, a couple long connecting wires, 3 buttons (one red, one blue, one yellow), a Piezo speaker, 4 LED's (One red, one green, one blue, one yellow), a USB cable, a photoresistor, 5 resistors, and a few short wires (like the ones you can see near the bottom of the breadboard, as you will see in the circuit diagram ).

          How to put all these pieces together in order to make the full product is explained in the "How to Build" page. All of these pieces when put together create the brains of our game.

          The buttons are what the player will press in order to begin 2 of the 3 games on the breadboard. These buttons are programmed by Arduino to activate the 2 games, which are memory and music challenge. For the "Hover" game, the red button is programmed so that if you press it, Arduino will take a reading of the voltage hitting the photoresistor. 

         The speaker is what allows the user to engage in the music challenge by playing a tune through it. It only has a small range of musical notes, and so if the melodies sound a little bit off, know this is the reason why. It is programmed by Arduino to output a specific song randomly selected by the program when the button corresponding to the music challenge is pressed (blue one).

         The LED's combined with the buttons are what allow the players to engage in the memory challenge. They will light up in a certain pattern, created at random each time by Arduino, when the button corresponding to the memory challenge is pressed (yellow one), as it was programmed this way. This pattern is a combination of the red, green, blue, and yellow colors displayed by these same LED colors. The player will interact with these lights and buttons as previously mentioned in order to complete the challenge.

The long wires are what connect the components of the breadboard with the ports on the RedBoard. This allows for the components to be programmed by Arduino, as the ports themselves are specified and programmed too. The wires also help provide electricity to the breadboard because it connects the 5V and GND pins with the power rails. The short wires connect the power rails to main section of the breadboard where all the components are. So together, all these wires is what make the components function by providing the electricity needed and the connection with the programmed ports. The resistors limits the flow of current so that way the LEDs do not burn out. 

The photoresistor takes readings in voltage of the amount of light hitting it. It takes readings constantly, but it only outputs them to the screen if the button corresponding to it is pressed (red one). The photoresistor is an important piece to our "Hover" game. It takes readings of the brightness hitting it and the program verifies if the condition for the level the player is currently on is met. More detail on this can be found in the "Challenges" section under the "How to Play" page.  

Finally, the USB cable is what allows the code to be downloaded to the RedBoard and run the game, as it connects the computer with the RedBoard and provides the electricity to power the game. Without the cable, none of the components get programmed and the game would not run!

         All of these pieces when combined in tandem are what allow for our game to be played, any piece in a missing spot will cause a failure, so if you are having issues please view the diagrams below carefully.

About Our Game: Text
cleaner-better-code-670x335.jpg

About our C++ Gameplay Program

The C++ program is used essentially as an interface that can keep track of the players’ locations on the game board while displaying what tasks players need to complete in order to win the game. It begins by allowing the user to input 3 player names and setting their starting spaces equal to 0 (which corresponds to the “Start” space on the game board).


The while loop then begins and much of the code is contained within this while loop, which has the condition that the players’ spaces are < 60 (60 is the final space on the gameboard). Player 1 is asked to type “1” and by doing so, a random number is generated between 1 and 6 which is outputted to the screen to serve as a dice roll. Player 1’s new space is then stored as Player 1’s old space added to the dice roll number. 


The program then checks if Player 1’s space is a number greater than 60. If so, the program returns Player 1 to their old space before the last dice roll. This serves as a way to disallow players to go past space 60, allowing victory only by landing on space 60 itself. If Player 1’s space is not a number greater than 60 after the dice roll, the program checks what “characteristics” may apply to the space they are on. 


First, the program checks if Player 1 is on a “Skip” space, which corresponds to spaces 8, 27, 38, and 49. The skip space causes the program to return Player 1 to their previous space before the dice roll that caused them to land on the skip space. Hence, the turn that is skipped is essentially their current turn, in which the player stays on the space they started their turn on instead of moving forward. This is how we went about defining what "skip" should mean in the context of our game.  

Second, the program checks if Player 1 is on a “JINX challenge” space, which corresponds to spaces 21 and 44. Player 1 is asked to type ‘2’ or ‘3’ to indicate which player they wish to challenge. Based on the results of the challenge, player 1 is then asked to type ‘1’ or ‘2’/’3’ (depending on who they challenged) to indicate which player won (1 if player 1 won, ‘2’ or ‘3’ if player 2 or player 3 won respectively). Whichever player wins has 4 added to their space number, and whichever player loses has 3 subtracted from their space number as rewards and punishments for winning or losing the challenge respectively. 


Third, the program checks if Player 1’s space leaves a remainder of 1 when divided by 4. If so, these spaces correspond to the “Hover” game. Based on the results of the game, Player 1 is asked to type ‘1’ if they won the game and ‘2’ if they lost the game. Winning the game allows Player 1’s space to remain as is. Losing the game causes Player 1’s space to be stored as Player 1’s old space before the dice roll causing them to land on the “Hover” game, meaning they go back to where they were at the start of their turn. 


Fourth, the program checks if Player 1’s space leaves a remainder of 2 when divided by 4. If so, these spaces correspond to the “Music” challenge. The program asks Player 1 to input the number of the song inputted to the Serial Monitor of the Arduino code. This number corresponds to a particular song that is played for Player 1 to hear and guess the name of. A void function “MusicSong” is used here which stores information about what song was played and outputs it to the screen. Player 1 is then asked to type ‘1’ if they won the game and ‘2’ if they lost the game. Winning the game allows Player 1’s space to remain as is. Losing the game causes Player 1’s space to be stored as Player 1’s old space before the dice roll causing them to land on the “Music” challenge, meaning they go back to where they were at the start of their turn. 


Fifth, the program checks if Player 1’s space leaves a remainder of 3 when divided by 4. If so, these spaces correspond to the “Memory” game. Based on the results of the game, Player 1 is asked to type ‘1’ if they won the game and ‘2’ if they lost the game. Winning the game allows Player 1’s space to remain as is. Losing the game causes Player 1’s space to be stored as Player 1’s old space before the dice roll causing them to land on the “Memory” game, meaning they go back to where they were at the start of their turn. 


Sixth, the program checks if Player 1’s space is divisible by 4. If so, these spaces correspond to the “Fitness” challenge. Based on the results of the game, Player 1 is asked to type ‘1’ if they won the game and ‘2’ if they lost the game. Losing the game causes Player 1’s space to be stored as Player 1’s old space before the dice roll causing them to land on the “Fitness” game, meaning they go back to where they were at the start of their turn. Winning the game causes the program to check a few more conditions. If Player 1’s space is 12, Player 1’s new space is stored as 16 to account for a slide on the gameboard at space 12. If Player 1’s space is 36, Player 1’s new space is stored as 39 to account for a crosswalk on the gameboard at space 36. If Player 1’s space is divisible by 4 but not 12 or 36, the program allows Player 1’s space to remain as is. 


Finally, the program checks if Player 1’s space is equal to 60. If so, the program outputs “Congrats Player 1, you have won the game!!!” and the game ends due to a return(0) that stops the loop and the entire program from continuing to run after outputting this statement. 


The aforementioned features of the program are repeated for Player 2, then for Player 3 within the loop. After Player 3's turn is complete, this marks the end of the loop, so it restarts again to run Player 1's turn as long as all of the players' spaces are < 60. 

About Our Game: Image
53b24c13-458e-4d25-aee1-79f623d49591_edited.jpg

Curious about our code?

If you want to know which parts of the code do what, click the button below for a more in depth discussion.

About Our Game: Text

Graphical Pseudo-Code

If you want to see how the C++ code works in a physical representation, here it is!

About Our Game: Text

Moving Along!

The code and instructions on how to put the electronics together can all be found on the next pages. Enjoy our game!

About Our Game: Text
  • Facebook
  • Twitter
  • LinkedIn

©2020 by Code Four's Project. Proudly created with Wix.com

bottom of page