home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / developer_install / ReplicaNetFreewareV5_4.exe / data1.cab / Program_Executable_Files / Example4 / Enemy.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-30  |  1.9 KB  |  100 lines

  1. /* START_LICENSE_HEADER
  2.  
  3. Copyright (C) 2000 Martin Piper, original design and program code
  4. Copyright (C) 2001-2005 Replica Software
  5.  
  6. This program file is copyright (C) Replica Software and can only be used under license.
  7. For more information visit: http://www.replicanet.com/
  8. Or email: info@replicanet.com
  9.  
  10. END_LICENSE_HEADER */
  11. /*
  12. See Enemy.cpp
  13. */
  14. #ifndef __ENEMY_H__
  15. #define __ENEMY_H__
  16.  
  17. #include "d3dfile.h"
  18.  
  19. #include "GameObject.h"
  20. #include "Shadow.h"
  21.  
  22. #include "_RO_Enemy.h"
  23.  
  24. class Enemy : _RO_DO_PUBLIC_RO(Enemy) , public GameObject
  25. {
  26. public:
  27.     Enemy();
  28.     virtual ~Enemy();
  29.  
  30.     void Render(void);
  31.  
  32.     void PollIt(void);
  33.  
  34.     bool GetPosition(D3DXVECTOR4 &input)
  35.     {
  36.         input = mPosition;
  37.         return true;
  38.     }
  39.  
  40.     D3DXVECTOR4 GetPosition(void)
  41.     {
  42.         return mPosition;
  43.     }
  44.  
  45.     void SetPosition(D3DXVECTOR4 pos)
  46.     {
  47.         mPosition = pos;
  48.         GiveDeltaHint(mPosition.x,0);
  49.         GiveDeltaHint(mPosition.y,0);
  50.         GiveDeltaHint(mPosition.z,0);
  51.     }
  52.  
  53.     D3DXVECTOR4 GetRotation(void)
  54.     {
  55.         return mRotation;
  56.     }
  57.  
  58.     void SetRotation(D3DXVECTOR4 rot)
  59.     {
  60.         mRotation = rot;
  61.     }
  62.  
  63.     float GetSpeed(void)
  64.     {
  65.         return mSpeed;
  66.     }
  67.  
  68.     void SetSpeed(float speed)
  69.     {
  70.         mSpeed = speed;
  71.     }
  72.  
  73.     /*
  74.     This callback is used by the distance based prediction to calculate the distance to another object in our game
  75.     */
  76.     float CalculateDistanceToObject(RNReplicaNet::ReplicaObject *object)
  77.     {
  78.         // Since the OpaquePointer is always the GameObject pointer for each object we can do this cast safely
  79.         GameObject *gameobject = (GameObject *) object->GetOpaquePointer();
  80.         return GameObject::CalculateDistanceToObject(gameobject);
  81.     }
  82.  
  83.     static void SpawnEnemy(void);
  84.  
  85.     void *GetOpaquePointer(void *data = 0)
  86.     {
  87.         return (GameObject *)(this);
  88.     }
  89.  
  90. /* These variables are defined in the ROL file for this object */
  91. private:
  92. _RO_DO_ALLOW_FRIEND_RO(Enemy);
  93.     D3DXVECTOR4 mPosition;
  94.     D3DXVECTOR4 mRotation;
  95.  
  96.     float mSpeed;
  97. };
  98.  
  99. #endif
  100.