Exercise: Handheld Game in Tinkercad

In the 1970s new microprocessors and digital logic enabled a generation of handheld electronic games before the advent of microprocessors powerful enough to operate LCD matrix displays. Some examples: Milton Bradley Simon, Parker Brothers Merlin, Mattel Football.

Tinkercad lacks mechanical hardware but has enough electronic I/O components to support creating simple electronic games. This exercise will explore all aspects of game development, including game design, circuit design, software design and implementation, and playtesting.

One strong hint: please start with a well-defined, simple game idea. It is easier to elaborate a working design than start with complexity.

As a reference, I have provided a complete working code and circuit sample, please see RockPaperScissors Arduino Sketch.

Objectives

After this exercise, you should be able to:

  1. Design a simple real-time handheld game.

  2. Implement low-latency processing of asynchronous inputs and events using event-loop and state machine structures.

  3. Write code using parameterized functions to implement action primitives.

  4. Write code with integrated debugging using the serial port for user console communication.

Reference Guides

Please review the following reference guides as needed:

Creative Constraints and Opportunities

  1. You may use any components available in Tinkercad. However, you are strongly encouraged to start with the components we have already encountered: pushbuttons, slide switches, hobby servos, LEDs, and piezo speakers.

  2. Please think in terms of tangible game experience. Yes, there is an LCD display component, but a purely text-based game misses the point.

  3. Please remember games may be real-time or turn-based. In either case, timing and pacing are important elements of game design.

  4. Scorekeeping is optional.

  5. The game should be single-player, either a solitaire puzzle or against an active computer opponent.

  6. Alas, there is no coin acceptor component.

Steps and observations

The overall objective is to create a interactive game. The following checklist will guide you through building a circuit and program to submit within a single Tinkercad sketch.

  1. Please start with by choosing a game concept. A clear idea at the beginning will focus the rest of the work. It’s fine to adopt or adapt an existing game idea.

  2. Plan out the essential features in advance: game play sequence, user inputs, visible and audible outputs.

  3. Construct a circuit with the input and output components as per your design. Be sure to remember to use pullup resistors on your switches and ballast resistors on your LEDs.

  4. Set up the shell of a text-based Arduino program to support your hardware, e.g. initialize the Serial port, initialize the output pins.

  5. Add temporary code to test your inputs and outputs. At this stage it is helpful just to print values to the Serial port.

  6. Set up the essential run loop. I suggest using a real-time event polling loop as I have provided in the sample, it is a versatile structure. But some games may only require a scripted sequence; for these I recommend looking at the cond_delay() function in the Lecture Sample Code, it provides a suggestion for incorporating low-latency polling into a scripted sequence.

  7. Incrementally add the game logic, testing at each step. Please add debugging output to the Serial Monitor as needed.

  8. Please be sure to include user instructions in comments at the top of your code.

Deliverables

The result of your explorations should include:

  1. a single circuit sketch including code, submitted as a URL to Canvas

  2. a brief paragraph describing your game intent and outcome, submitted as text to Canvas

When it is time to submit your result for the assignment, you’ll need to click Share, then Invite people. You may then copy the generated sharing URL and submit it to Canvas.

N.B. As of Fall 2020, Tinkercad has a sharing bug, please note the following. Tinkercad Circuits sketch sharing links which include the term ‘tenant=circuits’ appear consistently to return a 404 error instead of accessing the sketch. The first workaround appears to be to exit and reload the sketch at least once before generating the share link. Alternatively, an existing link can be fixed by editing out the tenant=circuits clause, e.g. delete the text ‘?tenant=circuits’.

Challenges

If you would like to explore more, please consider the following optional challenge questions.

  1. Try adding an ‘attract mode’ to garner attention between plays.

  2. What’s the most subtle way for the computer to cheat?

  3. Could you have implemented your game purely in circuit logic without the Arduino?