Game Development Reference
In-Depth Information
This great modularization works wonders on the desktop, where developers simply have
to code a new game library and leave the other components intact. In Android (or any
mobile platform, for that matter), this can be a pain to develop, as the compiler tools are
cumbersome compared to the desktop, plus the way Android loads shared libraries is not
the same as in the standard Linux OS. Luckily, Quake II can compile all three components
as a stand-alone (hard-linked) library. Thus in Android, to make things even easier, you will
compile Quake II as a single, hard-linked library dubbed libquake2.so . More details on
doing so will be explained in the “Building Quake II with the NDK” section.
Code Reusability
Thanks to the great object-oriented and reusability features of Java, most of the classes
from Chapter 6 can be reused without change. There are some tiny changes to the startup
class, but besides that, the code is identical. Best of all, this code could be used in any type
of native engine, not just Quake I and Quake II. To recap, Table 7-1 lists the Java classes and
their tasks.
Table 7-1. Java Classes and Tasks
Package
Class Name
Description
com.opengl
QuakeActivity
This is the game startup class. It requires tiny changes mostly
related to the game startup arguments.
com.opengl
QuakeKeyEvents
This class translates Android key event codes into ASCII
codes understood by the Quake II engine. It will be reused
without change.
com.opengl
QuakeView
This class extends the Android API GLSurfaceView to provide
a surface for OpenGL rendering. It also contains the API
GLSurfaceView.Renderer used to implement rendering calls
into the native engine. It will be reused without change.
quake.audio
NativeAudio
This class implements a thread that reads the audio buffer
from the native layer and sends it to the device hardware using
the Android MediaTrack API. It will be reused without change.
quake.jni
Native s
This is the most important class. It declares the JNI native
methods for communication between the Java and C code,
plus it implements a set of callbacks that can be used from
the C layer to send messages to the Java layer. This class will
be reused without change.
 
 
Search WWH ::




Custom Search