|Sams Teach Yourself Android Game Programming in 24 Hours|
Author: Jonathan S. Harbour
Learning to program an Android game should be fun - can you learn how in just 24 short lessons?
Programming games on the Android platform can be as simple or as complicated as you care to make it as you can go all the way from GUI based games, through 2D and on to full OpenGL 3D graphics. If you are going to go very far, however, you would probably be better using some sort of game engine.
This book attempts to teach you the basics of gaming - simple graphics, using the devices touch input, using its sensors and so on. However, it is worth knowing that it stops short of 3D graphics and OpenGL - and this isn't unreasonable in a beginner's book.
It is important to know that you do need to be able to program in Java to get almost anything from this book. If you are not a Java expert then you need to be prepared to look things up because the author doesn't explain everything down to each instruction. It might also help if you already know a little about Android programming, although this is less of a requirement than Java.
The book starts off with the customary look at what Android is - you probably don't need to read it. Hour 2 is where the fun starts in that you have to get the SDK and the IDE installed. This is the first place that I have to take issue with the book's approach. It not only tells you how to work with Eclipse, it also explains using NetBeans. I'm a great fan of NetBeans but I would never start an Android beginner off using NetBeans, it is far more difficult than Eclipse. It also means that the instructions for procedures in the first part of the book are repeated once for Eclipse and once for NetBeans. The fact that Google has just released Android Studio, an alternative and better IDE than either Eclipse or NetBeans also confuses the issue, but makes NetBeans a very poor choice.
Hours 3 and 4 are good as long as you already write Java. They do a reasonable job of explaining how to write a simple Android app.
This takes us to Part II of the book on Android Hardware. This starts well in explaining how to create a graphics applications and how to draw on the canvas. Hour 7 gets a little more involved with the details of how to load and draw a bitmap.
However it is Hour 8 where things start to go a little wrong. This is where the idea of a game loop running on a separate thread is introduced. The problem is that the need for a separate thread isn't really explained. It is justified on the grounds that without a separate thread there is nothing going on to make the game happen - there is no pump to keep things moving. This is okay, but it misses the idea that that Android UI, like most modern UIs, is single threaded. This means that if you put the animation loop in the UI thread then the whole of the UI freezes. In addition to this the idea of the Runnable interface isn't explained well and, if you don't know about Java threading, you are going to have problems understanding the lesson. What really finally sinks the whole thing is the example, which is too big and too complicated for the beginner to follow. It would have been much better to spread the ideas introduced over more than one lesson. The conclusion is that if you are a beginner and your Java isn't great you will probably make it to Hour 8 but most likely get stuck there - unless you put in a lot of work.
The book picks up again after Hour 8 because the material isn't as difficult. We have four lessons on the hardware - multi-touch, the accelerometer, the proximity sensor and using the pressure sensor. This part of the book ends with an example - a Tricorder project - and a final lesson on using audio.
Part III is about Android Gameplay and opens with the idea of building your own game engine. It then goes on to explain the ideas of sprites and sprite animation. This is all fairly standard stuff if you have read any book on game programming. It covers all of the material, including matrix operations, collision detection, simple physics and so on. The final two lessons cover a scrolling background game and a ball and paddle game example. This is as far as the book gets - but it might be far enough for you.
It is arguable that the same space could have been better used explaining how to use one of the many free game engines available for the Android. This is probably a better way to create a complex game, rather than trying to implement a game engine from scratch. However, if the book had turned to a game engine you have the problem of which one and the reader would have learned fewer basic graphics techniques.
What is more of a problem is that as the book goes on the examples get longer and the explanations become increasingly thin. For example, in the lesson on collision detection the basic idea of bounding box or bounding circle collision detection is introduced, but how you actually tell when two convex regions intersect isn't explained. To discover what the algorithm is you have to read the many pages of code that "update" the game engine.
As the book proceeds you are more and more presented with long code listings that, if you understand the simple ideas being used, you could probably write for yourself - assuming that you are a reasonable Java programmer. If you are not a reasonable Java programmer then there is a lot of code for you to plough through and details to extract.
Overall, this book starts well but becomes increasingly difficult to read as it progresses. It certainly isn't suitable for the Java beginner and there are many aspects of what it describes that would confuse a graphics novice as well. It is difficult to identify a reader who would get something from the entire book.
|Last Updated ( Friday, 12 September 2014 )|