]>
git.saurik.com Git - wxWidgets.git/blob - demos/life/game.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Life! game logic
4 // Author: Guillermo Rodriguez Garcia, <guille@iies.es>
8 // Copyright: (c) 2000, Guillermo Rodriguez Garcia
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "game.h"
19 // for compilers that support precompilation, includes "wx/wx.h"
20 #include "wx/wxprec.h"
26 // for all others, include the necessary headers
31 // --------------------------------------------------------------------------
33 // --------------------------------------------------------------------------
35 // minimum and maximum table size, in each dimension
39 // --------------------------------------------------------------------------
40 // Cell and CellArray;
41 // --------------------------------------------------------------------------
44 typedef wxArrayLong CellArray
;
46 // --------------------------------------------------------------------------
48 // --------------------------------------------------------------------------
53 LifeShape::LifeShape(wxString name
,
55 int width
, int height
, char *data
,
56 int fieldWidth
= 20, int fieldHeight
= 20,
64 m_fieldWidth
= fieldWidth
;
65 m_fieldHeight
= fieldHeight
;
79 // --------------------------------------------------------------------------
81 // --------------------------------------------------------------------------
87 Life(int width
, int height
);
89 void Create(int width
, int height
);
93 inline int GetWidth() const { return m_width
; };
94 inline int GetHeight() const { return m_height
; };
95 inline void SetBorderWrap(bool on
) { m_wrap
= on
; };
98 bool IsAlive(int i
, int j
) const;
99 bool IsAlive(Cell c
) const;
100 int GetX(Cell c
) const;
101 int GetY(Cell c
) const;
102 const CellArray
* GetCells() const { return &m_cells
; };
103 const CellArray
* GetChangedCells() const { return &m_changed
; };
107 Cell
SetCell(int i
, int j
, bool alive
= TRUE
);
108 void SetShape(LifeShape
&shape
);
112 int GetNeighbors(int i
, int j
) const;
113 inline Cell
MakeCell(int i
, int j
, bool alive
) const;
117 CELL_DEAD
= 0x0000, // is dead
118 CELL_ALIVE
= 0x0001, // is alive
119 CELL_MARK
= 0x0002, // will change / has changed
129 #endif // _LIFE_GAME_H_