We have provided 2 demonstration games. We wanted something very simple that would illustrate how the TwoPlayerGame engine works so we implemented a simple "Tic-Tac-Toe" game. Then to really illustrate the power of the system, we implemented a classic game of "Battleship".

The PyGamer display alternates between a view of your ships and a radar screen of your enemy territory. You select a location on a 10 x 10 grid and fire a shot. The other device will send a signal back telling you if it was a "hit" or "miss". There are added sound effects for this game including cannon fire, hit and miss sound effects, and voice clips saying such things as "You stank my battleship". There is a third demonstration game myDemoDebug.ino that we used during the development of the game engine that is completely text-based. It transmits messages back and forth and displays the results on the serial monitor as well as taking input from the serial monitor. It could be a useful starting point for creating your own games.

Uploading Games

You will have to make a slight modification to the software before uploading it to your two devices.

On any of our games at the top of the main page you will see the following line:

Download: file
#define IS_PLAYER_1 true

You should compile and upload the game to one of your devices with that definition true. Then then modify it to read false and upload it to the other device. This single #define statement is the only difference between the software on the two devices. It sets up addresses for the packet radio system so that the radios can talk to one another. If you don't make this modification then they both try to communicate as address "1". If you make the change them one of them will have address "1" and the other address "2".

Basic Game Play Procedures

All of our demonstration games and likely any game created for this system will have a basic standard flow of the game as follows.

When you first power on your device or press reset or upload the code, you will see an opening splash screen and then your device will begin transmitting a signal offering a game to another device. After a few seconds if it does not find anyone to take its offer, then it goes into seeking mode which means it's seeking an invitation from another device. It will stay in that mode until it finds an offer or you press reset to start over.

If you turn on or reset both devices simultaneously, it's likely that they would both be offering at the same time and neither one would be accepting. So you and your game partner will have to ensure that you start the system one or two seconds apart from each other.

Once the connection has been made, the offering device will perform a virtual coin toss to decide who goes first. Both devices will be informed of the results of the toss and gameplay will continue from there. The winner of the toss will make a selection by moving the cursor around using the joystick and then will select a location using the "Select" button. Your move will be transmitted to the other device, the results of that move if any will be transmitted back to you and then the other player will take their turn.

Accessibility Features

As a result of my disability I'm unable to operate the joystick or push buttons on the PyGamer or PyBadge devices. Therefore I implemented an alternative input method. In both battleship.h and tictactoe.h look for the definition…

Download: file
#define ACCESSIBLE_INPUT false

If you edit this to true, the program will use an extended version of the Adafruit_Arcada_Library that allows simulation of the joystick and button pushes by typing commands into the serial monitor. You can enter "U", "D", "L", or "R" for moving the joystick Up, Down, Left, or Right respectively. Entering "A" or "B" simulates pressing those buttons. Entering "E" for "enter" simulates the "Select" button while "S" simulates the "Start" button. The letters may be either upper or lower case. You will have to type the command letter and press Enter on your keyboard after each command.

All of the development and testing on the software was accomplished using this alternate accessible implement methods. Able-bodied friends also tested the games for me using traditional input.

This guide was first published on Jul 07, 2020. It was last updated on Jul 07, 2020.
This page (Demonstration Games) was last updated on Sep 26, 2020.