Beginning Android Games

Robert Green, Mario Zechner

Mentioned 4

Beginning Android Games, Second Edition offers everything you need to join the ranks of successful Android game developers, including Android tablet game app development considerations. You'll start with game design fundamentals and programming basics, and then progress toward creating your own basic game engine and playable game apps that work on Android and earlier version compliant smartphones and now tablets. 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. This book will guide you through the process of making several example game apps using APIs available in new Android SDK and earlier SDK releases for Android smartphones and tablets: The fundamentals of game development and design suitable for Android smartphones and tablets The Android platform basics to apply those fundamentals in the context of making a game, including new File Manager system and better battery life management The design of 2D and 3D games and their successful implementation on the Android platform This book lets developers see and use some Android SDK Jelly Bean; however, this book is structured so that app developers can use earlier Android SDK releases. This book is backward compatible like the Android SDK. What you’ll learn How to set up/use the development tools for creating your first Android game app 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 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.

More on Amazon.com

Mentioned in questions and answers.

I'm a complete newbie when it comes to game development and I need someone to point me to the right direction.
For the sake of clarity please consider the following animation. simple zombie game animation

Basically I need to know how to emulate the above animation as an Android game but I don't know the steps necessary to do as such. My questions can be summarized as follow:

  • Do I need to use a Game Engine for such simple games?
  • Or it can be done without the use of any particular framework?
  • Do I need to use an animation application such as Adobe Flash?
  • What are the necessary steps to make this kind of game?

Using a game engine or not is a preference. It will depend on what exactly you are after. If you want to learn about the underlying concepts of rendering, collision detection, etc, then writing these yourself is perfectly acceptable, and a lot of fun. On the other hand, if you just want to get the game done without having to worry about the details then an engine is definitely the way to go.

Game engines range from very basic wrappers (which usually provides easier functions that take care of low level tasks) to highly complex abstractions in which the actual game development no longer resembles any specific platform - they also sometimes allow you to create the game once and deploy it to various platforms without any changes.

To implement a game based on that animation you might use the following:

  • For each non-player character create a series of consecutive "frames" which when cycled gives the illusion of movement. These can be created in any graphics application (preferably in a texture map/atlas).
  • For the player character, you will need an animated sequence for each "move", such as kick, punch, etc. Then play the correct sequence when the player triggers some action (ex. play the kick sequence when the player pushes a kick button).
  • Each character should have a bounding box (i.e. a rectangle that defines the size and position of the character). The player character should probably have a different sized box based on the type of attack (i.e. the box for the kick action would extend farther to the right than the box for the punch action.
  • Randomly spawn characters at the right of the screen and move them at some speed (based on type?) towards the player. During each iteration, test for collisions between the player and each non-player's bounding boxes. If a collision is found, check if the player is kicking or punching and kill the character that was hit, if the player is not attacking maybe damage him/her.

That is a very basic description of your problem and should give you enough ideas to research in order to implement a basic version :)

Some game engines you might want to look into:

If you are interested in learning about making android games specifically, have a look at this book:

I am new to android development and I plan to make a 2d game engine but I don't really know where to start. I read something on the internet but I don't find any good opengl es documentation for android, I don't even know where to start.

If you have no idea where to start, I will point you to the excellent book Beginning Android Games. If you are serious about this, then it is more than worth the investment.

This is a beginner/intermediate text, but in the book the authors (Mario Zechner & Robert Green) create a fairly decent game development framework - not exactly a fully blown engine but it is highly reusable and easily expandable and, unless you've created a game engine before, I would advise you to walk before you try running. Creating a game engine is very complicated so start off with something that you will be able to finish and use, then once you've got that down you will have the confidence you need to build your own.

For me this book was the perfect introduction to android development - I had a great deal of programming experience but mostly in C/C++ with DirectX, some basic OpenGL, and software rendering and had no knowledge of Android, Java, or OpenGL ES. With this text I was up and running in a very short period and got some games done, which is always a great boost to keep going :)

I'm using this method to draw a circle in my app:

public void drawCircle(){       
    paint.setColor(Color.rgb(52, 73, 94));
    paint.setFlags(Paint.ANTI_ALIAS_FLAG);      
    canvas.drawCircle(100, 200, 60, paint);     
}

The problem is that the circle appears kind of oval and with pixellated edges.
I used the ANTI_ALIAS_FLAG but it didn't work.
How to draw a circle with smooth edges?

EDIT I using a framework for games. from this book: http://www.amazon.com/Beginning-Android-Games-Mario-Zechner/dp/1430246774

I am currently reading this book: http://www.amazon.com/Beginning-Android-Games-Mario-Zechner/dp/1430246774

The book covers OpenGL ES 1.0. In the chapter discussing texture mapping, it is said that the origin of the texture coordinates is in the upper-left corner of the image. However, the information I find on Google is different - everywhere I look it is explained that the origin is the bottom-left corner.

Can someone clarify which one is true?

That is an error in the book. The texture origin is the lower-left pixel always, on all OpenGL versions.

If the example code in the book works nonetheless the author of the book he as very likely uploaded his textures upside down. OpenGL Textures are uploaded from the bottom to the top and images are usually stored top to bottom within their files. If so two errors cancel each other out and everything looks okay again.