Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
4.6 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: ffdonuts.h
  3. //
  4. // Desc: DirectInput ForceFeedback version of Donuts game
  5. //
  6. // Copyright (C) 1995-1999 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef FFDONUTS_H
  9. #define FFDONUTS_H
  10. // Program states
  11. enum{ PS_SPLASH, PS_ACTIVE, PS_BEGINREST, PS_REST };
  12. // Game object types
  13. enum{ OBJ_DONUT=0, OBJ_PYRAMID, OBJ_CUBE, OBJ_SPHERE, OBJ_SHIP, OBJ_BULLET };
  14. // Object dimensions and fixed properties
  15. #define MAX_SCREEN_X (g_dwScreenWidth-1)
  16. #define MAX_SCREEN_Y (g_dwScreenHeight-1)
  17. #define DONUT_WIDTH 64
  18. #define DONUT_HEIGHT 64
  19. #define PYRAMID_WIDTH 32
  20. #define PYRAMID_HEIGHT 32
  21. #define SPHERE_WIDTH 16
  22. #define SPHERE_HEIGHT 16
  23. #define CUBE_WIDTH 16
  24. #define CUBE_HEIGHT 16
  25. #define SHIP_WIDTH 32
  26. #define SHIP_HEIGHT 32
  27. #define BULLET_WIDTH 3
  28. #define BULLET_HEIGHT 3
  29. #define MAX_DONUT_FRAME 30
  30. #define MAX_PYRAMID_FRAME 40
  31. #define MAX_SPHERE_FRAME 40
  32. #define MAX_CUBE_FRAME 40
  33. #define MAX_SHIP_FRAME 40
  34. #define MAX_BULLET_FRAME 400
  35. #define BULLET_XOFFSET 304
  36. #define BULLET_YOFFSET 0
  37. #define NO_PLAYER -1
  38. //-----------------------------------------------------------------------------
  39. // Name: struct DisplayObject
  40. // Desc: A game object that goes in the display list
  41. //-----------------------------------------------------------------------------
  42. struct DisplayObject
  43. {
  44. DisplayObject* next; // Link to next object
  45. DisplayObject* prev; // Link to previous object
  46. BOOL bVisible; // Whether the object is visible
  47. SHORT type; // Type of object
  48. FLOAT posx, posy; // X and y position
  49. FLOAT velx, vely; // X and y velocity (pixels/second)
  50. FLOAT frame; // Current animation frame
  51. FLOAT delay; // Frame/second
  52. RECT rcSrc, rcDst; // Source and destination rects
  53. LPDIRECTDRAWSURFACE7 pddsSurface; // Surface containing bitmap
  54. int Player; //which player the pbject belongs to -- only for bullets and ships
  55. };
  56. FLOAT Dirx[40] =
  57. {
  58. 0.000000f,
  59. 0.156434f,
  60. 0.309017f,
  61. 0.453991f,
  62. 0.587785f,
  63. 0.707107f,
  64. 0.809017f,
  65. 0.891007f,
  66. 0.951057f,
  67. 0.987688f,
  68. 1.000000f,
  69. 0.987688f,
  70. 0.951057f,
  71. 0.891007f,
  72. 0.809017f,
  73. 0.707107f,
  74. 0.587785f,
  75. 0.453990f,
  76. 0.309017f,
  77. 0.156434f,
  78. 0.000000f,
  79. -0.156435f,
  80. -0.309017f,
  81. -0.453991f,
  82. -0.587785f,
  83. -0.707107f,
  84. -0.809017f,
  85. -0.891007f,
  86. -0.951057f,
  87. -0.987688f,
  88. -1.000000f,
  89. -0.987688f,
  90. -0.951056f,
  91. -0.891006f,
  92. -0.809017f,
  93. -0.707107f,
  94. -0.587785f,
  95. -0.453990f,
  96. -0.309017f,
  97. -0.156434f
  98. };
  99. FLOAT Diry[40] =
  100. {
  101. -1.000000f,
  102. -0.987688f,
  103. -0.951057f,
  104. -0.891007f,
  105. -0.809017f,
  106. -0.707107f,
  107. -0.587785f,
  108. -0.453990f,
  109. -0.309017f,
  110. -0.156434f,
  111. 0.000000f,
  112. 0.156434f,
  113. 0.309017f,
  114. 0.453991f,
  115. 0.587785f,
  116. 0.707107f,
  117. 0.809017f,
  118. 0.891007f,
  119. 0.951057f,
  120. 0.987688f,
  121. 1.000000f,
  122. 0.987688f,
  123. 0.951057f,
  124. 0.891006f,
  125. 0.809017f,
  126. 0.707107f,
  127. 0.587785f,
  128. 0.453990f,
  129. 0.309017f,
  130. 0.156434f,
  131. 0.000000f,
  132. -0.156435f,
  133. -0.309017f,
  134. -0.453991f,
  135. -0.587785f,
  136. -0.707107f,
  137. -0.809017f,
  138. -0.891007f,
  139. -0.951057f,
  140. -0.987688f
  141. };
  142. //-----------------------------------------------------------------------------
  143. // Function prototypes
  144. //-----------------------------------------------------------------------------
  145. HRESULT InitializeGame( HWND hWnd );
  146. HRESULT InitializeSound( HWND hWnd );
  147. HRESULT InitializeInput( HWND hWnd );
  148. VOID DestroyGame();
  149. VOID DestroySound();
  150. VOID DestroyInput();
  151. VOID UpdateFrame(LPDIRECTDRAWSURFACE7 lpddsConfigDlg = NULL);
  152. VOID CleanupAndDisplayError( CHAR* strError );
  153. HRESULT RestoreSurfaces();
  154. BOOL IsDisplayListEmpty();
  155. BOOL IsDisplayListEmptyExceptShips();
  156. VOID InitializeShips();
  157. VOID AdvanceLevel();
  158. VOID UpdateDisplayList();
  159. VOID DrawDisplayList(LPDIRECTDRAWSURFACE7 lpConfigDlgSurf = NULL);
  160. FLOAT rnd( FLOAT low=-1.0f, FLOAT high=1.0f );
  161. VOID CheckForHits();
  162. VOID BltBitmappedText( CHAR* strScore, int x, int y );
  163. HRESULT DisplaySplashScreen();
  164. VOID EraseScreen();
  165. HRESULT FlipScreen();
  166. VOID DisplayLevelIntroScreen( DWORD dwLevel );
  167. DisplayObject* CreateObject( SHORT type, FLOAT x, FLOAT y, FLOAT vx, FLOAT vy, int Player );
  168. VOID AddToList( DisplayObject* pObject );
  169. VOID DeleteFromList( DisplayObject* pObject );
  170. VOID GetDeviceInput(DWORD input[]);
  171. #endif