From a2a1a670424eb326f6a36e23e3aa986fc5387379 Mon Sep 17 00:00:00 2001 From: oss Date: Tue, 17 Mar 2020 07:27:30 +0300 Subject: [PATCH] Rename Level.width, Level.height to .cols, .rows --- src/game.cpp | 6 +++--- src/level.cpp | 20 ++++++++++---------- src/level.h | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index cba684a..4915b98 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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(level->width()) * cell_deviation; + shift = static_cast(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()); diff --git a/src/level.cpp b/src/level.cpp index 70045e3..84fbc2d 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -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) diff --git a/src/level.h b/src/level.h index 4683bab..600a9bb 100644 --- a/src/level.h +++ b/src/level.h @@ -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 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);