Game Development Reference
In-Depth Information
int w = getWindow().getWindowManager().getDefaultDisplay().getWidth();
int h = getWindow().getWindowManager().getDefaultDisplay().getHeight();
// Put the game file pak0.pak files under /sdcard/quake/base!
final String baseDir = "/sdcard/quake";
String args = "quake"
+ ",-width," + String.valueOf(w)
+ ",-height," + String.valueOf(h)
+ ",-basedir," + baseDir
+ ",-game,base"
+ ",+skill,0"
+ ",+crosshair,1"
+ ",+gl_ztrick,0";
mQuakeView.setRenderer(args.split(","));
setContentView(mQuakeView);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
return mQuakeView.keyDown(keyCode, event);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
return mQuakeView.keyUp(keyCode, event);
}
}
The array of arguments sent to the engine is critical; if any mistakes are made, the whole
thing will fail. Listing 6-9 shows the most important arguments, which include the following:
-width and -height : These two are important. They tell the engine the
size of the video buffer and will differ by device. The easiest way to get
their values at runtime is to query the default display.
-basedir : This is the default base directory that contains all the game files.
In this case, you must upload your game files manually to /sdcard/quake .
Note that the directory must also be created.
-skill : Sets the game skill level (0 = easy, 1 = normal, 2 = hard,
3 = nightmare).
+crosshair : Displays a crosshair wherever you aim your weapon.
+gl_ztrick : This is required because Quake uses a buffering method
that avoids clearing the Z-buffer, but some hardware platforms
(like Android) don't like it. It is set to 0 to prevent the status bar and
console from flashing every other frame.
Search WWH ::




Custom Search