Beginning Android Games

By Mario Zechner

Beginning Android Games Cover Image

Beginning Android Games offers everything you need to join the ranks of successful Android game developers. You'll start with game design fundamentals and programming basics, and then progress towards creating your own basic game engine and playable game.

Full Description

  • ISBN13: 978-1-4302-3042-7
  • 688 Pages
  • User Level: Beginner to Intermediate
  • Publication Date: April 20, 2011
  • Available eBook Formats: EPUB, MOBI, PDF
  • Print Book Price: $39.99
  • eBook Price: $27.99
Buy eBook Buy Print Book Add to Wishlist

Related Titles

Full Description

Beginning Android Games offers everything you need to join the ranks of successful Android game developers. You'll start with game design fundamentals and programming basics, and then progress towards creating your own basic game engine and playable games. This will give you everything you need to branch out and write your own Android games.

The potential user base and the wide array of available high-performance devices makes Android an attractive target for aspiring game developers. Do you have an awesome idea for the next break-through mobile gaming title? Beginning Android Games will help you kick-start your project.

The book will guide you through the process of making several example games for the Android platform, and involves a wide range of topics:

  • The fundamentals of game development
  • The Android platform basics to apply those fundamentals in the context of making a game
  • The design of 2D and 3D games and their successful implementation on the Android platform

For those looking to learn about Android tablet game app development or want Android 4 SDK specific coverage, check out Beginning Android 4 Games Development, now available from Apress.

What you’ll learn

  • How to set up and use the development tools for developing your first Android application
  • The fundamentals of game programming in the context of the Android platform
  • How to use the Android's APIs for graphics (Canvas, OpenGL ES 1.0/1.1), audio, and user input to reflect those fundamentals
  • How to develop two 2D games from scratch, based on the Canvas API and OpenGL ES.
  • How to create a full-featured 3D game
  • How to publish your games, get crash reports, and support your users
  • How to complete your own playable 2D OpenGL games

Who this book is for

This book is for people with a basic knowledge of Java who want to write games on the Android platform. It also offers information for experienced game developers about the pitfalls and peculiarities of the platform.

Table of Contents

Table of Contents

  1. Android, the New Kid on the Block
  2. First Steps with the Android SDK
  3. Game Development 101
  4. Android for Game Developers
  5. An Android Game Development Framework
  6. Mr. Nom Invades Android
  7. OpenGL ES: A Gentle Introduction
  8. 2D Game Programming Tricks
  9. Super Jumper: A 2D OpenGL ES Game
  10. OpenGL ES: Going 3D
  11. 3D Programming Tricks
  12. Droid Invaders: the Grand Finale
  13. Publishing Your Game
  14. What’s Next?
Source Code/Downloads

Downloads are available to accompany this book.

Your operating system can likely extract zipped downloads automatically, but you may require software such as WinZip for PC, or StuffIt on a Mac.

Errata

Please Login to submit errata.

On page 36:
to be able to use button.setOnClickListener(this); the class has to implement the OnClickListener thus changing the line "public class HelloWorldActivity extends Activity" on page 35 towards "public class HelloworldActivity extends Activity implements OnClickListener"

On page 47:

this occurs throughout the book so far, but the location of the adb program has moved in a more recent version of the sdk from %android_home%\tools to %android_home%\platform-tools

On page 87-90:

Ch3 under Alpha Compositing and Blending

red = src.red * src.alpha + dst.red * (1 - src.alpha)
blue = src.green * src.alpha + dst.green * (1 - src.alpha)
green = src.blue * src.alpha + dst.blue * (1 - src.alpha)

Looks like the blue and green are switched, should be:
red = src.red * src.alpha + dst.red * (1 - src.alpha)
green= src.green * src.alpha + dst.green * (1 - src.alpha)
blue = src.blue * src.alpha + dst.blue * (1 - src.alpha)

On page 99:
3. MySuperAwesomStartScreen .render() method was not inluded in the MySuperAwesomStartScreen class.
The book says we just created it ?

5.MySuperAwesomStartScreen .render() [again this method was omitted, or it is invisible]. from context perhaps it is MySuperAwesomStartScreen .present() ???


On page 124:
The test activity that is listed as "Life Cycle Test" should not contain spaces and should be "LifeCycleTest" else it causes errors or doesn't respond accordingly when trying to run the application.

<activity android:label = "Life Cycle Test"
...
should be
<activity android:label = "LifeCycleTest"

