home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / wxos2233.zip / wxOS2-2_3_3.zip / wxWindows-2.3.3 / demos / bombs / game.h < prev    next >
C/C++ Source or Header  |  2000-01-08  |  1KB  |  43 lines

  1. //---------------------------------------------------------------
  2. // game.h
  3. // Definition of the class BombsGame, containing the data for a
  4. // playfield
  5. //---------------------------------------------------------------
  6. #ifndef GAME_H
  7. #define GAME_H
  8.  
  9. #define BG_HIDDEN   0x100
  10. #define BG_BOMB     0x200
  11. #define BG_MARKED   0x400
  12. #define BG_EXPLODED 0x800
  13. #define BG_MASK     0x0FF
  14.  
  15.  
  16. #include <stddef.h>
  17.  
  18. class BombsGame
  19.   { protected:
  20.       int width,height;
  21.       short *field;
  22.       int bombs,normal_cells;
  23.     public:
  24.       BombsGame() { width=height=0; field=NULL; };
  25.       ~BombsGame();
  26.       int Init(int width, int height);
  27.       int GetWidth() { return width; };
  28.       int GetHeight() { return height; };
  29.       int Get(int x, int y) { return field[x+y*width]; };
  30.       void Mark(int x, int y);
  31.       void Unhide(int x, int y);
  32.       void Explode(int x, int y);
  33.       int IsHidden(int x, int y) { return Get(x,y) & BG_HIDDEN; };
  34.       int IsMarked(int x, int y) { return Get(x,y) & BG_MARKED; };
  35.       int IsBomb(int x, int y) { return Get(x,y) & BG_BOMB; };
  36.       int IsExploded(int x, int y) { return Get(x,y) & BG_EXPLODED; };
  37.       int GetBombs() { return bombs; };
  38.       int GetRemainingCells() { return normal_cells; };
  39.   };
  40.  
  41. #endif /* def GAME_H */
  42.  
  43.