-
Notifications
You must be signed in to change notification settings - Fork 0
/
LocalAreaTerrain.cpp
45 lines (41 loc) · 1.2 KB
/
LocalAreaTerrain.cpp
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
38
39
40
41
42
43
44
45
#include "LocalArea.h"
#include "Body.h"
/*
The magic number 1's are to account for width and height measuring the number of items,
while the coordinates have a zero and are thus offset by 1.
*/
const TerrainType* LocalArea::getTerrain(int x, int y)
{
if (outsideArea(x,y))
return NULL;
else
return (terrain[y][x]);
}
void LocalArea::fillTerrain(const TerrainType& type)
{
unsigned int i, j;
for (i = 0; i < terrain.size(); i++)
{
for (j = 0; j < terrain[i].size(); j++)
{
terrain[i][j] = &type;
}
}
}
CharRaster LocalArea::getCharMap()
{
CharRaster output = CharRaster(getWidth(), getHeight(), ' ', WHITEBLACK);
for (unsigned int i = 0; i < getHeight(); i++)
{
for (unsigned int j = 0; j < getWidth(); j++)
{
if (getTerrain(j, i) != NULL)
{
output.setCharAttr(j, i, getTerrain(j, i)->getCharAttr(), getTerrain(j, i)->getDisplayChar());
}
}
}
for (unsigned int i; i < occupants.size(); i++)
output.setCharAttr(occupants[i]->getLocation().getX(), occupants[i]->getLocation().getY(), occupants[i]->getCharAttr(), occupants[i]->getSymbol());
return output;
}