Bullet.h
上传用户:royluo
上传日期:2007-01-05
资源大小:1584k
文件大小:3k
源码类别:

游戏

开发平台:

Visual C++

  1. /*****************************************************************************
  2. *                                                                             
  3. *   Bullet.h
  4. *                                                                             
  5. *   Electrical Engineering Faculty - Software Lab                             
  6. *   Spring semester 1998                                                      
  7. *                                                                             
  8. *   Tanks game                                                                
  9. *                                                                             
  10. *   Module description: Interface for the bullet game object.
  11. *                       
  12. *                                                                             
  13. *   Authors: Eran Yariv - 28484475                                           
  14. *            Moshe Zur  - 24070856                                           
  15. *                                                                            
  16. *                                                                            
  17. *   Date: 23/09/98                                                           
  18. *                                                                            
  19. ******************************************************************************/
  20. #ifndef _BULLET_H
  21. #define _BULLET_H
  22. #include <GameObject.h>
  23. #include <GameConsts.h>
  24. #include <ImageManager.h>
  25. #include <GameManager.h>
  26. #include <Tanks.h>
  27. #include <GameBoard.h>
  28. class CBullet: public CMovingGameObject
  29. {
  30. public:
  31.     CBullet (UINT uXPos, UINT uYPos, UINT uDirectionIndex, UINT uParentTankID);
  32.     virtual ~CBullet () {}
  33.     StateType           CalcState (DWORD dwCurTime);
  34.     ObjectHeightType    GetHeight();                
  35.     HIMAGE              GetImage();                 
  36.     CReaction           React(CGameObject *pTo);    
  37.     GameObjectType      GetType();                  
  38. private:
  39.     typedef enum {  
  40.             DEATH_OUTOFSCREEN,          // Bullet just flew out the window
  41.             DEATH_HITWALL,              // Bullet hits a wall
  42.             DEATH_HITTANK,              // Mission acomplished
  43.             DEATH_OUTOFRANGE,           // Range exceeded
  44.             DEATH_NOTDEAD
  45.          } BulletDeathType;      
  46.     BulletDeathType     m_Death;            // Bullet's death state
  47.     HIMAGE              m_himgBullet;       // Bullet's image handle
  48.     BOOL                m_bExplodedOnTank;  // Did we tell a tank we hit it yet ?
  49.     CPoint              m_Origin;           // Point of start
  50.     UINT                m_uParentTankID;    // ID of shooting tank
  51.     UINT                m_uWaitToTellTank;  // Counter until tank knows bullet hits it
  52.     UINT                m_uHitTankID;       // ID of tank bullet hits
  53.     /*  When a bullet flies it may hit a tank.
  54.         If this is the case, the bullet discovers it in its CalcState(...) call.
  55.         It goes into DEATH_HITTANK state and stores the tank ID of the tank it
  56.         hits in m_uHitTankID.
  57.         It then waits until this tank calls React(...).
  58.         When that tank calls React(...) it returns the hit reaction and 
  59.         sets m_bExplodedOnTank to TRUE.
  60.         The next call to CalcState(...) causes the bullet to die.
  61.         If the tank didn't call React(...) for that bullet (the tank might be dead)
  62.         the bullet waits for about 0.5 second and then kills itself.
  63.     */
  64. };
  65. #include <Bullet.inl>
  66. #endif