home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_10 / 1010109a < prev    next >
Text File  |  1992-08-10  |  1KB  |  59 lines

  1. #ifndef GAME_H
  2. #define GAME_H
  3.  
  4. typedef enum { PAWN, BISHOP, ROOK, KING } GAME_PIECE;
  5. typedef struct {
  6.     int   vertical;
  7. } PAWN_MOVE_STRUCT;
  8.  
  9. typedef PAWN_MOVE_STRUCT   *PAWN_MOVE;
  10.  
  11. typedef struct {
  12.     int    diagonal;
  13. } BISHOP_MOVE_STRUCT;
  14.  
  15. typedef BISHOP_MOVE_STRUCT   *BISHOP_MOVE;
  16.  
  17. typedef struct {
  18.     int    vertical;
  19.     int    horizontal;
  20. } ROOK_MOVE_STRUCT;
  21.  
  22. typedef ROOK_MOVE_STRUCT   *ROOK_MOVE;
  23.  
  24. typedef struct {
  25.     int    vertical;
  26.     int    horizontal;
  27.     int    diagonal;
  28. } KING_MOVE_STRUCT;
  29.  
  30. typedef KING_MOVE_STRUCT   *KING_MOVE;
  31.  
  32. typedef union {
  33.     PAWN_MOVE      PawnM;
  34.     BISHOP_MOVE    BishopM;
  35.     ROOK_MOVE      RookM;
  36.     KING_MOVE      KingM;
  37. } MOVE_U;
  38.  
  39. typedef MOVE_U          *MOVE;
  40.  
  41. class piece {
  42.  
  43.    public:
  44.     piece ();            // constructor and destructor have the
  45.     ~piece ();            // same name as the class.
  46.     piece_position ();        // declaration of public interfaces to
  47.     pawn_move ();            // the class piece.
  48.     bishop_move ();
  49.     rook_move ();
  50.     king_move ();
  51.    private:
  52.     GAME_PIECE     piece_type;    // private data for the class
  53.     MOVE           move;        // piece.  Can only be accessed
  54.     int            x_coord;        // through encapsulated member
  55.     int            y_coord;        // functions or friends.
  56. };
  57.  
  58. #endif   // GAME_H 
  59.