Android game development
Let us now focus on the main topic of this book. Although game development covers many platforms and technologies, we will only focus on Android in this book.
Android is a mobile operating system based on the Linux kernel. Currently, it is being developed by Google. The OS has released many versions since 2008 to date. But after the release of Android 2.2 (Froyo) and Android 2.3 (Gingerbread), this OS caught the attention of many game developers. Android uses what is called the Dalvik Virtual Machine (DVM), which is an open source implementation of a Java Virtual Machine (JVM). There are several differences between Dalvik and a standard JVM, some subtle, some not so subtle. The DVM is also not aligned to either Java SE or Java ME, but to an Apache implementation called Apache Harmony Java. All of this makes for a slight learning curve if you happen to be transitioning from Java ME. Google introduced an alternative to DVM called Android RunTime (ART) from Android 4.4 (KitKat), and ART replaced DVM from Android 5.0 (Lollipop). ART mainly features Ahead-of-time (AOT) compilation, and an improved garbage collection process, and it provides a smaller memory footprint in order to optimize memory operations. However, most game developers use DVM to support older versions of Android devices.
Android game development started extensively when this OS was adapted by many hardware platforms. Android is mostly being used on the mobile and tablet platforms. When the mobile game industry started migrating from Symbian or Java to Android or other smart mobile OSes, Android game development started to boom.
There are a few reasons for the success of Android games:
- Smooth user interface
- Better interactivity
- Touch interface
- Better look and feel
- Better hardware platform
- More design flexibility
It is always easier to use a common operating system than an embedded real-time operating system (RTOS). The user need not spend time on different hardware to learn its usability. Android is one such easy-to-use operating system.
The visual user interface is very attractive in Android, as it always runs on better hardware configuration than Symbian, Java, or an embedded OS. It enhances user experience, which is one of the reasons why it got adapted by so many organizations. As the user base of Android increased, many more game developers started targeting this platform.
From the perspective of game design, the enhanced Android features list gave flexibility to explore more in mobile games. Thus, the game design style was enhanced.
The current world has various types of hardware that run on Android. Apart from mobile phones, Android is being used on tablets, televisions, wristwatches, consoles, digital cameras, PCs, and other devices. Nowadays, game developers are targeting almost every Android platform.
Features and support
Direct manipulation interface is the top feature of Android. It interacts with the user through a continuous representation of objects of interest, dynamic real-time action, and dynamic feedback. Android mainly uses a touch interface with real-time action such as swiping, dragging, tapping, and multi-touch, which are widely used in game development for Android.
Android application development is mainly based on Java (SDK) and C++ (NDK), which are the most common programming languages in the world. Hence, developing a game has become much easier.
Excellent support for multimedia took Android a step further in gaining popularity. Game developers can now use multimedia objects freely inside the game in order to increase the game quality.
Since version 2.2 (Froyo), Google has developed an integrated service called Google Play Services. It is a closed system-level API service provider, which has proved to be very useful in game development.
A large number of third-party tools available for Android development have also eased the job of game developers. Some of the tools we can mention are Android Studio, App Inventor, Corona, Delphi, Testdroid, Sample Directmedia Layer, Visual Studio, Eclipse IDE, and RubyMotions.
Android device hardware configuration has to follow a minimum configuration list, so it becomes very easy for the developers to identify the configuration. Moreover, it has to maintain a minimum standard to run applications easily.
There are plenty of sensors associated with Android devices (mostly on mobiles or tablets), which are a very good option for designing the controls of a game.
Android supports awesome connectivity through Bluetooth, Wi-Fi, GSM/CDMA/EDGE, LTE, NFC, IDEN, and the like. These help game developers to create multiplayer games easily.
Virtual reality is another field where Android is being used through Cardboard SDK. We will discuss this topic more later on.
These are the features that a game developer should keep in mind. The rest of the features are less important for game development. However, there is always a chance to explore more, and create a few specific-feature oriented games.
Challenges
The main challenge in developing a game on an Android platform is to make the most use of the features in an efficient way.
The range of Android device configurations is wide. So, designing a game targeting most of them is a big challenge.
Many of the Android game developers design and build games for specific hardware configurations, like Tegra, or Snapdragon, or a particular device like Xperia Play. Nvidia's Tegra is the most commonly used chip in these situations; the THD branding often indicates that a game was built for Tegra only. Nvidia has a lot of experience working with developers on the desktop side, and has brought that expertise to mobiles. Android game developers are encouraged to make use of Tegra-specific APIs to build their games. The problem with this scenario is that most users don't have Tegra in their phones. In fact, many LTE handsets that might have otherwise had that gaming-friendly chip are being moved over to Snapdragon S4. Now, for a developer, it is very difficult to maintain performance across different graphic processors.
User experience
Android games can provide awesome user experience through their features.
Game controls can use the accelerometer or gravity sensor for a physics-based mechanism (if supported by the hardware), which is always an added advantage for real-time interactivity.
On-touch screen devices, and dynamic controls like swiping, dragging, pinching, and multi-touch, can be experienced through Android.
Android supports OpenGL for better graphic rendering, which enhances the visual quality of the game.
Miracast in Android is another feature which enables games to use multiple displays and screen sharing for a better experience.
Design constraints
Development of any game requires a design Android is not an exception. The design of Android games requires a lot of knowledge about the target hardware. There are thousands of varieties available for Android. Designers have to choose their target very carefully, and then design the game scope.
As previously stated, it is a challenge not only for the programmers but for the designers as well. Different Android devices have different configurations, but it is very important for a designer that the common features should be targeted.