home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / Concentration / Concentration.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-25  |  4.5 KB  |  214 lines  |  [TEXT/KAHL]

  1. /*
  2.  * Concentation.h - Concentration header file
  3.  */
  4.  
  5. # ifndef    __BLOBMGR_H__
  6. # include    "BlobMgr.h"
  7. # endif
  8.  
  9.  
  10. /*
  11.  * Horizontal and vertical ratios for positioning dialogs on the screen
  12.  * according the Apple's (current) Human Interface Guidelines.
  13.  */
  14.  
  15. # define    horizRatio        FixRatio (1, 2)
  16. # define    vertRatio        FixRatio (1, 5)
  17.  
  18.  
  19. /*
  20.  * Resource numbers
  21.  */
  22.  
  23. typedef enum
  24. {
  25.     aboutAlrtNum = 1000,    /* "About Concentration..." alert */
  26.     playerDlogNum = 1002,    /* "Players..." dialog */
  27.     boardDlogNum,            /* "Board Size..." dialog */
  28.     msgeAlrtNum,            /* generic message alert */
  29.  
  30.     fileMenuNum = 1000,
  31.     editMenuNum,
  32.     gameMenuNum,
  33.     
  34.     helpTextNum = 1000        /* 'TEXT' resource for Help window */
  35. };
  36.  
  37.  
  38. typedef enum                /* game piece sizes */
  39. {
  40.     largePiece,
  41.     smallPiece
  42. };
  43.  
  44.  
  45. typedef enum                /* game piece types */
  46. {
  47.     iconType,                /* 'ICON' */
  48.     cicnType,                /* 'cicn' */
  49.     sicnType                /* 'SICN' */
  50. };
  51.  
  52.  
  53. # define    iconSize    32    /* icon's are 32x32 pixels */
  54. # define    sitmSize    16    /* sicn items are 16x16 pixels */
  55. # define    iconGap        9    /* gap between large pieces */
  56. # define    sitmGap        11    /* gap between small pieces */
  57.  
  58. /*
  59.  * SICN item.  this is an array, but it's defined as an array inside
  60.  * a structure so x = y assignments can be done.
  61.  */
  62.  
  63. typedef    struct Sitm    Sitm, **SitmHandle;
  64.  
  65. struct Sitm
  66. {
  67.     short sitmData[sitmSize];
  68. };
  69. typedef Sitm    Sicn[1];            /* SICN is (variable-length) array of sitms */
  70. typedef Sicn     **SicnHandle;
  71.  
  72.  
  73. /*
  74.  * Game piece structure.  The type member indicates the type of the data
  75.  * member.  Operations that manipulate the data use the type to know now
  76.  * to cast the data handle properly.
  77.  */
  78.  
  79. typedef    struct Piece    Piece;
  80.  
  81. struct Piece
  82. {
  83.     short    pieceType;
  84.     Handle    pieceData;
  85. };
  86.  
  87. # define    maxPieces    200
  88.  
  89. /*
  90.  * For each type of piece (large or small), there must be enough of them
  91.  * available to make the requisite number of pairs for a given board size,
  92.  * i.e., (rows * cols) / 2.
  93.  *
  94.  * Maximum and default board dimensions MUST multiply to an even number of squares.
  95.  */
  96.  
  97. # define    maxLargeRows    6    /* maximum and default number of */
  98. # define    maxLargeCols    8    /* large-piece rows and columns */
  99. # define    defLargeRows    6
  100. # define    defLargeCols    8
  101.  
  102. # define    maxSmallRows    9    /* maximum and default number of */
  103. # define    maxSmallCols    12    /* small-piece rows and columns */
  104. # define    defSmallRows    6
  105. # define    defSmallCols    8
  106.  
  107.  
  108. /*
  109.  * Gameboard location, size
  110.  */
  111.  
  112. # define    gbHOffset    160    /* horizontal and vertical offsets */
  113. # define    gbVOffset    9    /* of game board upper left blob */
  114.  
  115.  
  116. /*
  117.  * Gameboard structure.  There is one of these for each size of piece that
  118.  * may be used.
  119.  */
  120.  
  121. typedef    struct    GameBoard    GameBoard;
  122.  
  123. struct GameBoard
  124. {
  125.     short    sizeType;                /* size type of game pieces (large, small) */
  126.     short    maxRows;                /* maximum dimensions of board */
  127.     short    maxCols;
  128.     short    defRows;                /* default (starting) dimensions of board */
  129.     short    defCols;
  130.     short    nRows;                    /* current dimensions of board */
  131.     short    nCols;
  132.     short    pieceSize;                /* size of board pieces */
  133.     short    pieceGap;                /* gap between board pieces */
  134.     short    nPieces;                /* number of pieces actually available */
  135.     Piece    piece[maxPieces];        /* array of board pieces */
  136. };
  137.  
  138.  
  139. /*
  140.  * Scoreboard location, size
  141.  */
  142.  
  143. # define    maxPlayers    4
  144.  
  145. # define    sbHOffset        14
  146. # define    sbVOffset        15
  147. # define    sbNameWidth        100
  148. # define    sbScoreWidth    30
  149. # define    sbWidth            (sbNameWidth + sbScoreWidth)
  150. # define    sbSlotHeight    26            /* height of single slot */
  151. # define    sbHeight        (sbSlotHeight * (maxPlayers + 1))    /* +1 allows for title */
  152.  
  153.  
  154. /*
  155.  * Scoreboard information structure.  Contains name and score for maximum
  156.  * number of players, the actual current number of players, the player whose
  157.  * turn it currently is, and who the first player was.  First player rotates
  158.  * to next player on each new round of the game.
  159.  */
  160.  
  161. typedef    struct ScoreBoard    ScoreBoard;
  162.  
  163. struct ScoreBoard
  164. {
  165.     Str255    name[maxPlayers];
  166.     short    score[maxPlayers];
  167.     short    nPlayers;
  168.     short    player;
  169.     short    firstPlayer;
  170. };
  171.  
  172.  
  173. extern WindowPtr    gameWind;
  174. extern GameBoard    *gb;
  175. extern ScoreBoard    *sb;
  176.  
  177.  
  178. /* Main.c */
  179.  
  180. void Bail (StringPtr msg);
  181.  
  182. /* Concentration.c */
  183.  
  184. void ReadPieces (void);
  185. void InitBoard (short pieceSize);
  186. void NewGameRound (void);
  187. void ShowAnswer (void);
  188. void WindInit (void);
  189.  
  190. /* ScoreBoard.c */
  191.  
  192. void ResetScoreBoard (Boolean advanceFirstPlayer);
  193. void DrawScoreBoard (void);
  194. void DrawPlayerInfo (short n);
  195. void FlashPlayerFrame (short n);
  196. void HiliteWinner (void);
  197.  
  198. /* Menu.c */
  199.  
  200. void SetupMenus (void);
  201.  
  202. /* Dialog.c */
  203.  
  204. void PlayerDialog (void);
  205. void BoardDialog (void);
  206.  
  207. /* Lib.c */
  208.  
  209. void MakeBlob (BlobSetHandle bSet, short h, short v, short type);
  210.  
  211. /* Help.c */
  212.  
  213. void HelpWindow (void);
  214.