Game Development Reference
In-Depth Information
Figure 7-1. Player's power pyramid
Creating the Player's Viewpoint and Input
The player's viewpoint for this game will be a first-person viewpoint, in which the player can turn
left and right up to 90 degrees. The player will be able to fire 3D projectiles by touching the screen.
Creating the player's viewpoint and the player's input requires modifications to the MyGLRenderer
class and the MyGLSurfaceview class.
Modifying the MyGLRenderer Class
The MyGLRenderer class must be modified to add code to calculate the player's viewpoint and
player's input.
The CameraMoved() function takes as input the change, or delta, in the rotation of the player's view
around the x and y axes. The x and y change in angular position is altered by the ScaleFactor
variable, of which you can make the rotation greater or smaller. (See Listing 7-9.)
Listing 7-9. Calculating the Camera Movement Delta
void CameraMoved(float DeltaXAxisRotation , float DeltaYAxisRotation)
{
m_CameraMoved = true;
float ScaleFactor = 3;
m_DeltaXAxisRotation = DeltaXAxisRotation/ScaleFactor;
m_DeltaYAxisRotation = DeltaYAxisRotation/ScaleFactor;
}
 
Search WWH ::




Custom Search