Android Game with AndEngine: Gravity Ball

Gravity Ball is a free Android Game. To play, you tilt the phone to roll your ball on a path of tiles to the Vortex tile to finish that level. If the ball falls off the tile, it will be respawned immediately on the very first tile.

NOTE: This game works only on Android cell phones. It will not work on tablets.

There are four difficulty levels: Kids, Easy, Medium, and Hard. I was able to win the Kids level, but it gets harder to win the levels starting from the Easy level. There are a total of 10 levels (or tile configurations) for each difficulty level.

Tiles with arrows on them will push the ball in that direction so you have to compensate for it by tilting the phone in the opposite direction.

Developing the Game

Game programming is little different than regular programming in several ways. For one thing, it is very graphics intensive. And the biggest problem there is keeping track of the coordinates of the background, animated sprites, the camera, and the fixed images like the score board (Heads Up Display).

Performance makes a difference, because if there are long delays in responding to the user input, the user may think that the game crashed and try to restart or close it.

Also in the case of Gravity Ball, we used a sensor (an accelerometer) to move the ball on the screen. So whenever the game screen was displayed, the accelerometer was turned on to report the X, Y, and Z values, and it needed to be turned off when not in use.

Game Development Libraries

When I first started to work on this game, I had already spent about two weeks when I realized that lot of the functions I was trying to build can be factored out and re-used to develop other games. With this thought, I started to research available game libraries.

For example, Unity is a cross-platform game library that has support from game consoles to desktops and everything in between. The problem for me was that this library was so large that it would take me several months just to learn the basics.

The AndEngine currently supports only Android devices, it is small and fast. It may support iPhones in the future. Some of the Cocoa like features are already available.

AndEngine also supports creating live-wallpapers. This is also on my list of projects to do in the future.

One big problem with AndEngine is that there is not much documentation for it. The source code (the ultimate documentation!) is available, but even that is sparsely commented. One good thing is that the source code comes with number of example apps that show some of the features of the library.

Credits

Credit goes to where credit is due. My son Kubi came up with the original idea and in fact had built a Flash version of this same game earlier this year. He also created all the graphics images used in this game.