Click here to Skip to main content
15,888,070 members
Articles / Mobile Apps / Android

Android NDK Game Development Cookbook – A Review

Rate me:
Please Sign up or sign in to vote.
4.33/5 (2 votes)
25 Apr 2014CPOL7 min read 13K   2  
Android NDK Game Development Cookbook - a review

This article is in the Book Review chapter. Reviews are intended to provide you with information on books - both paid and free - that others consider useful and of value to developers. Read a good programming book? Write a review!

No matter which platform your primary target platform for your game in development is, it is wise to have an appreciation for how platforms operate. So even if Android isn't your first deployment, it’s good to get to know how it works as it will help you architect your game properly.

Image 1

Android NDK Game Development Cookbook

I've read many Android platform books / how-to’s and cookbooks in my time, most are fairly run of the mill describing the odd feature here and there, usually focusing on the latest build at the time. This usually left me wanting more or set me on a path to go and delve deeper. Perhaps this is the aim of most of these kinds of titles, however this latest book by Sergey Kosarevsky and Viktor Latypov had a few surprises in store. Let’s uncover this book and get into it.

Image 2

Unlike other Android cookbooks which just focus on the mechanics of Android and its many flavours, this book focuses on the main concepts required for game development such as Input, File Systems, Graphics including web technologies. There is a twist however, maybe it’s because there are twice as many authors as usual, or maybe these guys actually sat down and thought about how to do things differently, whatever the thought processes they used, they certainly gave me food for thought.

Unlike other titles, the authors have tackled one of the biggest issues in the Android domain, that of how to build you project once and get it running on all flavours of Android out there. Granted this is not a silver bullet but it starts you thinking about HOW to build your game, not just what to do to get on a code.

I've done a lot of work in the past building or architecting the multi-platform story, getting a project to run on many platforms such as iOS, Android, Windows Phone, etc. Here though the guys have turned this focus inwards and at each step walk through not only how to use a feature but how to use and design its use properly so that cross-platform impacts across the Android estate are minimised. Its more work than just building a game with Android but the big advantage is that it will run on more Android platforms, not just the latest, increasing your games population and adoption rates which will obviously have a knock on impact on how much revenue you can collect. Food for thought.

So let’s break down what this book has to offer above the competition.

Image 3

Here’s a brief run through what all the chapters are and what to expect from them:

Chapter 1 “Establishing a Build Environment”

Starting with the basics, this chapter gets you up and running whether you are developing your game from Windows or Linux (a nice touch). Here the authors lead you through getting the Android SDK and NDK environments setup and running. You will also be walked through setting your first little program.

What sets this title aside is that it goes beyond just a simple program and deploying it, it also walks you through combining many applications into a single deliverable for several android platforms / versions, tackling the cross platform / multi-platform issues we face within Android itself.

Chapter 2 “Porting Common Libraries”

No development these stands purely on its own, in order to deliver something within an acceptable timeframe you need supporting libraries to quickly and efficiently expand the capabilities of your app/game. With Android being opensource itself, there are a multitude of different options for just about everything. This chapter covers a selection of the main libraries you will likely end up using for graphics, physics, web and others, plus it walks you through how to natively compile them to get the best performance.

Chapter 3 “Networking”

Working with networking on Android can be tough, here the authors lead you through the garden on how to efficiently build a networking solution using libcurl and connect to several major online social networks as examples.

What really surprised me in this chapter was that it even went so far as to show you how to self-host a mini webserver within your project so that you can monitor the apps health and even update it effectively.

Chapter 4 “Organizing a Virtual Filesystem”

File handling on Android is a bit of a back art, not only are there several ways to access files across the many versions of Android that there are, they are also compressed even after installing them on a device to save space, every run of the application requires to you decompress and load them each run. The authors have done a nice job showcasing a simple way of building a simple system that will work on several Android versions continuing the cross platform flow and extend the asynchronous systems built up in previous chapters to apply them to the file system.

Chapter 5 “Cross-platform Audio Streaming”

Stepping back in to more familiar territory, this chapter covering the Android audio system and leveraging OpenAL to read and play audio files. Here, we get an overview of using ogg files and streaming them. What is good is that the authors explain in quite technical detail what goes on under the hood with the audio framework on Android.

