One of the biggest markets in smart phones is games. I am sure most of us would have played around with “Angry Birds” . In this games tutorial you will learn different methods of developing “Android Games”
At the end of the post is the video on how the code below works and the zip of all the source files used in this example.
Android Games can be developed in 3 ways
1) Developing games using Android/Java libraries
2) Developing games using External Libraries like OpenGL
3) Developing games by porting existing c-game (pc game) to android.
Before getting started I assume that the reader is familiar with the basics of android programming like using activity, creating views, handling motion/touch events etc.
Also, apart from android sdk and eclipse some other tools are required for the game development. Details of the tools required, how to configure and use them will be explained as and when required. I will recommend to check out our last posts
Before starting with the game development lets understand the term “Main Loop”.
Main Loop:
Not just android any game written on any language consists of a set of custom views which are constantly refreshed/re-painted/re-drawn. In some games we need to update the screen or re-draw the view elements at regular intervals.
E.g. consider two games (i) Android Snake Game (ii) Android Number Game for kids as shown.

In android snake game the snake has to move irrespective of the user input. Here the screen has to regularly re-drawn/re-painted to create the motion effect of the snake. Where as in the Number game we need not redraw the screen now and then. The screen must be updated/re-drawn only when the user clicks/touches the screen.
So in the snake game we must re-draw the screen at regular intervals say 1sec in order to do that we make use of threads, while loops etc. and create a refresh/re-draw handler that updates screen regularly. This refresh/re-draw loop created is called “Main Loop”. Read more…