Years ago I was addicted to a simple game that I played on my then state-of-the-art Pentium-75. In this game, balls would bounce around, and I would try to partition them into small enough spaces so that I could go to the next level where more and more balls would be added. As of a couple of months ago, for the life of me, I couldn't remember the name of this game. So when I sat down to write an application for Android in my 20% time, I thought, why not try to recreate something similar? After completing most of the game and showing it to some of my friends at work, one of them said, "Oh, this reminds me of JezzBall!" Eureka! If working on this game does nothing more than reveal the name of one of the favorite games of my youth, I'll call it a success, but in the meantime, I'm happy to announce that the source of this application, named Divide and Conquer, is now available on apps-for-android.
The game starts with instructions:
and begins simply enough with one ball bouncing around. You drag your finger in a horizontal or vertical gesture on the screen to initiate a line that extends until it reaches the edges:
In each level, once you've shaved off 80% of the original area, you move to the next level. Here's a screen shot of level 6:
If a ball hits a line in progress, you lose a life:
Once you are out of lives, it is game over:
While this game isn't going to win any awards for cutting edge graphics, it demonstrates use of several Android features and APIs:
- custom drawing and animation
- touch input based gesture detection
- overriding the default behavior of the back key in some situations (to pause the game)
- creating custom Dialogs
- configuring an application to be full screen with no title or status bar
- use of the preferences framework
- use of the vibrator API
DivideAndConquerView is a custom View that implements its own onDraw method using the Canvas methods, and gesture detection using onTouchEvent and a helper class DirectionPoint. It keeps track of the state of the game using BallEngine, and reports relevant events back to the main activity of the application, which, in turn, keeps track of and controls the state of the game. The application is configured to be full screen in its AndroidManifest.xml file.
ليست هناك تعليقات:
إرسال تعليق