Game Development Reference
In-Depth Information
for (size_t i = 0; i < gameObjects.size(); ++i)
{
const GameObject& gameObj = gameObjects[i];
jobject newGameObj =
env->NewObject(gameObjectClass,
gameObjectCtor, gameObj.id,
gameObj.x, gameObj.y, gameObj.color
);
jboolean result =
env->CallBooleanMethod(objArrayList,
addFunction, newGameObj);
}
}
Test Drive
Hopefully, by working with the code, you now realize the power of this prototyping system. However, the fun part is
trying it out, so you will create a very simple scene in a matter of minutes.
Build both the native code and Java code, and run the application on your mobile device or emulator. You should
see the scene editor come up. Tap on the colored circle button several times until the green circle appears. Then tap
once in the empty scene area, preferably near the top. A green object should appear, and it should have a gray outline,
indicating it's selected. Now tap on the Edit Script button. The script editor should come up, with a default script that
contains an empty OnUpdate function. You will write code that makes the object move, given a constant velocity. The
code should look like that in Listing 12-23.
Listing 12-23. AngelScript Code for the One-Minute Scene
float velocity = 100.0f;
void OnUpdate(float dt)
{
me.y += velocity * dt;
}
Now press the Back button on your device twice, once to hide the keyboard and a second time to go back to the
scene editor. Tap on the Play Scene button to go to the scene player. When there, press Play and watch the magic
happen!
What's Next
While the prototyping tool you just created gives you some power, there are many features it still lacks. Previously
I mentioned sending touch input to the scripted objects, creating and destroying objects, and the ability to detect
collisions with other objects. Additional features include creating object prefabs before placing them as object
instances, using textured sprites instead of colored circles, and a visual scripting system. The important takeaway
from this chapter is that the prototyping tool should be bound only by the limits of your own imagination. In other
words, the tool's features can grow with every new idea. I invite you to improve it, or reimagine it completely.
Hopefully this chapter has sparked an interest in the internal workings of authoring tools, and given you the
knowledge to continue learning.
 
Search WWH ::




Custom Search