Pong Game (leJOS EV3)

Photo of robotA simple two-player pong game, written in leJOS EV3.

Robot Design

The robot is simply a base EV3 brick with two NXT motors attached to the sides, and a wheel on each motor for a control.

The NXT motors could be exchanged for EV3 motors with only a minor change in the code. An alternative design to make two-player games easier would be to detach the motors from the brick and connect them with a longer cable.

Issues and Improvements

The large issue I came across with this program was the screen refresh. When the game was running, the screen was flickering a lot, making the game virtually unplayable. I experimented around with changing the screen refresh rate, even splitting the game into separate processes with their own delay, but nothing seemed to resolve the issue. I eventually sorted out the issue by removing all code that was clearing the LCD screen, and instead drew the objects in white to erase the previous position before calculating their new positions and redrawing them in black.


The program was written in leJOS EV3. It consists of three classes:

  • Pong is the main class which is run when the program is started. It manages the game loop and ties the other classes together
  • The Ball class represents the ball. It has fields for the X and Y positions, as well as the delta X and delta Y, as well as methods for updating the position and drawing it on the screen and checking if it has bounced
  • The Paddle class is designed to control a single paddle, and so is initialized twice with different parameters for each paddle.

The entire program code can be found at GitHub.



Leave a Reply

Your email address will not be published. Required fields are marked *