Game Development Reference
In-Depth Information
We have discussed the caveats of using polygons in Android. The goal of this section has been to
illustrate the missing pieces we need to start building the game itself. We now have the foundation
classes for Asteroids, so let's look at the actual game architecture.
Understanding the Game's Architecture
The architecture of Asteroids is almost identical to Space Blaster from the last chapter. When the
program starts, the main class
AsteroidsActivity
will be loaded by Android. This activity will load the
user-defined layout in the
Asteroids
class. This class, in turn, inherits from the abstract class
ArcadeGame
,
which extends
LinearLayout
. Note that the user-defined layout is bound with the system by the XML file
asteroids.xml
(see Figure 4-2).
Here, you realize why
ArcadeGame
has been defined as
Abstract
. By incorporating common
functionality in this class, we can implement multiple arcade games in the same project. As a matter of
fact, you can merge
SpaceBlaster
and
Asteroids
into the same project and build your own arcade
system.
Figure 4-2.
The Asteroids game architecture
Let's take a closer look at the actual project.
Creating the Project
We'll start by creating an Android project called Asteroids. Here is how: