home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XGAMES / XHEXTRIS.TAR / header.h next >
Encoding:
C/C++ Source or Header  |  1990-04-27  |  7.3 KB  |  181 lines

  1. /*
  2.  * hextris Copyright 1990 David Markley, dm3e@+andrew.cmu.edu, dam@cs.cmu.edu
  3.  *
  4.  * Permission to use, copy, modify, and distribute, this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided that
  6.  * the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of the copyright holders be used in
  9.  * advertising or publicity pertaining to distribution of the software with
  10.  * specific, written prior permission, and that no fee is charged for further
  11.  * distribution of this software, or any modifications thereof.  The copyright
  12.  * holder make no representations about the suitability of this software for
  13.  * any purpose.  It is provided "as is" without express or implied warranty.
  14.  *
  15.  * THE COPYRIGHT HOLDER DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  16.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  17.  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  18.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  19.  * DATA, PROFITS, QPA OR GPA, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
  20.  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21.  * PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23.  
  24. /* The maximum rows in the game.
  25.  */
  26. #define MAXROW 26
  27. /* The maximum columns in the game.
  28.  */
  29. #define MAXCOLUMN 13
  30. /* The number of high scores that are kept.
  31.  */
  32. #define MAXHIGHSCORES 500
  33. /* The maximum length of the user defined name.
  34.  * The user can set his hextris playing name by setting the
  35.  * environment variable XHEXNAME, like this:
  36.  * setenv XHEXNAME "Mr. Xhextris"
  37.  */
  38. #define MAXNAMELENGTH 40
  39. /* The maximum length of the users id.
  40.  */
  41. #define MAXUSERIDLENGTH 5
  42. /* The maximum nuber of high scores a user can have in the high score file.
  43.  */
  44. #define MAXUSERHIGHS 3
  45. /* The number of pieces in the game. DON'T CHANGE!!!
  46.  */
  47. #define NUMBEROFPIECES 10
  48. /* The name of the xhextris font. DON'T CHANGE!!!
  49.  */
  50. #define HEXFONTNAME "xhextris"
  51. /* The directory where the text font is.
  52.  */
  53. #define FONTDIR "/usr/lib/X11/fonts/misc/"
  54. /* The text font being used.
  55.  */
  56. #define FONTNAME "8x13bold"
  57. /* The name on the window.
  58.  */
  59. #define WINDOWNAME "xhextris"
  60. /* The name on the icon.
  61.  */
  62. #define ICONNAME "xhextris"
  63.  
  64. /* Don't worry about this stuff, it's Andrew specific.
  65.  */
  66. #ifdef sun4_40
  67. #define FONTDIR "/afs/andrew.cmu.edu/usr10/dm3e/.fonts/.X11/sun4_40/"
  68. #define HIGHSCOREDIR "/afs/andrew.cmu.edu/usr10/dm3e/.logs/"
  69. #endif
  70.  
  71. #ifdef mac2_51
  72. #define FONTDIR "/afs/andrew.cmu.edu/usr10/dm3e/.fonts/.X11/mac2_51/"
  73. #define HIGHSCOREDIR "/afs/andrew.cmu.edu/usr10/dm3e/.logs/"
  74. #endif
  75.  
  76. /* This is the type definition for a piece.
  77.  */
  78. typedef struct piece_s
  79. {
  80.     int    type;
  81.     int    rotation;
  82.     int row;
  83.     int column;
  84. } piece_t;
  85.  
  86. /* This is the type definition for a position.
  87.  */
  88. typedef struct position_s
  89. {
  90.     int type;
  91.     int filled;
  92. } position_t;
  93.  
  94. /* This is the type definition for a high score.
  95.  */
  96. typedef struct high_score_s
  97. {
  98.     char name[MAXNAMELENGTH];
  99.     char userid[MAXUSERIDLENGTH];
  100.     int score;
  101.     int rows;
  102. } high_score_t;
  103.  
  104. /* This is the mess that defines each piece. There are six rotations to
  105.  * each piece, so there are six rows of numbers to each piece. For example,
  106.  * the second rotation of the third piece is on the row labled 21. Each row
  107.  * has 16 numbers, that can be broken down into 2 sets of 4 pairs. Each pair
  108.  * is a set of relative coordinates inf row and column from the current
  109.  * position of the piece. There are two sets of 4 pairs, because the offsets
  110.  * differ depending on whether the current position of the piece is in a
  111.  * hex that is up to its neighbors in its row, or down to them. One row in the
  112.  * game moves up and down, from left to right.
  113.  */
  114. static int shape[NUMBEROFPIECES*6][16]
  115.   = {{0,0,-1,0,1,-1,1,1,-1,0,0,-1,0,1,0,0},       /* 00 */
  116.        {0,0,0,-1,0,1,1,0,-1,-1,-1,1,1,0,0,0},     /* 01 */
  117.        {0,0,-1,0,1,-1,1,1,-1,0,0,-1,0,1,0,0},     /* 02 */
  118.        {0,0,0,-1,0,1,1,0,-1,-1,-1,1,1,0,0,0},     /* 03 */
  119.        {0,0,-1,0,1,-1,1,1,-1,0,0,-1,0,1,0,0},     /* 04 */
  120.        {0,0,0,-1,0,1,1,0,-1,-1,-1,1,1,0,0,0},     /* 05 */
  121.        {0,0,-1,0,1,0,2,0,-1,0,1,0,2,0,0,0},       /* 10 */
  122.        {0,0,0,-1,1,1,1,2,-1,-1,0,1,1,2,0,0},      /* 11 */
  123.        {0,0,1,-1,0,1,-1,2,0,-1,-1,1,-1,2,0,0},    /* 12 */
  124.        {0,0,-2,0,-1,0,1,0,-2,0,-1,0,1,0,0,0},     /* 13 */
  125.        {0,0,-1,-2,0,-1,1,1,-1,-2,-1,-1,0,1,0,0},  /* 14 */
  126.        {0,0,1,-2,1,-1,0,1,1,-2,0,-1,-1,1,0,0},    /* 15 */
  127.        {0,0,-1,0,1,0,1,1,-1,0,1,0,0,1,0,0},       /* 20 */
  128.        {0,0,0,-1,1,1,0,1,-1,-1,0,1,-1,1,0,0},     /* 21 */
  129.        {0,0,1,-1,0,1,-1,0,0,-1,-1,0,-1,1,0,0},    /* 22 */
  130.        {0,0,0,-1,-1,0,1,0,-1,-1,-1,0,1,0,0,0},    /* 23 */
  131.        {0,0,0,-1,1,-1,1,1,0,-1,-1,-1,0,1,0,0},    /* 24 */
  132.        {0,0,1,-1,1,0,0,1,0,-1,1,0,-1,1,0,0},      /* 25 */
  133.        {0,0,-1,0,1,-1,1,0,-1,0,0,-1,1,0,0,0},     /* 30 */
  134.        {0,0,0,-1,1,0,1,1,-1,-1,1,0,0,1,0,0},      /* 31 */
  135.        {0,0,1,-1,0,1,1,1,0,-1,-1,1,0,1,0,0},      /* 32 */
  136.        {0,0,-1,0,1,0,0,1,-1,0,1,0,-1,1,0,0},      /* 33 */
  137.        {0,0,0,-1,-1,0,1,1,-1,-1,-1,0,0,1,0,0},    /* 34 */
  138.        {0,0,0,-1,1,-1,0,1,-1,-1,0,-1,-1,1,0,0},   /* 35 */
  139.        {-1,0,0,-1,1,-1,1,0,-1,0,-1,-1,0,-1,1,0},  /* 40 */
  140.        {0,-1,1,-1,1,0,1,1,-1,-1,0,-1,1,0,0,1},    /* 41 */
  141.        {1,-1,1,0,1,1,0,1,0,-1,1,0,0,1,-1,1},      /* 42 */
  142.        {1,0,1,1,0,1,-1,0,1,0,0,1,-1,1,-1,0},      /* 43 */
  143.        {1,1,0,1,-1,0,0,-1,0,1,-1,1,-1,0,-1,-1},   /* 44 */
  144.        {0,1,-1,0,0,-1,1,-1,-1,1,-1,0,-1,-1,0,-1}, /* 45 */
  145.        {-1,0,1,1,2,1,0,0,-1,0,0,0,0,1,1,1},       /* 50 */
  146.        {0,-1,0,0,0,1,0,2,-1,-1,0,0,-1,1,0,2},     /* 51 */
  147.        {1,-1,0,0,-1,0,-1,1,0,-1,0,0,-1,0,-2,1},   /* 52 */
  148.        {1,0,0,0,0,-1,-1,-1,1,0,0,0,-1,-1,-2,-1},  /* 53 */
  149.        {0,-2,1,-1,0,0,1,1,0,-2,0,-1,0,0,0,1},     /* 54 */
  150.        {2,-1,1,0,0,0,0,1,1,-1,1,0,0,0,-1,1},      /* 55 */
  151.        {0,0,1,-1,1,0,1,1,0,0,0,-1,1,0,0,1},      /* 60 */
  152.        {0,0,1,0,1,1,0,1,0,0,1,0,0,1,-1,1},      /* 61 */
  153.        {0,0,1,1,0,1,-1,0,0,0,0,1,-1,1,-1,0},      /* 62 */
  154.        {0,0,0,1,-1,0,0,-1,0,0,-1,1,-1,0,-1,-1},   /* 63 */
  155.        {0,0,-1,0,0,-1,1,-1,0,0,-1,0,-1,-1,0,-1},  /* 64 */
  156.        {0,0,0,-1,1,-1,1,0,0,0,-1,-1,0,-1,1,0},    /* 65 */
  157.        {-1,0,0,0,1,0,2,1,-1,0,0,0,1,0,1,1},      /* 70 */
  158.        {0,-1,0,0,1,1,0,2,-1,-1,0,0,0,1,0,2},      /* 71 */
  159.        {1,-1,0,0,0,1,-1,1,0,-1,0,0,-1,1,-2,1},    /* 72 */
  160.        {1,0,0,0,-1,0,-1,-1,1,0,0,0,-1,0,-2,-1},   /* 73 */
  161.        {0,-2,0,-1,0,0,1,1,0,-2,-1,-1,0,0,0,1},    /* 74 */
  162.        {2,-1,1,-1,0,0,0,1,1,-1,0,-1,0,0,-1,1},    /* 75 */
  163.        {-1,0,0,0,1,0,2,-1,-1,0,0,0,1,0,1,-1},     /* 80 */
  164.        {0,-1,0,0,1,1,2,1,-1,-1,0,0,0,1,1,1},      /* 81 */
  165.        {1,-1,0,0,0,1,0,2,0,-1,0,0,-1,1,0,2},      /* 82 */
  166.        {1,0,0,0,-1,0,-1,1,1,0,0,0,-1,0,-2,1},     /* 83 */
  167.        {-1,-1,0,-1,0,0,1,1,-2,-1,-1,-1,0,0,0,1},  /* 84 */
  168.        {0,-2,1,-1,0,0,0,1,0,-2,0,-1,0,0,-1,1},    /* 85 */
  169.        {-1,0,0,0,1,-1,2,-1,-1,0,0,0,0,-1,1,-1},   /* 90 */
  170.        {0,-1,0,0,1,0,2,1,-1,-1,0,0,1,0,1,1},      /* 91 */
  171.        {1,-1,0,0,1,1,0,2,0,-1,0,0,0,1,0,2},       /* 92 */
  172.        {1,0,0,0,0,1,-1,1,1,0,0,0,-1,1,-2,1},      /* 93 */
  173.        {1,1,0,0,-1,0,-1,-1,0,1,0,0,-1,0,-2,-1},   /* 94 */
  174.        {0,-2,0,-1,0,0,0,1,0,-2,-1,-1,0,0,-1,1}};  /* 95 */
  175.  
  176. #ifdef LOG
  177. #define LOGHOST "waddington.andrew.cmu.edu"
  178. char log_message[80];
  179. #endif
  180.  
  181.