Today I decided to work through a libGDX tutorial by the YouTube creator Small Pixel Games. I’ve been considering learning libGDX for some time now, but haven’t had a spare weekend to work on new personal projects in some time. The goal of this tutorial was fairly simple, implement a game of Pong using libGDX and the Box2D physics engine. I expanded on the project a little by adding a menu, difficulty settings, and sound effects.

I was extremelly excited to find this tutorial as it was created around six months before I went through it. Like I said earlier, I have wanted to get into libGDX for some time, and have spent a couple of weekends wandering around some other tutorials and perusing the libGDX JavaDocs at BadLogic Games. libGDX is a very well established framework and it has been around for quite awhile, so many of the tutorials that you find for it are old and often out of date. For example, libGDX recently switched from LWJGL2 to LWJGL3, and it’s difficult to find any recent tutorials that cover the new OpenGL framework. Additionally, it was very fun and encouraging to spend a day on a project and end up with a trivial, but ultimately complete and full featured game that can be played. And hey, on the mid and hard difficulties, it can actually be quite challenging!


What I ended up making had a number of variations from the tutorial. Starting with the more obvious ones, I included a game menu (allowing you to start the game, or exit). Additionally, I included a menu where you set the difficulty of the game. These were implemented using libGDX’s Scene2D library to make the UI. The menu is faily simple, but I think it adds some completeness to the experience (especially with the difficulty selection).

The button assets were sourced from a bundle of free assets from Kenny, however the button assets they shipped only came with “not selected” and “selected” versions, so I used the “selected” version for the “hover” asset, and used Gimp to shift it down a couple of pixels to make a “button down” version.

The game sounds came from one of the annual giveaway sound packs from SONNISS. If you search around the /r/gamedev subreddit, you’ll find that SONNISS has given away sound packs every year for a couple of years now. The original sound effect was actually of a bunch of beeps, but I used Audacity to cut it down to just one beep (which is used for the “paddle hit” sound effect), and then down shifted that one beep by a couple of octaves in Audacity for the “wall hit” sound effect. The “button click” sounds also came from one of the annual SONNISS giveaway packs.

One key difference between my implementation and the tutorial is the score keeping display. In the tutorial, Small Pixel Games brought in a .png of the digits 0-9 in a particular font, and then imported that into the project as a TextureMap. I was hoping to achieve the same effect with a regular font file instead of turning the digits into sprites, so I came up with my own implementation using text. For the font, I found a TrueType Font called ‘press-start’ on DaFont with a license allowing free or commercial release, and then I used the tool Hiero to convert that ttf to a BitmapFont. I also made a smaller version of this font to use for the text on the buttons.

In order to use Scene2D effectively I had to pack all of my UI assets (fonts and buttons) into a libGDX skin. To accomplish this, I used SkinComposer.

And finally, the only game sprite I used was a green square, which was used to texture the walls, ball, and paddles. I simply made this myself using Gimp.

Ultimately, I feel like it turned out pretty good! It captures a very retro aesthetic, and it’s probably the first game that I’ve made in one day!

If you’d like, you can play the game right in your browser here!

Additionally, you can download the game here.

And, last but not least, feel free to check out the full source code here.

pong_gameplay pong_gameplay pong_gameplay pong_gameplay