6. Chapter Pong Game

We have experienced single-player game snake before. Now, let’s use control board to play classic two-player pong game. You will experience both 2D and 3D version.

6.1. Project 6.1 Pong Game

First, let’s experience the 2D version game.

6.1.1. Component list

Control board x1

Chapter01_00

Breadboard x1

Chapter02_00

GPIO Extension Board x1

Chapter02_01

USB cable x1

Chapter01_02

Jumper M/M x3

Chapter01_03

Rotary potentiometer x2

Chapter08_00

6.1.2. Circuit

Use A0, A1 ports on connect board to detect the voltage of rotary potentiometers.

Schematic diagram

Chapter6_00

Hardware connection

If you need any support, please feel free to contact us via: support@freenove.com

Chapter6_01

6.1.3. Sketch

6.1.3.1. Sketch Pong_Game

Use Processing to open .\Processing\Processing\Pong_Game\Pong_Game.pde ,and click Run.

If the connection succeeds, the follow will be shown:

../../../_images/Chapter6_02.png

Now you can try to control the racket motion by pressing the corresponding button. Press space bar to start the game:

../../../_images/Chapter6_03.png

Use button to control the movement of paddle to block the ball back. The game rules are the same as classic pong game:

../../../_images/Chapter6_04.png

The game will be over when one side reachs three points. Pressing the space bar can restart the game:

../../../_images/Chapter6_05.png

Additionally, you can restart the game by pressing the space bar at any time.

6.2. Project 6.2 Pong Game 3D

Now, let’s experience the 3D version game.

6.2.1. Component list

The same as last section.

6.2.2. Circuit

The same as last section.

6.2.3. Sketch

6.2.3.1. Sketch Pong_Game_3D

Use Processing to open .\Processing\Processing\Pong_Game_3D\Pong_Game_3D.pde , and click Run.

If the connection succeeds, the follow will be shown:

../../../_images/Chapter6_06.png

Now you can try to control the racket motion by pressing the corresponding button. Press space bar to start the game:

../../../_images/Chapter6_07.png

Use button to control the movement of paddle to block the ball back. The game rules are the same as classic pong game:

../../../_images/Chapter6_08.png

The rest operation is the same as the 2D version.