Rename Level.width, Level.height to .cols, .rows
This commit is contained in:
parent
6eac3c84f6
commit
a2a1a67042
|
@ -141,11 +141,11 @@ void Game::renderMap()
|
|||
hero->position(hero_row, hero_col);
|
||||
|
||||
// Draw map from 2D array
|
||||
for (coordinate x = 0; x < level->width(); ++x)
|
||||
for (coordinate x = 0; x < level->cols(); ++x)
|
||||
{
|
||||
shift = static_cast<float>(level->width()) * cell_deviation;
|
||||
shift = static_cast<float>(level->cols()) * cell_deviation;
|
||||
|
||||
for (coordinate y = 0; y < level->height(); ++y)
|
||||
for (coordinate y = 0; y < level->rows(); ++y)
|
||||
{
|
||||
convex_brush.setPosition(shift + painter_x, painter_y);
|
||||
convex_brush.setFillColor(map[y][x]->color());
|
||||
|
|
|
@ -39,18 +39,18 @@ Level::Level(const std::string &map_file)
|
|||
while (getline(file, cur_line))
|
||||
{
|
||||
// need fix; see std::string.compare
|
||||
if (strstr(cur_line.data(), "size") != NULL)
|
||||
if (cur_line.compare(0, 4, "size") == 0)
|
||||
{
|
||||
file >> level_width >> level_height;
|
||||
map.resize(level_height);
|
||||
file >> level_rows >> level_cols;
|
||||
map.resize(level_rows);
|
||||
for (Row &row : map)
|
||||
row.resize(level_width);
|
||||
row.resize(level_cols);
|
||||
}
|
||||
else if (strstr(cur_line.data(), "map") != NULL)
|
||||
else if (cur_line.compare(0, 3, "map") == 0)
|
||||
{
|
||||
readMap(file);
|
||||
}
|
||||
else if (strstr(cur_line.data(), "teleport") != NULL)
|
||||
else if (cur_line.compare(0, 8, "teleport") == 0)
|
||||
{
|
||||
coordinate src_row, src_col;
|
||||
coordinate dest_row, dest_col;
|
||||
|
@ -71,14 +71,14 @@ Level::~Level()
|
|||
delete cell;
|
||||
}
|
||||
|
||||
size_t Level::width() const
|
||||
size_t Level::rows() const
|
||||
{
|
||||
return level_width;
|
||||
return level_rows;
|
||||
}
|
||||
|
||||
size_t Level::height() const
|
||||
size_t Level::cols() const
|
||||
{
|
||||
return level_height;
|
||||
return level_cols;
|
||||
}
|
||||
|
||||
void Level::placeBridge(coordinate row, coordinate col)
|
||||
|
|
|
@ -15,7 +15,7 @@ class Level
|
|||
private:
|
||||
Map map;
|
||||
sf::Color color_ground;
|
||||
size_t level_width, level_height;
|
||||
size_t level_rows, level_cols;
|
||||
std::array<Cell *, N_CELLS> default_cells;
|
||||
|
||||
void prepareCellInstances();
|
||||
|
@ -25,8 +25,8 @@ public:
|
|||
Level(const std::string &map_file = default_file_name);
|
||||
~Level();
|
||||
|
||||
size_t width() const;
|
||||
size_t height() const;
|
||||
size_t rows() const;
|
||||
size_t cols() const;
|
||||
|
||||
/// Place a bridge cell
|
||||
void placeBridge(coordinate x, coordinate y);
|
||||
|
|
Loading…
Reference in New Issue