Tuesday, February 5, 2013

Esplora LCD Pong Game

The Arduino Esplora is blooming as a game platform. This includes use as a standalone game machine as documented in my previous posts.  Add an Adafruit 1.8 inch TFT LCD display or the official Arduino display onto the little-documented expansion header and the Esplora is a game platform rather than a controller.
Add an LCD to your Esplora and you have a standalone gaming platform
The first game on an Esplora + LCD was a platform bounce game I ported from work by R0d0t.  But I also eyed a Pong game posted to Youtube by David Rutherford.

So I contacted David and he sent me over the code the other day.  David stated the code was not textbook code - besides adding Esplora button presses, I did some reformatting and documentation.

The Arduino may be powered by a USB cable to your PC, a USB phone brick, or a phone backup battery.

So here I present the classic one-player Pong game.  It uses the Esplora right-hand buttons 2 and 4 (up and down) to allow the player to move their paddle up and down.  First player to 5 wins.  The Arduino plays a good game but can make some bonehead moves every now and then - definitely not easy to beat it.

To start a new game, you press the right button (labeled Switch 3).
Player's paddle on screen is on the left, control buttons to the right.  Excuse my photography...
You can download the code for free on Github at https://github.com/TheKitty/EsploraApps.

You can mod the game but it may not be the simplest process.  I looked into use of the joystick for paddle control and I found it sluggish.  The game may be sped up by not drawing the lines and score after every ball move.  Perhaps the gameplay calculation conditional statements could be a bit clearer.  If you do speed up the game, you should have something to govern the ball speed - I would suggest the slider below the display controlling a delay.

If you want a cleaner version of the code, the official Arduino.cc website has a version of Pong at https://www.arduino.cc/en/Tutorial/EsploraTFTPong

1 comment:

Note: Only a member of this blog may post a comment.