On page 129:
Decorating onTouch with @Override causes an error on some setups of eclipse (I followed the set up completely from the book, but be a version related thing)

Specifically eclipse reports:
Multiple markers at this line
- implements android.view.View.OnTouchListener.onTouch
- The method onTouch(View, MotionEvent) of type SingleTouchTest must override a superclass

On page 158:

Under "Using Wake Locks":

(PowerManager)context.getSystemService(Context.POWER_SERVICE);

...should be...

(PowerManager)this.getSystemService(Context.POWER_SERVICE);

or just...

(PowerManager)getSystemService(Context.POWER_SERVICE);



On page 169:
Errata:
[...] We load a bitmap from a file by using the BitmapFactory singleton. [...]

Corrige:
BitmapFactory is not a singleton it is just a static class.

On page 170:
The sentence starting "This will free the memory used..." in the Loading and Examining Bitmaps section should be under the Disposing of Bitmaps section instead.

On page 180:
The pause() method in the example code will never exit as it is written now.

On page 186:

In the first paragraph under "The AndroidFileIO Class" there is an error at the end of the paragraph that says that the interfaces are knowledge from chapter 4. They are not.. they are from chapter 3.

On page 190:
There's code repeated in the Listing 5-4. the code repeated is this:

import java.io.IOException;
import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;

import android.media.MediaPlayer.OnCompletionListener;
import com.badlogic.androidgames.framework.Music;
public class AndroidMusic implements Music, OnCompletionListener {
MediaPlayer mediaPlayer;
boolean isPrepared = false; package com.badlogic.androidgames.framework.impl;

On page 192:
Regarding the play() method shown on page 191.
Text states "we again throw and unchecked RuntimeException" but the example does not do that. It catches the exception and calls printStackTrace()

On page 192:
No pause() method is defined for the implemented AndroidMusic class although one is declared in the Music interface in chapter 3

On page 192:

The override method for pause() is missing.

On page 198:

line 23 and line 28

if (keyCode>0&& keyCode<127) should be
if (keyCode>=0&& keyCode<=127)

On page 206:
in the case "case MotionEvent.ACTION_MOVE:"
The "isTouched[pointerId] = true;" line is missing.

On page 218:

Errata:
[...] Finally we construct a new AndroidBitmap [...]

Corrige:
[...] Finally we construct a new AndroidPixmap [...]

On page 219:
The line:

canvas.drawRect(x, y, x + width - 1, y + width - 1, paint);

is incorrect. It should be:

canvas.drawRect(x, y, x + width - 1, y + height - 1, paint);


On page 230:
In the Figure 6-1, background.png should have a size of 320x480 instead of 320x380.

On page 280:

There is an error in the overridden function "onResume()".

The line:
super.onPause();

should be:
super.onResume();

On page 290:
In page 290, paragraph 2:

You should substitute "Figure 7-4" with "Figure 7-5".

On page 309:
Errata:
int textureIds = { textureid };

Correction:
int textureIds[ ] = { textureid };

On page 326:
In Page 326, just after the title "2D Transformations: Fun with the Model-View Matrix":

Substitute "Figure 7-11" by "Figure 7-16".

On page 330:

Errata:
in the 3rd chunk of code

for(int i = 0; i < 100; i ++ ) {
bob.update(deltaTime);
[...]
}

Corrige:

for(int i = 0; i < 100; i ++ ) {
bobs[ i ].update(deltaTime);
[...]
}

On page 353:

Errata:
[...] Say we take Bob's position, p=(3, 2) and add his velocity, v=(-2,3). [...]

Corrige:
You cannot really add the two vectors p and v as you did coz you have different entities there. In order to do the sum you first need to convert the velocity in a distance along the velocity's direction by multiply such vector for a scalar namely the time for which you are observing the movement at the given velocity.
The right espression would be:
p' = p + v * t (where t is a scalar having the same unityou gave to the time for the velocity i.e. if the velocity is in m/s then t will be in s).

On page 359:
Errata:
[...] Note that we used the FastMath class instead [...]

Corrige:
[...] Note that we used the FloatMath class instead [...]

On page 433:

The book says

"So let's overlay our mock-up, which is 320x380 pixels in size with a grid where each cell is 32x32 pixels."

Instead

"So let's overlay our mock-up, which is 320x480 pixels in size with a grid where each cell is 32x32 pixels."