Game Development Reference
In-Depth Information
The initializeGrenade function is invoked from the update function of the
LeftHand class once the animation has been executed. It invokes the initialize
function of the Grenade class and passes the grenadePositions array calculated
in the start function. Note that these interpolates are calculated in reference to
the camera and not the world space. We calculate each position in world space by
translating them with the camera matrix in the update function of the Grenade class.
function initializeGrenade(){
grenade.initialize(grenadePositions);
}
Our handleKeys function simply toggles the visibility of the left hand when the
Enter key is pressed. Once the object is marked visible, the drawScene function starts
invoking its update function and subsequently leads to its rendering. Once the hand
animation ends, it invokes the grenade animation from the callback function.
function handleKeys(event) {
...
switch(event.keyCode) {//determine the key pressed
case 13://Press Enter for grenade action
leftHand.visible=true;
break;
...
}
}
Using texture animation for an explosion
effect
In the last section of this chapter, we will create an animation effect with textures. We
want the grenade to explode once its animation ends. Although explosions in games
are created using particle physics, for simple explosions, we chose to confine ourselves
to texture animation. So let's first understand what we mean by texture animation.
Until now, we were updating an object's location or rotation in our update function.
In short, we were manipulating the ModelView matrix. Now, we will change the
texture in our update function.
 
Search WWH ::




Custom Search