home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / v / vol1n7.zip / HEXES.H < prev    next >
Text File  |  1992-09-29  |  4KB  |  122 lines

  1. /* HEXES.H
  2.  
  3. Copyright (c) 1992 Timur Tabi
  4. Copyright (c) 1992 Fasa Corporation                                               
  5.                                                                                   
  6. The following trademarks are the property of Fasa Corporation:                    
  7. BattleTech, CityTech, AeroTech, MechWarrior, BattleMech, and 'Mech.
  8. The use of these trademarks should not be construed as a challenge to these marks.
  9.  
  10. This file assumes that it is included after os2.h
  11.  
  12. The file HEX.PCX is a diagram describing the dimensions of a hexagon.
  13. HEX_SIDE is given a value, the others are all derived from it.
  14.  
  15. The hex map is indexed as shown:
  16.              __      __      __      __
  17.             /  \    /  \    /  \    /  \
  18.          __/ 15 \__/ 35 \__/ 55 \__/ 75 \__
  19.         /  \    /  \    /  \    /  \    /  \   
  20.        / 04 \__/ 24 \__/ 44 \__/ 64 \__/ 84 \
  21.        \    /  \    /  \    /  \    /  \    /
  22.         \__/ 13 \__/ 33 \__/ 53 \__/ 73 \__/ 
  23.         /  \    /  \    /  \    /  \    /  \ 
  24.        / 02 \__/ 22 \__/ 42 \__/ 62 \__/ 82 \
  25.        \    /  \    /  \    /  \    /  \    /
  26.         \__/ 11 \__/ 31 \__/ 51 \__/ 71 \__/ 
  27.         /  \    /  \    /  \    /  \    /  \ 
  28.        / 00 \__/ 20 \__/ 40 \__/ 60 \__/ 80 \
  29.        \    /  \    /  \    /  \    /  \    /
  30.         \__/    \__/    \__/    \__/    \__/ 
  31.  
  32. */
  33.  
  34. #define HEX_SIDE 14              // Must be even
  35. #define HEX_HEIGHT 24            // 2 * sin(60) * HEX_SIDE, must be be even
  36. #define HEX_EXT (HEX_SIDE/2)     // HEX_SIDE * cos(60)
  37. #define HEX_DIAM (HEX_SIDE*2)    // The long diameter (width)
  38. #define HEX_COLOR CLR_BLACK
  39.  
  40. // The next two values must be odd
  41. #define NUM_COLUMNS 21           // The number of columns on the map
  42. #define NUM_ROWS 35              // The number of rows.
  43.  
  44. typedef struct {          // The column and row index of a hex
  45.   int c;
  46.   int r;
  47. } HEXINDEX;
  48.   
  49. typedef struct {
  50.   int iTerrain;        // Terrain ID
  51.   SBYTE sbHeight;       // The height, where ground level is zero
  52. } MAP;
  53.  
  54. // Global variables
  55. #ifdef HEXES_C
  56. #define EXTERN
  57. #else
  58. #define EXTERN extern
  59. #endif
  60.  
  61. EXTERN HPS hpsHex;                             // The PS handle for all hex drawing
  62. EXTERN long lNumColors;                        // The number of colors, for HexHighlight()
  63. EXTERN MAP amap[NUM_COLUMNS][NUM_ROWS];        // Data for each hex on the map
  64. EXTERN MAP mapDefault;
  65.  
  66. #undef EXTERN
  67.  
  68. // Determine whether two hex indices are equal
  69. #define HI_EQUAL(hi1,hi2) (hi1.c==hi2.c && hi1.r==hi2.r)
  70.  
  71. POINTL HexCoord(HEXINDEX);
  72. // Returns the X,Y coordinate of the bottom-left corner of a hex
  73.  
  74. POINTL HexMidpoint(HEXINDEX);
  75. // Returns the X,Y coordinate of the midpoint of a hex
  76.  
  77. void HexDraw(HPS, HEXINDEX);
  78. // Draws a single hex outline
  79.  
  80. void HexFillDraw(HEXINDEX hi);
  81. // Draws a hex with outline HEX_COLOR and filled with the terrain color
  82.  
  83. BYTE HexTerrainColor(int iTerrain);
  84. // Returns the color associated with the given terrain type
  85.  
  86. BYTE HexTerrainPattern(int iTerrain);
  87. // Returns the background pattern associated with the given terrain type
  88.  
  89. BYTE HexTerrainVisibility(int iTerrain);
  90. // Returns the visibility associated with the given terrain type
  91.  
  92. void HexInitMap(void);
  93. // Initializes the map array
  94.  
  95. BOOL HexInPoint(POINTL, HEXINDEX);
  96. // Returns true of a given X,Y point is within a given hex
  97.  
  98. BOOL HexLocate(POINTL, HEXINDEX *);
  99. // Returns the hex index of the given X,Y coordinate
  100.  
  101. void HexDrawMap(HWND);
  102. // Draws the playing field
  103.  
  104. void APIENTRY HexHighlight(ULONG);
  105. // Thread which highlights the starting hex
  106.  
  107. HEXINDEX HexNextShortest(HEXINDEX, HEXINDEX);
  108. // Returns the next hex in a shortest-distance path from hi1 to hi2
  109.  
  110. int HexNextSide(HEXINDEX hi, int iSide, POINTL ptl1, POINTL ptl2);
  111. // returns the exiting side of hi through which a line from ptl1 to ptl would pass,
  112. //  if it entered at side iSide
  113.  
  114. HEXINDEX HexFromSide(HEXINDEX, int iSide);
  115. // returns the hex that is across side iSide of hex hi
  116.  
  117. int HexFirstSide(HEXINDEX, HEXINDEX);
  118. // returns the side of hi1 through which the target line to hi2 passes
  119.  
  120. void HexPointFromSide(HEXINDEX, int iSide, PPOINTL, PPOINTL);
  121. // Sets pptl1 & pptl2 to the two endpoints of side iSide of the hexagon
  122.