home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / xenon / includes / ship.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-12  |  3.2 KB  |  146 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    Player's Ship
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    06/05/00
  8. //
  9. // Base:    CActor
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #ifndef _INCLUDE_SHIP_H
  16. #define _INCLUDE_SHIP_H
  17.  
  18. #include "actor.h"
  19. #include "clone.h"
  20. #include "wingtip.h"
  21. #include "shipengine.h"
  22. #include "retroengine.h"
  23. #include "weapon.h"
  24.  
  25. //-------------------------------------------------------------
  26.  
  27. const int SHIP_CENTRE_FRAME = 3;        // ship centred frame
  28. const int SHIP_ROLL_FRAMES = 3;            // frame range for roll i.e. -3..+3 from centre
  29. const int SHIP_CLOAK_OFFSET = 7;        // offset to invulnerability frames
  30. const int SHIP_DIVE_FRAMES = 6;            // number of dive frames
  31. const int SHIP_DIVE_OFFSET = 14;        // offset to dive frames
  32.  
  33. const float SHIP_DIVE_SCALE = (float) 52 / 64;    // scale of dived ship
  34.  
  35. const float SHIP_ROLL_RATE = 10.f;        // frames per seconds
  36. const int SHIP_MAP_HIT = 10;            // energy lost if ship hits map
  37.  
  38. //-------------------------------------------------------------
  39.  
  40. const float CLOAK_FLASH_TIME = 1.f;        // time for flashing to signify end of cloaking
  41. const float CLOAK_FLASH_RATE = 0.15f;    // flash rate
  42.  
  43. //-------------------------------------------------------------
  44.  
  45. typedef enum {
  46.     HANDLING_BAD,
  47.     HANDLING_NORMAL,
  48.     HANDLING_GOOD,
  49. } ShipHandling;
  50.  
  51. //-------------------------------------------------------------
  52.  
  53. class CShip : public CActor
  54. {
  55.     private:
  56.         CWeapon *m_weapon;
  57.  
  58.         WeaponType m_weapon_type;
  59.  
  60.         CClone *m_left_clone;
  61.         CClone *m_right_clone;
  62.         
  63.         CWingtip *m_left_wingtip;
  64.         CWingtip *m_right_wingtip;
  65.  
  66.         CShipEngine *m_left_engine;
  67.         CShipEngine *m_right_engine;
  68.         CRetroEngine *m_retro_nw;
  69.         CRetroEngine *m_retro_ne;
  70.         CRetroEngine *m_retro_sw;
  71.         CRetroEngine *m_retro_se;
  72.  
  73.         float m_max_speed;
  74.         float m_acceleration;
  75.         float m_damping;        
  76.  
  77.         ShipHandling m_handling;
  78.  
  79.         int m_roll;
  80.  
  81.         gsCTimer m_cloak_timer;
  82.         float m_cloak_time_limit;
  83.  
  84.         enum {
  85.             DIVE_OFF,
  86.             DIVING_DOWN,
  87.             DIVE_ACTIVE,
  88.             DIVING_UP
  89.         } m_dive_mode;
  90.  
  91.         int m_dive_level;
  92.         gsCTimer m_dive_timer;
  93.         float m_dive_time_limit;
  94.  
  95.     public:
  96.         CShip();
  97.         ~CShip();
  98.         const ActorInfo& getActorInfo() { return ActorInfoList[INFO_SHIP]; };
  99.  
  100.         bool activate();
  101.         void kill();
  102.  
  103.         void explode();
  104.  
  105.         bool update(Controls *controls);
  106.  
  107.         gsCRect getCollisionRect();
  108.  
  109.         void registerHit(int energy,CActor *hitter);
  110.  
  111.         void onCollisionWithActor(CActor *actor);
  112.         void onCollisionWithMap(gsCMap *map,int hits);
  113.  
  114.         void setWeapon(WeaponType type,WeaponGrade grade = WEAPON_STANDARD);
  115.  
  116.         WeaponType getWeaponType();
  117.  
  118.         void addWeapon(WeaponType type,WeaponGrade grade = WEAPON_STANDARD);
  119.         bool upgradeWeapon();
  120.  
  121.         bool attachClone(int side);
  122.         void detachClone(CClone *clone);
  123.         bool attachWingtip(int side);
  124.         void detachWingtip(CWingtip *clone);
  125.         void removeUpgrades();
  126.  
  127.         void setHandling(ShipHandling handling);
  128.         ShipHandling getHandling();
  129.  
  130.         void setCloak(float time);
  131.         bool isCloaked();
  132.         bool isCloakFlashing();
  133.  
  134.         void dive(float time);
  135.         int getDiveLevel();
  136.         float getDiveScale();
  137.  
  138.         void reverseWeapon();
  139.  
  140. };
  141.  
  142. //-------------------------------------------------------------
  143.  
  144. #endif
  145.  
  146.