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