]> git.saurik.com Git - wxWidgets.git/blame - demos/bombs/game.h
Don't rely on __GXX_RTTI being defined with g++ < 4.3.
[wxWidgets.git] / demos / bombs / game.h
CommitLineData
0c65afdb
DS
1///////////////////////////////////////////////////////////////////////////////
2// Name: game.h
3// Purpose: Bombs game
4// Author: P. Foggia 1996
c8059953 5// Modified by: Wlodzimierz Skiba (ABX) since 2003
0c65afdb
DS
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_
025e88c5
JS
14
15#define BG_HIDDEN 0x100
16#define BG_BOMB 0x200
17#define BG_MARKED 0x400
18#define BG_EXPLODED 0x800
709d0081
WS
19#define BG_SELECTED 0x080
20#define BG_MASK 0x03F
025e88c5 21
025e88c5
JS
22#include <stddef.h>
23
24class BombsGame
0c65afdb
DS
25{
26public:
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
709d0081
WS
68 int IsSelected(int x, int y) const
69 {
70 return Get(x,y) & BG_SELECTED;
71 };
72
0c65afdb
DS
73 int GetNumBombs() const
74 {
75 return m_numBombCells;
76 };
77
78 int GetNumRemainingCells() const
79 {
80 return m_numRemainingCells;
81 };
82
709d0081
WS
83 int GetNumMarkedCells() const
84 {
85 return m_numMarkedCells;
86 };
0c65afdb
DS
87
88
43c3922b 89 bool Init(int width, int height, bool easyCorner = false);
0c65afdb
DS
90
91
92 // Marks/unmarks a cell
93 void Mark(int x, int y);
94
95 // Unhides a cell
709d0081 96 void Unhide(int x, int y, bool b_selected);
0c65afdb
DS
97
98 // Makes a cell exploded
99 void Explode(int x, int y);
100
101 int m_gridFocusX;
102 int m_gridFocusY;
103
104private:
105
106 // Current difficulty level (Determines grid size).
107 //int m_level;
108
109 int m_width, m_height;
110 short *m_field;
709d0081 111 int m_numBombCells, m_numRemainingCells, m_numMarkedCells;
0c65afdb
DS
112
113};
025e88c5 114
0c65afdb 115#endif // #ifndef _WX_DEMOS_BOMBS_GAME_H_