Products for USB Sensing and Control
Products for USB Sensing and Control

Phidgets, Pong, & Processing

Getting Started Kit and Game Design

Beginner
by Phidgets Education

Introduction

Pong is a classic game that consists of two paddles, some walls and a scoring system. In this project, you will modify a game of Pong to incorporate the Getting Started Kit.

Prerequisites

This project assumes are familar with Processing and you have completed the following guides:

Goal

By the end of this tutorial, you should have a functioning single player Pong game implemented in Processing.

Parts Inventory



Hardware

All that is required for this project is connecting your Getting Started Kit to your computer.



Software

Download Base Project

This project builds off of Coding Challenge #67: Pong! by Daniel Shiffman. You can find the project through GitHub or download it here.

Add Libraries and Experiment

After downloading the project, open the Processing project named CC_067_Pong.

Click on Sketch > Import Library ...

Enter Sound in the search box and install the Sound Library (author is The Processing Foundation).

After installing, you will see a green checkmark.

Next, import the Phidget libaries. If you forget how, go back to the Processing and Phidgets Tutorial.

Finally, try running the program and experimenting. The left paddle uses the keys A and Z to move. The right paddle uses J and M.

Modify Project

Open the project and identify the spot where keyboard presses are being intercepted and used. You'll notice that the paddle moves when a key is pressed and the paddle stops when it is released.

You can recreate this movement in one of the paddles with the Getting Started Kit.

All of the Phidgets code required can be added to your setup method.

Your Phidgets code should have the following flow.

.

Remember to close your Phidget Objects.

.

Next Steps

After getting your paddle working, try the following:

  • Work with a teammate and add another Getting Started Kit to the program.
    • When using two VINT Hubs in the same program, make sure to set the Device Serial Number of your Phidget objects.
  • Pong AI - write code so that the right paddle plays against you. Try adding different difficulty levels that the user can select.
  • Use a different Phidget to control the paddle. For example, the Slider 60 Phidget.

Conclusion

There are many more applications of the Get Started Kit and Phidgets. Have you created something from your Get Started Kit? We would love to hear about it at education@phidgets.com