Chapter 6 “Unifying OpenGL ES 3 and OpenGL 3”

The word of graphics is an ever evolving system, sometimes changing rapidly between different releases and Android does suffer from this a lot. The more modern versions of Android use a mixture of OpenGL 3 and ES 2 to provide a rich but sometimes tricky state of affair.

Using more cross platform techniques the book walks you through each system to the point where you will be rendering geometry and tweaking the performance to get the best out of even the smallest device. OpenGL 3 is also what is used on Windows platforms so lessons learned here are quickly reusable.

Chapter 7 “Cross-platform UI and Input System”

Without some form of input, most games would be a very boring, however trying to handle all the different types of input available on each system is a tricky thing to achieve. This chapter walks you through building a cross platform UI and input system using touch and gesture based interfaces, plus building on screen joypads for additional control. Following the UI theme, the chapter then also walks into fonts and text with a few neat tricks for handling localisation.

Chapter 8 “Writing a Match-3 Game”

With the theory over, the book ups its pace to walk you through the first of the two example games you will be building. Starting easy first with a nice match three game. This brings together a lot of the tips and tricks learned so far to create a simple game that will work on most variants of Android including a multi-touch input system.

Chapter 9 “Writing a Picture Puzzle Game”

For the second game example, the authors have opted for an online style picture puzzle game, taking pictures from the web and integrating them into the game. It’s a nice touch extending this way and reaching out beyond the device. It also goes beyond the single screen to build a more complete game system.

Image 4

When I was first asked to review this book, I thought “Yet another Android book” but I was pleasantly surprised by the level of technical background included within its pages. The authors have gone to great lengths to not only explain how the code they have built works but how it is handled by the underlying systems on Android. It also features something I've not seen in an Android title before, focusing on ways to handle and beat the diversity that Android suffers from with its many versions, platforms and operator differentials by building your titles in a cross-platform manor even though we are only talking Android.

Pros

  • High level of technical detail
  • High degree of focus on the cross-platform story within Android itself
  • Builds examples that make very good use of the features explained within its pages

Cons

  • Although covering cross-platform very well, I would have liked to see more of a multi-platform story to close the gap as well (a bit of a stretch)
  • Chapter 1 quickly runs through the deployment story with Android, but I would have liked to see more focus on what it takes to ship an Android title
  • It’s in C++ Confused smile (but in a good way)

Image 6

As Android titles go, this book certainly ups its game tackling and not avoiding the diverse nature of Android. It helps you focus on maximising your target audience instead of just building for one version. Adding in the online elements and leaning heavily of some very good opensource frameworks and components to ease your development burden.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect ZenithMoon Studios
United Kingdom United Kingdom
Long-time game developer / IT maniac.
By day I architect, design, build and deliver enriching Mixed Reality solutions to clients, bringing the work of AR/VR to light in new and interesting ways, by night I Masquerade as the Master Chief of ZenithMoon Studios, my own game development studio.

At heart, I am a community developer breaking down lots of fun and curious technologies and bringing them to the masses.

I'm also a contributor to several open-source projects, most notably, the Reality Toolkit and all the services provided by the Reality Collective, The Unity-UI-Extensions project, as well as in the past the AdRotator advertising rotator project for Windows and Windows Phone.

Currently, I spend my time fulfilling contracts in the Mixed Reality space (primarily for an XR experience firm called Ethar), writing books, technically reviewing tons of material and continuing my long tradition of contributing to open-source development, as well as delivering talks, but that goes without saying Big Grin | :-D

Mixed Reality MVP, Xbox Ambassador, MS GameDevelopment Ambassador & Best selling author:

[Accelerating Unity Through Automation](https://www.amazon.co.uk/Accelerating-Unity-Through-Automation-Offloading/dp/1484295072/ref=rvi_sccl_3/262-0817396-1418043)
[Mastering Unity 2D Game Development] (https://www.packtpub.com/game-development/mastering-unity-2d-game-development)
[Unity 3D UI Essentials] (https://www.packtpub.com/game-development/unity-3d-gui-essentials)

Comments and Discussions

 
-- There are no messages in this forum --