Game Development Reference
In-Depth Information
Consider Tables 7-1 and 7-2. They show the total number of lines of new Java code, plus the number
of lines inserted in the existing C code in Doom for Android.
Table 7-1. Estimated Number of Lines for Java Files of Doom for Android
File
Description
Lines of Code
DoomClient.java
Main game activity
700
DialogTool.java
Methods to create help dialogs
300
DoomTools.java
Miscellaneous helper subs
450
GameFileDownloader.java
A class to install game files to the SD card
180
WebDownload.java
Web download tool
200
AudioManager.java
Singleton for audio management
200
AudioClip.java
Wrapper for Android MediaPlayer to play sounds
110
Table 7-2. Estimated Number of Lines Changed from the Original Doom C Code
File
Description
Lines of Code
jni_doom.c (new)
Implementation of the JNI native methods plus C to Java callbacks
450
i_sound.c
C to Java callbacks to send sound events to Java
3
s_sound.c
C to Java callbacks to send sound events to Java
6
i_video.c
C to Java callbacks to send video events to Java
10
Here's the rundown of the estimated totals:
Total number of lines of new Java Code = 2140
Total number of lines of original C code = 80,000
Total number of lines of new C code = 469
The bottom line? One developer has managed to reuse about 80,000 lines of C code, thus bringing a
PC game to Android with a few thousand lines of new code in a couple of days. Imagine the potential
savings in development costs and time. Now compare this to a team of three developers trying to port
the 80,000 lines of raw C to pure Java. It would probably take them months of head-pounding work with
no financial gain (as the code is open sourced). This simply makes no sense. I hope that at this point you
understand why this chapter is my personal favorite and a must-read for the aspiring Android game
developer. So get the source code for the chapter, and let's get started.
Search WWH ::




Custom Search