Definition at line 12 of file Field.h.
Public Member Functions | |
Field (int w, int h) | |
Two dimensional array of Cube pointers. | |
~Field () | |
int | getW () const |
int | getH () const |
Cube * | getModel (const V2 &loc) |
Get model which occupied this location. | |
void | setModel (const V2 &loc, Cube *model) |
Mark this location as occupied by model. |
|
Two dimensional array of Cube pointers.
Definition at line 22 of file Field.cpp. 00023 { 00024 m_w = w; 00025 m_h = h; 00026 00027 m_border = ModelFactory::createBorder(); 00028 m_border->rules()->takeField(this); 00029 00030 //NOTE: [y][x] indexes 00031 m_marks = new Cube**[m_h]; 00032 for (int y = 0; y < m_h; ++y) { 00033 m_marks[y] = new Cube*[m_w]; 00034 memset(m_marks[y], 0, sizeof(Cube *) * m_w); 00035 } 00036 }
|
|
Definition at line 38 of file Field.cpp. 00039 { 00040 for (int y = 0; y < m_h; ++y) { 00041 delete [] m_marks[y]; 00042 } 00043 delete [] m_marks; 00044 delete m_border; 00045 }
|
|
Definition at line 23 of file Field.h. 00023 { return m_h; }
|
|
Get model which occupied this location. Empty locations are NULL filled. Locations out of field are filled with border object. Definition at line 53 of file Field.cpp. 00054 { 00055 int x = loc.getX(); 00056 int y = loc.getY(); 00057 00058 //NOTE: hack border everywhere in outher space 00059 Cube *result = m_border; 00060 if ((0 <= x && x < m_w) && (0 <= y && y < m_h)) { 00061 result = m_marks[y][x]; 00062 } 00063 return result; 00064 }
|
|
Definition at line 22 of file Field.h. 00022 { return m_w; }
|
|
Mark this location as occupied by model. Locations out of field will not be filled. Definition at line 71 of file Field.cpp. 00072 { 00073 int x = loc.getX(); 00074 int y = loc.getY(); 00075 00076 if ((0 <= x && x < m_w) && (0 <= y && y < m_h)) { 00077 m_marks[y][x] = model; 00078 } 00079 }
|