]> git.saurik.com Git - wxWidgets.git/blob - demos/bombs/game.h
Use wxFindWindowAtPoint() for hit testing in wxPopupTransientWindow.
[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) since 2003
6 // Created: 1996
7 // Copyright: (c) 1996 P. Foggia
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_DEMOS_BOMBS_GAME_H_
12 #define _WX_DEMOS_BOMBS_GAME_H_
13
14 #define BG_HIDDEN 0x100
15 #define BG_BOMB 0x200
16 #define BG_MARKED 0x400
17 #define BG_EXPLODED 0x800
18 #define BG_SELECTED 0x080
19 #define BG_MASK 0x03F
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 IsSelected(int x, int y) const
68 {
69 return Get(x,y) & BG_SELECTED;
70 };
71
72 int GetNumBombs() const
73 {
74 return m_numBombCells;
75 };
76
77 int GetNumRemainingCells() const
78 {
79 return m_numRemainingCells;
80 };
81
82 int GetNumMarkedCells() const
83 {
84 return m_numMarkedCells;
85 };
86
87
88 bool Init(int width, int height, bool easyCorner = false);
89
90
91 // Marks/unmarks a cell
92 void Mark(int x, int y);
93
94 // Unhides a cell
95 void Unhide(int x, int y, bool b_selected);
96
97 // Makes a cell exploded
98 void Explode(int x, int y);
99
100 int m_gridFocusX;
101 int m_gridFocusY;
102
103 private:
104
105 // Current difficulty level (Determines grid size).
106 //int m_level;
107
108 int m_width, m_height;
109 short *m_field;
110 int m_numBombCells, m_numRemainingCells, m_numMarkedCells;
111
112 };
113
114 #endif // #ifndef _WX_DEMOS_BOMBS_GAME_H_