home *** CD-ROM | disk | FTP | other *** search
/ MORE WinGames / WINGAMES.iso / hyperoid / hyperoid.h < prev    next >
C/C++ Source or Header  |  1991-11-02  |  7KB  |  242 lines

  1. //
  2. // HYPEROID.H - hyperoid internal header information
  3. //
  4. // Version: 1.1  Copyright (C) 1990,91 Hutchins Software
  5. //      This software is licenced under the GNU General Public Licence
  6. //      Please read the associated legal documentation
  7. // Author: Edward Hutchins
  8. // Revisions:
  9. //
  10.  
  11. #ifndef RC_INVOKED
  12.  
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <ctype.h>
  16. #include <math.h>
  17. #include <limits.h>
  18. #define OEMRESOURCE
  19. #include <winext.h>
  20.  
  21. //
  22. // typedefs and defines
  23. //
  24.  
  25. // color stuff
  26. #define PALETTE_SIZE 16
  27. typedef enum
  28. {
  29.     BLACK, DKGREY, GREY, WHITE,
  30.     DKRED, RED, DKGREEN, GREEN, DKBLUE, BLUE,
  31.     DKYELLOW, YELLOW, DKCYAN, CYAN, DKMAGENTA, MAGENTA
  32. } COLORS;
  33.  
  34. // degrees scaled to integer math
  35. #define DEGREE_SIZE 256
  36. #define DEGREE_MASK 255
  37. #define DEGREE_MAX 0x4000
  38.  
  39. // object limits
  40. #define MAX_PTS 8
  41. #define MAX_OBJS 100
  42. #define MAX_COORD 0x2000
  43. #define CLIP_COORD (MAX_COORD+300)
  44.  
  45. // timer stuff
  46. #define DRAW_TIMER 1
  47. #define DRAW_DELAY 50
  48. #define RESTART_TIMER 2
  49. #define RESTART_DELAY 5000
  50.  
  51. // restart modes
  52. typedef enum { RESTART_GAME, RESTART_LEVEL, RESTART_NEXTLEVEL } RESTART_MODE;
  53.  
  54. // letter scaling
  55. #define LETTER_MAX 256
  56.  
  57. // extra life every
  58. #define EXTRA_LIFE 100000
  59.  
  60. // list node
  61. typedef struct tagNODE
  62. {
  63.     struct tagNODE  *npNext, *npPrev;
  64. } NODE;
  65. pointerdef( NODE );
  66.  
  67. // list header
  68. typedef struct
  69. {
  70.     NPNODE          npHead, npTail;
  71. } LIST;
  72. pointerdef( LIST );
  73.  
  74. // object descriptor
  75. typedef struct
  76. {
  77.     NODE            Link;               // for object list
  78.     POINT           Pos;                // position of center of object
  79.     POINT           Vel;                // velocity in logical units/update
  80.     INT             nMass;              // mass of object
  81.     INT             nDir;               // direction in degrees
  82.     INT             nSpin;              // angular momentum degrees/update
  83.     INT             nCount;             // used by different objects
  84.     INT             nDelay;             // used by different objects
  85.     BYTE            byColor;            // palette color
  86.     BYTE            byPts;              // number of points in object
  87.     POINT           Pts[MAX_PTS];       // points making up an object
  88.     POINT           Old[MAX_PTS];       // last plotted location
  89. } OBJ;
  90. pointerdef( OBJ );
  91.  
  92. //
  93. // inline macro functions
  94. //
  95.  
  96. // function aliases
  97. #define AddHeadObj(l,o) AddHead((l),((NPNODE)o))
  98. #define RemHeadObj(l) ((NPOBJ)RemHead(l))
  99. #define RemoveObj(l,o) Remove((l),((NPNODE)o))
  100. #define HeadObj(l) ((NPOBJ)((l)->npHead))
  101. #define NextObj(o) ((NPOBJ)((o)->Link.npNext))
  102.  
  103. // real-time check of the keyboard
  104. #define IsKeyDown(x) (GetAsyncKeyState(x)<0)
  105.  
  106. // I HATE typing this allatime!
  107. #define INTRES(x) MAKEINTRESOURCE(x)
  108.  
  109. // size of an array
  110. #define DIM(x) (sizeof(x)/sizeof((x)[0]))
  111.  
  112. // faster than MulDiv!
  113. #define MULDEG(x,y) ((INT)(((LONG)(x)*(y))/DEGREE_MAX))
  114.  
  115. // DEG - convert an integer into a degree lookup index
  116. #define DEG(x) ((WORD)(x)&DEGREE_MASK)
  117.  
  118. // ACCEL - accelerate an object in a given direction
  119. #define ACCEL(o,d,s) \
  120. (((o)->Vel.x += MULDEG((s),nCos[DEG(d)])), \
  121. ((o)->Vel.y += MULDEG((s),nSin[DEG(d)])))
  122.  
  123. // PTINRECT - a faster PtInRect
  124. #define PTINRECT(r,p) \
  125. (((r)->left <= (p).x) && ((r)->right > (p).x) && \
  126. ((r)->top <= (p).y) && ((r)->bottom > (p).y))
  127.  
  128. // INTRECT - a faster IntersectRect that just returns the condition
  129. #define INTRECT(r1,r2) \
  130. (((r1)->right >= (r2)->left) && \
  131. ((r1)->left < (r2)->right) && \
  132. ((r1)->bottom >= (r2)->top) && \
  133. ((r1)->top < (r2)->bottom))
  134.  
  135. // MKRECT - make a rect around a point
  136. #define MKRECT(r,p,s) \
  137. (((r)->left = ((p).x-(s))), ((r)->right = ((p).x+(s))), \
  138. ((r)->top = ((p).y-(s))), ((r)->bottom = ((p).y+(s))))
  139.  
  140. //
  141. // prototypes
  142. //
  143.  
  144. // hyperoid.c
  145. INT NEAR PASCAL arand( INT x );
  146. VOID NEAR PASCAL AddHead( NPLIST npList, NPNODE npNode );
  147. NPNODE NEAR PASCAL RemHead( NPLIST npList );
  148. VOID NEAR PASCAL Remove( NPLIST npList, NPNODE npNode );
  149. VOID NEAR PASCAL DrawObject( HDC hDC, NPOBJ npObj );
  150. VOID NEAR PASCAL SetRestart( BOOL bGameOver );
  151. VOID NEAR PASCAL AddExtraLife( VOID );
  152. VOID NEAR PASCAL Hit( HDC hDC, NPOBJ npObj );
  153. VOID NEAR PASCAL Explode( HDC hDC, NPOBJ npObj );
  154. BOOL NEAR PASCAL HitPlayer( HDC hDC, NPOBJ npObj );
  155. NPOBJ FAR PASCAL CreateLetter( CHAR cLetter, INT nSize );
  156. VOID NEAR PASCAL DrawLetters( HDC hDC );
  157. VOID NEAR PASCAL DrawHunterShots( HDC hDC );
  158. VOID NEAR PASCAL FireHunterShot( NPOBJ npHunt );
  159. VOID NEAR PASCAL CreateHunter( VOID );
  160. VOID NEAR PASCAL DrawHunters( HDC hDC );
  161. VOID NEAR PASCAL CreateSpinner( VOID );
  162. VOID NEAR PASCAL DrawSpinners( HDC hDC );
  163. VOID NEAR PASCAL CreateRoid( POINT Pos, POINT Vel, INT nSides, BYTE byColor, INT nDir, INT nSpeed, INT nSpin );
  164. VOID NEAR PASCAL BreakRoid( HDC hDC, NPOBJ npRoid, NPOBJ npShot );
  165. VOID NEAR PASCAL DrawRoids( HDC hDC );
  166. VOID NEAR PASCAL DrawShots( HDC hDC );
  167. VOID NEAR PASCAL DrawFlames( HDC hDC );
  168. VOID NEAR PASCAL FireShot( VOID );
  169. VOID NEAR PASCAL AccelPlayer( INT nDir, INT nAccel );
  170. VOID NEAR PASCAL DrawPlayer( HDC hDC );
  171. VOID NEAR PASCAL DrawObjects( HWND hWnd );
  172. VOID NEAR PASCAL CheckScore( HWND hWnd );
  173. VOID NEAR PASCAL HitList( HDC hDC, NPLIST npList );
  174. VOID NEAR PASCAL ExplodeBadguys( HDC hDC, NPLIST npList );
  175. VOID NEAR PASCAL NewGame( HWND hWnd );
  176. VOID NEAR PASCAL RestartHyperoid( VOID );
  177. VOID NEAR PASCAL Panic( BOOL bPanic );
  178. VOID NEAR PASCAL PaintHyperoid( HWND hWnd );
  179. VOID NEAR PASCAL DisableHyperoidInput( HWND hWnd, BOOL bCapture );
  180. LONG FAR PASCAL EXPORT HyperoidWndProc( HWND hWnd, unsigned message, WORD wParam, LONG lParam );
  181. BOOL NEAR PASCAL InitHyperoid( VOID );
  182. VOID NEAR PASCAL ExitHyperoid( VOID );
  183. INT FAR PASCAL WinMain( HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, INT nCmdShow );
  184.  
  185. // roidsupp.c
  186. VOID FAR PASCAL PrintLetters( NPSTR npszText, POINT Pos, POINT Vel, BYTE byColor, INT nSize );
  187. VOID FAR PASCAL SpinLetters( NPSTR npszText, POINT Pos, POINT Vel, BYTE byColor, INT nSize );
  188. HPALETTE FAR PASCAL CreateHyperoidPalette( VOID );
  189. BOOL FAR PASCAL CreateHyperoidClass( VOID );
  190. VOID NEAR PASCAL SetHyperoidMenu( HWND hWnd, INT nFirstID, INT nLastID );
  191. HWND FAR PASCAL CreateHyperoidWindow( LPSTR lpszCmd, INT nCmdShow );
  192. VOID FAR PASCAL SaveHyperoidWindowPos( HWND hWnd );
  193. VOID FAR PASCAL GetHyperoidIni( VOID );
  194. VOID FAR PASCAL HyperoidHelp( HWND hWnd );
  195. BOOL FAR PASCAL EXPORT HyperoidAboutDlg( HWND hDlg, WORD mess, WORD wParam, LONG lParam );
  196. VOID FAR PASCAL AboutHyperoid( HWND hWnd );
  197.  
  198. #endif // RC_INVOKED //
  199.  
  200. //
  201. // resource IDs
  202. //
  203.  
  204. // icons and bitmaps
  205. #define IDI_HYPEROID    10
  206. #define IDI_PANIC       20
  207.  
  208. // bitmaps
  209. #define IDB_blank       50
  210. #define IDB_bomb        51
  211. #define IDB_level       52
  212. #define IDB_life        53
  213. #define IDB_num0        54
  214. #define IDB_num1        55
  215. #define IDB_num2        56
  216. #define IDB_num3        57
  217. #define IDB_num4        58
  218. #define IDB_num5        59
  219. #define IDB_num6        60
  220. #define IDB_num7        61
  221. #define IDB_num8        62
  222. #define IDB_num9        63
  223. #define IDB_plus        64
  224. #define IDB_score       65
  225. #define IDB_shield      66
  226. // additional bitmap stuff
  227. #define IDB_MAX         17
  228. #define CX_BITMAP       16
  229. #define CY_BITMAP       16
  230.  
  231. // strings
  232. #define IDS_NAME        100
  233.  
  234. // menus
  235. #define IDM_NEW         200
  236. #define IDM_ABOUT       201
  237.  
  238. // about box
  239. #define IDD_ABOUT       500
  240. #define IDD_A_HELP      501
  241. #define IDD_A_HISCORE   502
  242.