Game Development Reference
In-Depth Information
Google is reusing some neat libraries from the Apache Software Foundation (Commons HTTP and HTTP
client) and the W3C XML APIs (under org.xml ).
Figure 3-1. The packages of the Android API (android.jar)
The Android API breaks compatibility with Java SE/ME and makes it tough, but not impossible, to
reuse Java code from standard Java games or applets. You'll find out how to reuse your Java code
throughout this chapter.
Creating Space Blaster, Your First Java Game
It's time for the real thing. This section presents the pure Java game Space Blaster. Even though this is an
Android game, some code has been reused from a Java applet.
Figure 3-2 shows the game in action. The objective of the game is to navigate a space ship through a
field of meteors, shooting them up as you go. The ship has a laser weapon and a defensive shield. You
can choose to shoot the meteor, dodge it by dragging the ship with your fingertips, or let the shield
protect you, but whatever you choose, the power diminishes. As time passes, the power will replenish
itself, and you will get points the longer you stay in the game. You can maneuver the ship with the
keypad arrows or drag it across the field with your fingers. Tapping the background will fire the laser,
pressing E will end the game, and pressing Q will terminate the application.
Search WWH ::




Custom Search