home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / Source / Chapter 13 / Game / Bullet.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-01  |  1.9 KB  |  54 lines

  1. //-----------------------------------------------------------------------------
  2. // Functionality for a bullet to exist in the scene. The bullet manager tracks
  3. // and processes all of the bullets.
  4. //
  5. // Programming a Multiplayer First Person Shooter in DirectX
  6. // Copyright (c) 2004 Vaughan Young
  7. //-----------------------------------------------------------------------------
  8. #ifndef BULLET_H
  9. #define BULLET_H
  10.  
  11. //-----------------------------------------------------------------------------
  12. // Bullet Class
  13. //-----------------------------------------------------------------------------
  14. class Bullet
  15. {
  16. public:
  17.     Bullet( SceneObject *owner, D3DXVECTOR3 translation, D3DXVECTOR3 direction, float velocity, float range, float damage );
  18.     virtual ~Bullet();
  19.  
  20.     void Update( float elapsed );
  21.  
  22.     bool IsExpired();
  23.  
  24. private:
  25.     SceneObject *m_owner; // Owner of the bullet. Used to prevent players from shooting themselves.
  26.     RayIntersectionResult *m_hitResult; // Result of the bullet's ray intersection.
  27.     float m_totalDistance; // Total distance covered by the bullet.
  28.     bool m_expired; // Indicates if the bullet has expired yet.
  29.  
  30.     D3DXVECTOR3 m_translation; // Current translation of the bullet.
  31.     D3DXVECTOR3 m_direction; // Direction the bullet is travelling.
  32.     float m_velocity; // Velocity of the bullet.
  33.     float m_range; // How far the bullet can travel.
  34.     float m_damage; // How much damage the bullet does.
  35. };
  36.  
  37. //-----------------------------------------------------------------------------
  38. // Bullet Manager Class
  39. //-----------------------------------------------------------------------------
  40. class BulletManager
  41. {
  42. public:
  43.     BulletManager();
  44.     virtual ~BulletManager();
  45.  
  46.     void Update( float elapsed );
  47.  
  48.     void AddBullet( SceneObject *owner, D3DXVECTOR3 translation, D3DXVECTOR3 direction, float velocity, float range, float damage );
  49.  
  50. private:
  51.     LinkedList< Bullet > *m_bullets; // Linked list of bullets.
  52. };
  53.  
  54. #endif