]> git.saurik.com Git - wxWidgets.git/blob - demos/bombs/game.h
also fix handling of wxSP_ARROW_KEYS|wxSP_WRAP (see #10565)
[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 // 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_SELECTED 0x080
20 #define BG_MASK 0x03F
21
22 #include <stddef.h>
23
24 class BombsGame
25 {
26 public:
27 BombsGame()
28 {
29 m_width = m_height = 0;
30 m_field = NULL;
31 };
32
33 ~BombsGame();
34
35 int GetWidth() const { return m_width; };
36 int GetHeight() const { return m_height; };
37
38 int Get(int x, int y) const
39 {
40 return m_field[x+y*m_width];
41 };
42
43 int IsFocussed(int x, int y) const
44 {
45 return (m_gridFocusX == x) && (m_gridFocusY == y);
46 }
47
48 int IsHidden(int x, int y) const
49 {
50 return Get(x,y) & BG_HIDDEN;
51 };
52
53 int IsMarked(int x, int y) const
54 {
55 return Get(x,y) & BG_MARKED;
56 };
57
58 int IsBomb(int x, int y) const
59 {
60 return Get(x,y) & BG_BOMB;
61 };
62
63 int IsExploded(int x, int y) const
64 {
65 return Get(x,y) & BG_EXPLODED;
66 };
67
68 int IsSelected(int x, int y) const
69 {
70 return Get(x,y) & BG_SELECTED;
71 };
72
73 int GetNumBombs() const
74 {
75 return m_numBombCells;
76 };
77
78 int GetNumRemainingCells() const
79 {
80 return m_numRemainingCells;
81 };
82
83 int GetNumMarkedCells() const
84 {
85 return m_numMarkedCells;
86 };
87
88
89 bool Init(int width, int height, bool easyCorner = false);
90
91
92 // Marks/unmarks a cell
93 void Mark(int x, int y);
94
95 // Unhides a cell
96 void Unhide(int x, int y, bool b_selected);
97
98 // Makes a cell exploded
99 void Explode(int x, int y);
100
101 int m_gridFocusX;
102 int m_gridFocusY;
103
104 private:
105
106 // Current difficulty level (Determines grid size).
107 //int m_level;
108
109 int m_width, m_height;
110 short *m_field;
111 int m_numBombCells, m_numRemainingCells, m_numMarkedCells;
112
113 };
114
115 #endif // #ifndef _WX_DEMOS_BOMBS_GAME_H_