Game Development Reference
In-Depth Information
The next step is to create a jni folder inside the game prototype tool's project folder. Copy the libangelscript.a
file into the jni folder and create two files, Android.mk and Application.mk , inside that same folder.
The Android.mk file tells the build system which source files to compile, which libraries to link, and which type of
library to output, as shown in Listing 12-11.
Listing 12-11. Android.mk File
LOCAL_PATH:= $(call my-dir)
# Declare the prebuilt AngelScript static library
include $(CLEAR_VARS)
LOCAL_MODULE := libangelscript
LOCAL_SRC_FILES := libangelscript.a
include $(PREBUILT_STATIC_LIBRARY)
# Build our JNI shared library
include $(CLEAR_VARS)
LOCAL_MODULE := libgptjni
LOCAL_CFLAGS := -Werror
LOCAL_CPPFLAGS := -fexceptions
LOCAL_SRC_FILES := GPTMain.cpp \
GPTScriptEngine.cpp
LOCAL_LDLIBS := -llog
LOCAL_STATIC_LIBRARIES := libangelscript
include $(BUILD_SHARED_LIBRARY)
You will use containers from the Standard Template Library, or STL, in your native code. The Android NDK
comes with its own version of STL and must be built. The Application.mk file has a single line that tells the NDK to
build STL and to give us access to it (see Listing 12-12).
Listing 12-12. Application.mk File
APP_STL := gnustl_static
GPTScriptEngine
Let's briefly go over the requirements for the script engine. It should be able to take a scene as a collection of game
objects, then create and manage a representation of that scene. The goal is to allow calling script functions on each
object from within C/C++, which, along with compiling scripts, is the next requirement for the engine. The only script
function you want to call in your simplified system is OnUpdate . But each object can implement it differently; this
shows the power and flexibility of the prototyping tool. One last requirement is a way to reset the scene. The idea is to
forget about the current collection of game objects and initialize the system with a new set of objects. An example is a
situation in which the user navigates back to the editor, makes changes to the scene, and returns to the scene player.
 
Search WWH ::




Custom Search