Game Development Reference
In-Depth Information
The Sky Is the Limit with the Java/C Power Combo
The goal here is not to explain how the game itself works (that would take a complete book),
but to show the kinds of things that can be accomplished by combining the elegant
object-oriented features of Java with the raw power of C. Most Java developers dismiss
procedural languages like C, failing to see what can be accomplished when this duo
coexists harmoniously. The trick is to find the right balance that combines the best of both
worlds to solve a complex task with minimal time and effort. Here, you will learn how a task
that would take a team of Java developers possibly months to complete can be done in a
matter of days by someone who understands that object-oriented and procedural languages
are not enemies, but simply pieces of the same puzzle.
Consider Tables 5-1 and 5-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 5-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 5-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
The following is the rundown of the estimated totals:
Total number of lines of new Java code = 2,140
Total number of lines of original C code = 80,000
Total number of lines of new C code = 469
 
 
Search WWH ::




Custom Search