XNA Game Programming—Player


Jump to: navigation, search
Visual C# Tutorials
.NET Framework Tutorials

Create a third person shooter game

© 2008 Lobão, et. al.

Player

In this section you'll create the Player class, which has the player's attributes and logic. The Player class extends and adds some functionalities to the TerrainUnit class. Figure 12-7 shows the marine model used as the game player.


Image:BegXNAGameProgfig12-7.jpg
Figure 12-7. A marine model. Courtesy of Carlos Augusto (http://www.floatbox.com.br).


In the Player class, you first store the type of player you're creating, because you might have some different types of players in the game. You also store the player's weapon, because it is updated according to the player. For example, the player's weapon is always positioned in the player’s right hand.

// Player type
UnitTypes.PlayerType playerType;
// Player weapon
PlayerWeapon playerWeapon;

Next, declare two attributes to store and control the transformations made over the waist bone of the player's animated model. You can use this transformation to rotate the player's torso around his waist:

// Waist bone
float rotateWaistBone;
float rotateWaistBoneVelocity;


Previous_Page_.gif Next_Page_.gif

Share this page
  • del.icio.us
  • Facebook
  • Google+
  • StumbleUpon