home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / thx / demos / skyscrap / build / stealth.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-19  |  1.7 KB  |  64 lines

  1. #ifndef __stealth_h
  2. #define __stealth_h
  3.  
  4. #include "plane.h"
  5. #include "plasma.h"
  6. #include "global.h"
  7.  
  8. //--------------------------------------
  9. // Stealth
  10. // the player's ship
  11. // maintains a plasma ( his weapon ) list
  12. // responds to GO LEFT, GO RIGHT, and FIRE
  13. // draws itself
  14. //--------------------------------------
  15. class Stealth : public Plane
  16. {
  17.   // data
  18.   private:
  19.     int MoveLength;
  20.   protected:
  21.     Plasma plasma[15];
  22.   public:
  23.  
  24.   // functions
  25.   private:
  26.   protected:
  27.   public:
  28.     Stealth() { MoveLength = 4; }
  29.     void Setup( Director* director ); // sets up stealth
  30.     void Reset(void);                 // sets stealth at initial location
  31.     void OnLeftKey();              // response function for GO LEFT
  32.     void OnRightKey();             // response function for GO RIGHT
  33.     void OnUpKey();                // response function for GO UP
  34.     void OnDownKey();              // response function for GO DOWN
  35.     void OnFireKey();              // response function for FIRE weapons
  36.     void OnMove(int,int);
  37.     void OnDraw(void);                // draws ship's image
  38.     void initialize();
  39.     void SoundDestroy(void);
  40. };
  41.  
  42. inline void Stealth::OnLeftKey()
  43. {
  44.   int x=loc.x-=(loc.x-MoveLength>=0) ? MoveLength:0;
  45.   StealthRect.l=x, StealthRect.r=x+width;
  46. }
  47. inline void Stealth::OnRightKey()
  48. {
  49.   int x=loc.x+=(loc.x+MoveLength<=320-width) ? MoveLength:0;
  50.   StealthRect.l=x, StealthRect.r=x+width;
  51. }
  52. inline void Stealth::OnUpKey()
  53. {
  54.   int y=loc.y-=(loc.y-MoveLength>=0) ? MoveLength:0;
  55.   StealthRect.t=y, StealthRect.b=y+height;
  56. }
  57. inline void Stealth::OnDownKey()
  58. {
  59.   int y=loc.y+=(loc.y+MoveLength<=200-height) ? MoveLength:0;
  60.   StealthRect.t=y, StealthRect.b=y+height;
  61. }
  62.  
  63. #endif //__stealth_h
  64.