blob: d74f58785e6a0f406a9b59f5e45af0a99e943a8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "Field.h"
Field::Field(uint width, uint height): m_width(width), m_height(height)
{
m_fieldCells.resize(width*height);
}
Coordinates Field::getMaxCoordinates()
{
return Coordinates(m_width, m_height);
}
Field::~Field(void)
{
}
bool Field::drawAllPlayers(uint numCycles) {
return(true);
}
Cell& Field::getCell(Coordinates c) {
if (c.x<0 || c.x >= m_width || c.y <0 || c.y >= m_height)
throw std::out_of_range ("getCell");
return(m_fieldCells[c.x+m_width*c.y]);
}
void Field::init(uint width, uint height) {
// m_fieldCells.assign(width*height, EMPTY_CELL);
m_width = width;
m_height = height;
m_fieldCells.clear();
m_fieldCells.resize(width*height);
}
void Field::setCell(Coordinates coord, Cell cell) {
m_fieldCells[coord.x+m_width*coord.y] = cell;
}
|