プレイヤクラス


4.2.4.6 プレイヤクラス

The Player class manages the player and player movement including collision detection.

プレイヤクラスは、プレイヤとコリジョン衝突を含んだプレイヤの移動を管理します。

class Player
{
private:
 AppMazing* app;

 csRef<iCollider> player_collider;

 // For the movement system.
 csVector3 desired_location;
 csVector3 desired_lookat;
 float amount_moved;
 float amount_rotated;
 csVector3 start_location;
 csVector3 start_lookat;

public:
 Player (AppMazing* app);

 bool InitCollisionDetection ();

 void StartMovement (const csVector3& dir);
 void StartRotation (const csVector3& rot);
 void MoveAndRotateCamera (float elapsed_seconds);
};

First it keeps track of the `player_collider'. This will be used for detecting collision detection. Then it keeps track of where the player wants to go too and in what direction it wants to look (`desired_location' and `desired_lookat'). The function StartMovement?() initiates a movement in some direction (relative). The function StartRotation?() initiates a rotation in some rotational direction. It is important to note that these functions don't actually do the movement and the rotation. This is done in the function MoveAndRotateCamera?(). This function takes the elapsed seconds since the last frame as a parameter. This makes sure that movement speed will be equal on fast and slow hardware. i.e. the movement speed is independent from framerate. That's a very important principle to maintain in games.

まず、`player_collider`を保持します。これは、

最新の20件

2007-02-18 2007-02-12 2007-01-31 2007-02-12 2007-01-14 2007-01-21 2007-02-12 2007-02-11 2007-01-15 2007-01-14 2007-02-12 2007-02-11 2007-02-01 2007-01-21 2007-01-19 2007-02-12 2007-01-19 2009-08-27 2007-01-10

今日の14件

  • counter: 159
  • today: 1
  • yesterday: 0
  • online: 1