Game Development Reference
In-Depth Information
Chapter 5
3D Shooters for Doom
This chapter looks at another great and very popular PC game: Doom. In 1993, Doom came
along shortly after Wolfenstein 3D and put id Software at the lead of the pack in 3D graphics
gaming for the PC. In this chapter, you'll learn how to bring the open source Doom engine
(PrBoom) to the Android platform.
The chapter starts with fun facts about Doom itself, which will help you understand the
breadth of this project. Bringing a PC game to a mobile device with little change to the
original code is a difficult task. As you can probably tell from reading the previous chapters,
I embrace the Java/C power combo for maximum performance.
Next, you'll dig into the game, which is divided into two big layers: Java and native. This
makes sense, because the game is a mix of original C wrapped in Java code. The Java layer
contains classes for the main activity, audio, and JNI interface (what I call the native interface
class). The native layer has the native method implementations (using JNI) plus changes to
the original C code. The latter is required to glue together both layers and requires less than
50 lines of new code (I consider this to be the most difficult to follow, as there are close to
80,000 lines of original C code, but I will explain the new C code as clearly as possible).
Finally, you get to compilation and deployment; then you can play Doom in the emulator!
You will learn awesome tips for native library compilation—a subject that is obscure to the
average Java developer.
This is a long and complex chapter, and I have tried my best to make it as simple and clean
as possible. For the sake of simplicity, I have omitted some of the lengthier code. Even so,
there are some big listings throughout this chapter and a lot of things to cover. To make the
most of this chapter, you should grab the chapter source code distributed with this topic.
The project has been built with Eclipse ADT with the Android SDK 5.0.1 for Windows and
can be imported into your workspace. The source will help you to understand the layout of
the resources as you read through the chapter.
Note All the code included in this chapter was developed, compiled and tested using Eclipse IDE
for Java Developers instead of Android Studio 1.0.1 since, when this manuscript was written,
NDK and JNI were not supported by Android Studio.
137
 
 
Search WWH ::




Custom Search