home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mnth0104.zip / Timur / hexes.H < prev    next >
Text File  |  1992-05-12  |  3KB  |  80 lines

  1. /* HEXES.H: Header file for hexes.c
  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.          __/ 26 \__/ 46 \__/ 66 \__/ 86 \__
  19.         /  \    /  \    /  \    /  \    /  \   
  20.        / 15 \__/ 35 \__/ 55 \__/ 75 \__/ 95 \
  21.        \    /  \    /  \    /  \    /  \    /
  22.         \__/ 24 \__/ 44 \__/ 64 \__/ 84 \__/ 
  23.         /  \    /  \    /  \    /  \    /  \ 
  24.        / 13 \__/ 33 \__/ 53 \__/ 73 \__/ 93 \
  25.        \    /  \    /  \    /  \    /  \    /
  26.         \__/ 22 \__/ 42 \__/ 62 \__/ 82 \__/ 
  27.         /  \    /  \    /  \    /  \    /  \ 
  28.        / 11 \__/ 31 \__/ 51 \__/ 71 \__/ 91 \
  29.        \    /  \    /  \    /  \    /  \    /
  30.         \__/    \__/    \__/    \__/    \__/ 
  31.  
  32. */
  33.  
  34. #define HEX_SIDE 26              // Must be even
  35. #define HEX_HEIGHT 44            // 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_DARKGRAY
  39.  
  40. // The next two values must be odd
  41. #define NUM_COLUMNS 15           // The number of columns on the map
  42. #define NUM_ROWS 15              // The number of rows.
  43.  
  44. // Determine whether two hex indices are equal
  45. #define HI_EQUAL(hi1,hi2) (hi1.c==hi2.c && hi1.r==hi2.r)
  46.  
  47. typedef struct {          // The column and row index of a hex
  48.   int c;
  49.   int r;
  50. } HEXINDEX;
  51.   
  52. typedef struct _TARGET {  // Data for the targetting mechanism
  53.    BOOL fActive;          // TRUE if we are drawing the targetting line   
  54.    HEXINDEX hiStart;      // The index of the starting hex
  55.    HEXINDEX hiEnd;        // The index of the ending hex
  56.    POINTL ptlStart;       // The X,Y coordinate of the line's origin          
  57.    POINTL ptlEnd;         // The X,Y coordinate of the line's end
  58.    HPS hpsLine;           // The HPS for target-line drawing
  59.    HPS hpsHighlight;      // The HPS for origin hex highlighting
  60.    TID tid;               // Thread ID
  61. } TARGET;
  62.  
  63. POINTL HexCoord(HEXINDEX);
  64. // Returns the X,Y coordinate of the bottom-left corner of a hex
  65.  
  66. POINTL HexMidpoint(HEXINDEX);
  67. // Returns the X,Y coordinate of the midpoint of a hex
  68.  
  69. void HexDraw(HPS, HEXINDEX);
  70. // Draws a single hex
  71.  
  72. BOOL HexInPoint(POINTL, HEXINDEX);
  73. // Returns true of a given X,Y point is within a given hex
  74.  
  75. BOOL HexLocate(POINTL, HEXINDEX *);
  76. // Returns the hex index of the given X,Y coordinate
  77.  
  78. VOID APIENTRY HexHighlight(ULONG);
  79. // Thread which highlights the starting hex
  80.