Thursday, May 6, 2010

Virtual Table Tennis 3D 1.7 Update

My Android development has been on somewhat of a hiatus lately due to me moving to a new condo among other things. On the plus side I did manage to squeeze out a big update recently for Virtual Table Tennis 3D. For this update I added two new environments. This has been a feature requested by many users so I'm excited that I've finally gotten around to doing this.

Here are screenshots:

Friday, April 9, 2010

Bitmap Fonts

I recently added support for Bitmap fonts to my engine. I used the free tool BMFont to do this ( This tool allows you to select a font (face, size, etc) and it generates a bitmap containing the font glyphs as well as a file describing the texture coordinates and spacing. To integrate this into my engine, I extended my asset tool to read the font description file and write it out in a custom file format. The engine then reads in this file at runtime and uses the info to draw the glyphs.

To draw text, a "Text object" is created by the engine that stores a set of VBOs. A dynamic VBO is used to store the texture coordinates and vertex positions for each glyph in the string and a static VBO to store the indices. When the string for the Text object changes, the position/texcoord VBO contents change to reflect the new glyphs to be drawn.

Here is screenshot:

Tuesday, April 6, 2010

Rolling a custom model format

The first significant change I made to my engine after the launch of Virtual Table Tennis 3D was the implementation of a custom model format. This would speed up the loading of model assets since I wouldn't have to decode an MD2 file at runtime. My goal was to create a format that stored data in such a way that it could be passed to GL unmodified. This way I would be able to take a pointer to the file data and pass it directly into a glBufferData call. I also wanted all the other information that GL vertex buffer objects expect to be contained in the format (e.g. # vertices, # position components, etc). I named the format "Embedded Model Format" or "EMF" (what an imaginative name!).

I also added a conversion stage to my asset tool that would automatically turn all MD2 files into EMF files before being copying the asset to each platform's output folder.

Here is a screenshot of the format spec taken directly from my source code.

Monday, April 5, 2010

Mobile Monday Google Talk

I was invited to a Google Talk on mobile application today and it turned out to be pretty uneventful. The speakers mainly talked about HTML5 for an hour and about how mobile web apps are becoming more and more sophisticated. Tell me something I don't know seriously.

The one interesting thing is that most attendees were using iPhones and I also spotted quite a few iPads as well. Even the speakers from Google used an iPad to demonstrate their new gmail mobile web app.

Sunday, April 4, 2010

Under the Hood

Its not a stretch to say that Virtual Table Tennis 3D was somewhat of a test case for the engine I've been developing since last fall. When the game shipped, the engine was missing many features (required for more sophisticated games) but I was quite satisfied with it from the architectural standpoint.

It took me about two two and a half months to write the engine. The feature I'm most happy about is the cross-platform architecture. This allowed me to develop most of the game code in Windows (in Visual Studio) and only test on the Android platform from time to time, which was HUGE time saver especially since there isn't any official debugger support for the NDK yet.

Still, there are many features missing from the engine and tons of TODOs littered throughout the source. I plan to address these short comings in the upcoming months.

Here are some additional details about the engine (as it was when Virtual Table Tennis 3D shipped):
  • Game and rendering backends are written entirely in C and interface with a thin Java client via JNI
  • Multithreaded engine (Main/input thread, rendering thread, game logic thread)
  • Cross-platform architecture:
    • All platform specific code (threading primitives, logging, writing to persistent state, etc) is abstracted out to a separate module.
    • Developed custom asset tool that automatically exports all assets to each platform and generates a .h header file containing the asset ids.
    • Developed Windows version of the game (using an OpenGL ES emulator) along side the Android version for easy debugging
  • Uses fixed point math since many current Android handsets don't support hardware floating point
  • Asset Formats
    • MD2 file format used for models
    • OGG format used for sound effects
    • PNG format used for textures
  • Tools used:
    • Visual C++ 2008 Express - C source development
    • Eclipse Galileo - Java development
    • Blender 2.49b - modelling
    • LithUnwrap - UV unwrapping for models
    • git - version control

Saturday, April 3, 2010

Post Release

For two months after publishing Virtual Table Tennis 3D, I slowed down my development efforts considerably partly due to other things going on in life at the time. I did manage to push out several incremental updates for the game (bug fixes, gameplay tweaks, graphical polish, small features).

Some things I learned about publishing a game on the Android marketplace:
  • The market audience is polarizing. Some users will find your game too easy while others will find it too difficult. Trying to please all users is a balancing act.
  • Making any assumptions on the user's prior experience in playing touch screen games is detrimental. If you don't make your input system "idiot proof" expect some negative reviews to come your way.
  • Some users will blame you (and down rank you) for things that are beyond your control, such as not being able to download the game.
  • Weekend seems to bring in the best sales.
  • Its worthwhile to update your game every two weeks to get on the "Just In" section of the market.
I'm going to continue to update my game periodically and I even have some new content planned that goes beyond bug fixes and minor tweaks.

Friday, April 2, 2010

The Beginning

I'll keep this introduction short. After being involved in Android game development for over half a year I've decided to finally start a blog to share my experiences and hopefully inspire others to get involved.

Early last summer I became a proud owner of an HTC Magic and almost immediately began looking into developing games for the platform. I implemented a basic engine in Java but ended up abandoning it in September when version 1.6 of the NDK was released, which finally provided OpenGL bindings for native C code. At this point I started re-writing my engine from scratch in C (which is my area of expertise) and started working on an actual game in November. I wanted to start with a fairly simple game that would allow me to focus on learning the complete process of developing an Android game without getting bogged down by complex gameplay details.

In January I finally completed and published my game on the Android market. The game is called "Virtual Table Tennis 3D" and its currently doing reasonably well in terms of sales. Completing this game has been quite a satisfying experience but I feel like I've really only scratched the surface of what this platform is capable of. I'm hoping to achieve a lot more in the upcoming months. Stay tuned...