Game Development Reference
In-Depth Information
C H A P T E R 7
■ ■ ■
3D Shooters Episode II:
Doom for Android
This chapter looks at another great game for the PC: Doom. 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, we dig into the game itself, which is divided into two big layers: Java and native. This makes
sense, as the game is a mix of original C wrapped in Java code. In the Java layer are 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
both layers together and requires less then 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, we get to compilation, deployment, and playing 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 a 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 distributed with this topic. The project has been built with Eclipse Galileo 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.
The Sky Is the Limit with the Java/C Power Combo
The goal here is not to try to explain how the game itself works (that would take a complete topic), 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.
Search WWH ::




Custom Search