home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mnth0106.zip / Timur / HEXES.H < prev    next >
Text File  |  1992-06-14  |  4KB  |  115 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 29           // 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 {          // Data for the targetting mechanism
  50.    BOOL fActive;          // TRUE if we are drawing the targetting line   
  51.    HEXINDEX hiStart;      // The index of the starting hex
  52.    HEXINDEX hiEnd;        // The index of the ending hex
  53.    POINTL ptlStart;       // The X,Y coordinate of the line's origin          
  54.    POINTL ptlEnd;         // The X,Y coordinate of the line's end
  55.    HPS hpsLine;           // The HPS for target-line drawing
  56.    HPS hpsHighlight;      // The HPS for origin hex highlighting
  57.    TID tid;               // Thread ID
  58. } TARGET;
  59.  
  60. typedef signed char SBYTE; // Hmmm... is this already defined somewhere?
  61.  
  62. typedef struct {
  63.   BYTE bTerrain;        // Terrain ID
  64.   SBYTE sbHeight;       // The height, where ground level is zero
  65. } MAP;
  66.  
  67. // Global variables
  68. #ifdef HEXES_C
  69. #define EXTERN
  70. #else
  71. #define EXTERN extern
  72. #endif
  73.  
  74. EXTERN HPS hpsHex;                             // The PS handle for all hex drawing
  75. EXTERN TARGET target;                          // User-controlled targetting
  76. EXTERN long lNumColors;                        // The number of colors, for HexHighlight()
  77. EXTERN MAP amap[NUM_COLUMNS][NUM_ROWS];       // Data for each hex on the map
  78. EXTERN MAP mapDefault;
  79.  
  80. #undef EXTERN
  81.  
  82. // Determine whether two hex indices are equal
  83. #define HI_EQUAL(hi1,hi2) (hi1.c==hi2.c && hi1.r==hi2.r)
  84.  
  85. POINTL HexCoord(HEXINDEX);
  86. // Returns the X,Y coordinate of the bottom-left corner of a hex
  87.  
  88. POINTL HexMidpoint(HEXINDEX);
  89. // Returns the X,Y coordinate of the midpoint of a hex
  90.  
  91. void HexShow(HPS hps, HEXINDEX hi);
  92.  
  93. void HexDraw(HPS, HEXINDEX);
  94. // Draws a single hex outline
  95.  
  96. void HexFillDraw(HEXINDEX hi);
  97. // Draws a hex with outline HEX_COLOR and filled with the terrain color
  98.  
  99. BYTE HexTerrainColor(USHORT usTerrain);
  100. // Returns the color associated with the given terrain type
  101.  
  102. BYTE HexTerrainPattern(USHORT usTerrain);
  103.  
  104. void HexInitMap(void);
  105. // Initializes the map array
  106.  
  107. BOOL HexInPoint(POINTL, HEXINDEX);
  108. // Returns true of a given X,Y point is within a given hex
  109.  
  110. BOOL HexLocate(POINTL, HEXINDEX *);
  111. // Returns the hex index of the given X,Y coordinate
  112.  
  113. VOID APIENTRY HexHighlight(ULONG);
  114. // Thread which highlights the starting hex
  115.