]> git.saurik.com Git - wxWidgets.git/blob - demos/bombs/game.h
added setup.h file containing the settings common to all ports and a script to update...
[wxWidgets.git] / demos / bombs / game.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: game.h
3 // Purpose: Bombs game
4 // Author: P. Foggia 1996
5 // Modified by: Wlodzimierz Skiba (ABX) 2003
6 // Created: 1996
7 // RCS-ID: $Id$
8 // Copyright: (c) 1996 P. Foggia
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DEMOS_BOMBS_GAME_H_
13 #define _WX_DEMOS_BOMBS_GAME_H_
14
15 #define BG_HIDDEN 0x100
16 #define BG_BOMB 0x200
17 #define BG_MARKED 0x400
18 #define BG_EXPLODED 0x800
19 #define BG_MASK 0x0FF
20
21 #include <stddef.h>
22
23 class BombsGame
24 {
25 public:
26 BombsGame()
27 {
28 m_width = m_height = 0;
29 m_field = NULL;
30 };
31
32 ~BombsGame();
33
34 int GetWidth() const { return m_width; };
35 int GetHeight() const { return m_height; };
36
37 int Get(int x, int y) const
38 {
39 return m_field[x+y*m_width];
40 };
41
42 int IsFocussed(int x, int y) const
43 {
44 return (m_gridFocusX == x) && (m_gridFocusY == y);
45 }
46
47 int IsHidden(int x, int y) const
48 {
49 return Get(x,y) & BG_HIDDEN;
50 };
51
52 int IsMarked(int x, int y) const
53 {
54 return Get(x,y) & BG_MARKED;
55 };
56
57 int IsBomb(int x, int y) const
58 {
59 return Get(x,y) & BG_BOMB;
60 };
61
62 int IsExploded(int x, int y) const
63 {
64 return Get(x,y) & BG_EXPLODED;
65 };
66
67 int GetNumBombs() const
68 {
69 return m_numBombCells;
70 };
71
72 int GetNumRemainingCells() const
73 {
74 return m_numRemainingCells;
75 };
76
77
78
79 bool Init(int width, int height);
80
81
82 // Marks/unmarks a cell
83 void Mark(int x, int y);
84
85 // Unhides a cell
86 void Unhide(int x, int y);
87
88 // Makes a cell exploded
89 void Explode(int x, int y);
90
91 int m_gridFocusX;
92 int m_gridFocusY;
93
94 private:
95
96 // Current difficulty level (Determines grid size).
97 //int m_level;
98
99 int m_width, m_height;
100 short *m_field;
101 int m_numBombCells, m_numRemainingCells;
102
103 };
104
105 #endif // #ifndef _WX_DEMOS_BOMBS_GAME_H_