diff --git a/mazzGame/CMakeLists.txt b/mazzGame/CMakeLists.txt index a00aa7d..a2b2c7e 100644 --- a/mazzGame/CMakeLists.txt +++ b/mazzGame/CMakeLists.txt @@ -14,7 +14,7 @@ project ("mazzGame") aux_source_directory(${PROJECT_SOURCE_DIR}/src sourceCodeList) # 将源代码添加到此项目的可执行文件。 -add_executable (mazzGame ${sourceCodeList} "src/Maze.cpp") +add_executable (mazzGame ${sourceCodeList}) if (CMAKE_VERSION VERSION_GREATER 3.12) set_property(TARGET mazzGame PROPERTY CXX_STANDARD 20) diff --git a/mazzGame/src/Config.cpp b/mazzGame/src/Config.cpp index a546e81..1c6cfdf 100644 --- a/mazzGame/src/Config.cpp +++ b/mazzGame/src/Config.cpp @@ -58,7 +58,7 @@ bool ConfigReader::load(std::string &path) if (section == "Symbols") { if (key == "Wall") - symbols.setWall(value[0]); + m_data.setWall(value[0]); else if (key == "Empty") symbols.setEmpty(value[0]); else if (key == "Player") @@ -73,14 +73,14 @@ bool ConfigReader::load(std::string &path) else if (section == "Difficulty") { if (key == "MonsterAI") - difficulty = std::stoi(value); + m_difficulty = std::stoi(value); } else if (section == "Maze") { if (key == "Width") - mazeWidth = std::stoi(value); + m_mazeWidth = std::stoi(value); else if (key == "Height") - mazeHeight = std::stoi(value); + m_mazeHeight = std::stoi(value); } } diff --git a/mazzGame/src/Config.h b/mazzGame/src/Config.h index 4669828..182c432 100644 --- a/mazzGame/src/Config.h +++ b/mazzGame/src/Config.h @@ -13,13 +13,11 @@ public: MazeData getSymbols() const; void setSymbols(MazeData &value); - + private: std::string trim(const std::string &s); private: - MazeData symbols; // 存放迷宫符号 - int difficulty = 0; // 怪物AI难度 - int mazeWidth = 21; - int mazeHeight = 21; + MazeData m_data; // 存放迷宫符号 + }; diff --git a/mazzGame/src/Game.cpp b/mazzGame/src/Game.cpp index 04e9599..5fc32c5 100644 --- a/mazzGame/src/Game.cpp +++ b/mazzGame/src/Game.cpp @@ -1,5 +1,7 @@ #include "Game.h" +#include + Game::Game() { } @@ -19,3 +21,8 @@ void Game::initMaze() void Game::run() { } + +void Game::printConfig() +{ + +} diff --git a/mazzGame/src/Game.h b/mazzGame/src/Game.h index efdc0f0..f76b788 100644 --- a/mazzGame/src/Game.h +++ b/mazzGame/src/Game.h @@ -18,6 +18,7 @@ public: ~Game(); void loadConfig(const std::string &filePath, MazeData &data); + void printConfig(MazeData &data); void initMaze(); void run(); };