Thursday, February 10, 2011

Android Project - Game Engines


In the comments to my previous post iPhone developer extraordinaire Chris suggested using a third party physics engine for my game. I don't know why I hadn't thought of this in the first place. For web development I wouldn't dream of starting a project without using a framework. After all the longer you spend writing loads of boilerplate code the less time you have to spend on the good stuff.

Chris suggested using the Box2D library which looks very good. As Android is a Java platform a Java library would be ideal and luckily some helpful chaps have ported the library and called it JBox2D. There are some very nice looking demos on the website and a helpful tutorial about getting it up and running on Android. I was slightly concerted when playing with the applets that there were a few freezes and stutters (My laptop is only a year old) and a quick search on the internets revealed that most  people were having problems with the Java garbage collector causing problems. 
Luckily all is not lost. Android is not a Java only environment thanks to something called the NDK (Which as far as I can gather is just Android's version of JNI) which allows you do drop meaty chunks of speedy C++ into your Java stew. This requires you to do a bit of work to wrap any C++ classes you want to use with a bit of Java.
AndEngine Logo

Luckily a bit more Googling revealed the AndEngine and libgdx a pair of free Android game frameworks. Both use OpenGL for graphics and rather conveniently integrate the Box2D library saving me the job of getting my hands dirty with NDK. Opinion seems to be that libgdx is faster and better documented while AndEngine is higher level and easier to get to grips with. I quite like the fact that libgdx offers the ability to compile into JOGL for desktop apps rather than having to continually build apks and test on the emulator. 

I'm still undecided between the number puzzle and the jumping frog game but either way I'm going to give a framework a go and see what it offers. 

No comments: