Android Game Programming Tutorial

Today we start on a new tutorial series on Android Game Development.

The tutorials will teach game programming for Android devices using many real examples.

Motivation for the Course
The current state of mobile game development has again made it possible for lone developers to churn out fun and highly profitable games working from their homes. Some of the key motivations for this course include:

  • Fastest growing mobile platform (1.5 million Android phones being activated every day)  (source)
  • Lot of untapped potential
  • Used in wide ranging devices ranging from phones to tablets and even television !
  • Gaming Experience on Android improving by day with new multi core devices joining the ride

Assumptions about you
This course assumes that you have some experience in programming – so we will not talk about things like classes, object, inheritance, polymorphism and things like that. A very basic understanding of these is assumed.

Other Expectations from you

Game Development is a vast topic to cover in a tutorial series. Having general programing skill is just a small requisite for it. In addition  to programming there is a lot of things that go into execution of a game. At the very least, you need to implement things like graphics, sprites, fonts, animation, sound effects, and others.

While I will try to keep things as simple as possible, I will be abstracting on a few concepts which I assume you to know. If you do not know them you are expected to fill in those learning gaps as a motivated learner. On occasion you might find me explicitly linking to other recommended reading material.

Enough of setting pretext, Let’s get started !

 Some Theory Stuff

Before we get our hands dirty at the actual coding, it is important that we understand some of the theory that underlies a typical game program.

We will implement our game in the following order:

Splash Screen

A typical game is required to load a lot of resources into the memory before the game starts to run. To provide this time to the program, most of the games implement a splash screen(normally an attractive graphic/animation to hold the players attention during the load process).

Selection Menu

The splash screen is immediately followed by a selection menu which normally lets the user select among game options, help documentations and the play button.

Game Loop

Most of the games are implemented on the concept of game loop. The game loop is a programming loop that continuously runs right from the very start of the game up till the end of the game.   Each cycle in the loop takes care of the following tasks:

  • Get inputs from the player
  • Change Graphics as per inputs
  • Update Scores/ Status
  • Check for collisions/game over
  • Play related sounds
  • and more…

depending upon the requirements of the particular game.

Game Frameworks
If the game is going to be fun, it must do these updates as efficiently as possible within the time frame for each cycle of the game loop. This would require a lot of work. Fortunately we do not have to reinvent the wheel. Turns out this common theme runs through so many video games that several game developers have collaborated to produce several open source game frameworks or game engines to ease out the work for us.

We will be using one of the game frameworks. But before we select a game engine, we will first look at some of the game engines available to us. This is discussed in the next section.