ball.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // ball.h
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. //
  23. // 01/19/97 JMI Added some initializations to constructor.
  24. //
  25. // 01/27/97 JMI Added override for EditRect() to make this object clickable.
  26. //
  27. // 02/02/97 JMI Added EditHotSpot() override.
  28. //
  29. // 02/07/97 JMI Added members for 3D.
  30. //
  31. // 02/07/97 JMI Removed m_pipeline and associated members and setup since
  32. // the CScene now owns the pipeline.
  33. //
  34. // 02/13/97 JMI Changing RForm3d to RSop.
  35. //
  36. // 02/23/97 JMI Brought up to date so we can continue to use this as a
  37. // test object.
  38. //
  39. // 02/26/97 JMI Now sets m_sprite.m_pthing = this on construction.
  40. //
  41. // 03/13/97 JMI Load now takes a version number.
  42. //
  43. // 07/21/97 JMI Added GetX(), GetY(), and GetZ().
  44. //
  45. ////////////////////////////////////////////////////////////////////////////////
  46. #ifndef BALL_H
  47. #define BALL_H
  48. #include "RSPiX.h"
  49. #include "realm.h"
  50. // This is a sample game object
  51. class CBall : public CThing
  52. {
  53. //---------------------------------------------------------------------------
  54. // Types, enums, etc.
  55. //---------------------------------------------------------------------------
  56. protected:
  57. //---------------------------------------------------------------------------
  58. // Variables
  59. //---------------------------------------------------------------------------
  60. protected:
  61. double m_dX;
  62. double m_dY;
  63. double m_dZ;
  64. double m_dDX;
  65. double m_dDY;
  66. double m_dDZ;
  67. short m_sPrevHeight;
  68. short m_sSuspend;
  69. long m_lPrevTime;
  70. CSprite3 m_sprite; // Container (contains ref's to below).
  71. CAnim3D m_anim; // 3D animation.
  72. RTransform m_trans; // Current transformation.
  73. short m_sCurRadius; // Objects radius (currently fudged).
  74. // Tracks file counter so we know when to load/save "common" data
  75. static short ms_sFileCount;
  76. //---------------------------------------------------------------------------
  77. // Constructor(s) / destructor
  78. //---------------------------------------------------------------------------
  79. protected:
  80. // Constructor
  81. CBall(CRealm* pRealm)
  82. : CThing(pRealm, CBallID)
  83. {
  84. m_sSuspend = 0;
  85. m_dDX = 0;
  86. m_dDY = 0;
  87. m_dDZ = 0;
  88. m_sprite.m_pthing = this;
  89. }
  90. public:
  91. // Destructor
  92. ~CBall()
  93. {
  94. // Remove sprite from scene (this is safe even if it was already removed!)
  95. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  96. // Free resources
  97. FreeResources();
  98. }
  99. //---------------------------------------------------------------------------
  100. // Required static functions
  101. //---------------------------------------------------------------------------
  102. public:
  103. // Construct object
  104. static short Construct( // Returns 0 if successfull, non-zero otherwise
  105. CRealm* pRealm, // In: Pointer to realm this object belongs to
  106. CThing** ppNew) // Out: Pointer to new object
  107. {
  108. short sResult = 0;
  109. *ppNew = new CBall(pRealm);
  110. if (*ppNew == 0)
  111. {
  112. sResult = -1;
  113. TRACE("CBall::Construct(): Couldn't construct CBall!\n");
  114. }
  115. return sResult;
  116. }
  117. //---------------------------------------------------------------------------
  118. // Required virtual functions (implimenting them as inlines doesn't pay!)
  119. //---------------------------------------------------------------------------
  120. public:
  121. // Load object (should call base class version!)
  122. short Load( // Returns 0 if successfull, non-zero otherwise
  123. RFile* pFile, // In: File to load from
  124. bool bEditMode, // In: True for edit mode, false otherwise
  125. short sFileCount, // In: File count (unique per file, never 0)
  126. ULONG ulFileVersion); // In: Version of file format to load.
  127. // Save object (should call base class version!)
  128. short Save( // Returns 0 if successfull, non-zero otherwise
  129. RFile* pFile, // In: File to save to
  130. short sFileCount); // In: File count (unique per file, never 0)
  131. // Startup object
  132. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  133. // Shutdown object
  134. short Shutdown(void); // Returns 0 if successfull, non-zero otherwise
  135. // Suspend object
  136. void Suspend(void);
  137. // Resume object
  138. void Resume(void);
  139. // Update object
  140. void Update(void);
  141. // Render object
  142. void Render(void);
  143. // Called by editor to init new object at specified position
  144. short EditNew( // Returns 0 if successfull, non-zero otherwise
  145. short sX, // In: New x coord
  146. short sY, // In: New y coord
  147. short sZ); // In: New z coord
  148. // Called by editor to modify object
  149. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  150. // Called by editor to move object to specified position
  151. short EditMove( // Returns 0 if successfull, non-zero otherwise
  152. short sX, // In: New x coord
  153. short sY, // In: New y coord
  154. short sZ); // In: New z coord
  155. // Called by editor to update object
  156. void EditUpdate(void);
  157. // Called by editor to render object
  158. void EditRender(void);
  159. // Called by editor to get the clickable pos/area of an object.
  160. virtual // Overridden here.
  161. void EditRect( // Returns nothiing.
  162. RRect* prc); // Out: Clickable pos/area of object.
  163. // Called by editor to get the hotspot of an object in 2D.
  164. virtual // Overridden here.
  165. void EditHotSpot( // Returns nothiing.
  166. short* psX, // Out: X coord of 2D hotspot relative to
  167. // EditRect() pos.
  168. short* psY); // Out: Y coord of 2D hotspot relative to
  169. // EditRect() pos.
  170. // Get the coordinates of this thing.
  171. virtual // Overriden here.
  172. double GetX(void) { return m_dX; }
  173. virtual // Overriden here.
  174. double GetY(void) { return m_dY; }
  175. virtual // Overriden here.
  176. double GetZ(void) { return m_dZ; }
  177. //---------------------------------------------------------------------------
  178. // Internal functions
  179. //---------------------------------------------------------------------------
  180. protected:
  181. // Get all required resources
  182. short GetResources(void); // Returns 0 if successfull, non-zero otherwise
  183. // Free all resources
  184. short FreeResources(void); // Returns 0 if successfull, non-zero otherwise
  185. };
  186. #endif //BALL_H
  187. ////////////////////////////////////////////////////////////////////////////////
  188. // EOF
  189. ////////////////////////////////////////////////////////////////////////////////