Paddlenoid!

Posted on March 25th, 2012

Paddlenoid gameplay screenshot

Finally ! The first version of Paddlenoid is ready for launch. It’s best described as a fusion between Pong and Arkanoid. It’s a free download for Android phones and tablets. It’s even got its own website: www.paddlenoid.com.

Here’s a short gameplay video where I’m finishing the first level of the game:

I’m not providing the source code for this project just yet but here are some technical details about the source code:

C++

The project was created almost entirely in C++. This has three main advantages:

  • The ability to run Paddlenoid in Windows as well as on the Android device.
  • The ability to develop and debug most of Paddlenoid in Visual Studio Express.
  • It should help porting either the entire game or to re-use parts of it on different devices (iPhone, Windows Phone, etc..)

To give an idea about proportions; The source code has 320 lines of Java code to bootstrap the C++ library. The other 18.831 lines are entirely C++.

OpenGL

The graphics are entirely OpenGL 2.0 ES. I had experimented with OpenGL 1.0 in the past but getting started with 2.0 ES still offered quite a challenge. You will have to create your own fragment and vertex shaders or nothing will get drawn at all.

But since almost every device out there supports OpenGL in one form or another it’s still an easy choice to make if the code needs to be portable as well as fast.

Android 2.2+

If I wasn’t still stuck with my old HTC Desire I would have definitely used Android 2.3. Android 2.2 has a very limited amount of C++ support in the form of standard libraries. It does not implement a standard way to access resource files from your APK file as well as there’s no standard way to use the audio capabilities of the device.

To access the resources from the APK I resolved to using libzip. Libzip actually provides a very nice and easy API to opening files straight from a Zip file. And since the APK file is actually zip file I had this running smoothly in no time at all. This process is documented in my earlier ‘Android In C++‘ blog post.

Getting sound to work in Windows was a breeze, just link to OpenAL Soft and get started.

Getting sound to work in Java required some more effort. I quickly felt that the only really reliable way to access sound was through the Java layer by using the ‘AudioTrack‘ API. But I wasn’t going to create some kind of complicated callback mechanism to be able to trigger sounds from my C++ code in the Java code.
So the only option left was to create a C++ wrapper around the ‘AudioTrack’ Java class using JNI.

There’s not a lot of documentation which explains everything about calling Java from C++. A lot of what I did find looked outdated or was using the C based API instead of the C++ functions. This in addition to some interesting problems in the AudioTrack API itself.

In the end I’m happy with the way sound works in the game. Despite that it nearly made me buy a new phone early in order to be able to just switch to Android 2.3.

Graphics and Levels

All of the graphics in the game have been made exclusively with Paint.Net. ImageMagick was used to convert the graphics to 32bit BMP files before including them as resources in the game. PNG would also have been an obvious choice but it never seemed necessary. I like to think that using BMP’s kept loading times when switching levels pretty low.

The levels are created in Tiled. A brilliant little map editor. Tiled was also used it for all of the background tiles.

Fonts

The fonts are Republika for the logo and the menus. As well as CPMono for the highscores and everything that needed to be fixed width.