Game Development Reference
In-Depth Information
Creating the PowerPyramid Class
The PowerPyramid class is the class you will use to represent the player's physical presence in
the game.
The m_ExplosionSFXIndex variable holds the index to the explosive sound played when the
pyramid is hit.
The CreateExplosionSFX() function creates the explosive sound effect for the power pyramid and
saves the index to this sound in the m_ExplosionSFXIndex variable.
The PlayExplosionSFX() function plays back the explosion that was created with the
CreateExplosionSFX() function. (See Listing 7-8.)
Listing 7-8. The Player's PowerPyramid Class
public class PowerPyramid extends Object3d
{
private int m_ExplosionSFXIndex = -1;
PowerPyramid(Context iContext, Mesh iMesh, MeshEx iMeshEx, Texture[] iTextures, Material
iMaterial, Shader iShader)
{
super(iContext, iMesh, iMeshEx, iTextures, iMaterial, iShader);
}
// Sound Effects
void CreateExplosionSFX(SoundPool Pool, int ResourceID)
{
m_ExplosionSFXIndex = AddSound(Pool, ResourceID);
}
void PlayExplosionSFX()
{
if (m_ExplosionSFXIndex >= 0)
{
PlaySound(m_ExplosionSFXIndex);
}
}
}
The player's pyramid, which is an instance of the PowerPyramid class, is shown in Figure 7-1 .
 
Search WWH ::




Custom Search