添加基础文件

remote
InkSoul 2025-10-25 23:07:44 +08:00
parent be44a69100
commit 71d17de0e7
15 changed files with 183 additions and 13 deletions

View File

@ -14,7 +14,7 @@ project ("mazzGame")
aux_source_directory(${PROJECT_SOURCE_DIR}/src sourceCodeList) aux_source_directory(${PROJECT_SOURCE_DIR}/src sourceCodeList)
# #
add_executable (mazzGame ${sourceCodeList}) add_executable (mazzGame ${sourceCodeList} "src/Maze.cpp")
if (CMAKE_VERSION VERSION_GREATER 3.12) if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET mazzGame PROPERTY CXX_STANDARD 20) set_property(TARGET mazzGame PROPERTY CXX_STANDARD 20)

View File

@ -0,0 +1,25 @@
#include "Config.h"
ConfigReader::ConfigReader()
{
}
ConfigReader::~ConfigReader()
{
}
void ConfigReader::load(std::string& path)
{
}
ConfigData::ConfigData()
{
}
ConfigData::~ConfigData()
{
}
void ConfigData::setSymbol(char wall, char empty, char player, char monster, char trap, char exit)
{
}

View File

@ -0,0 +1,37 @@
#pragma once
#include<string>
class ConfigReader
{
public:
ConfigReader();
~ConfigReader();
void load(std::string& path);
private:
};
class ConfigData
{
public:
ConfigData();
~ConfigData();
void setSymbol(char wall, char empty, char player, char monster,char trap, char exit);
void getSymbol(char& wall, char& empty, char& player, char& monster, char& trap, char& exit);
void setDiffculty(int level);
int getDiffculty();
private:
char m_wall, m_empty, m_player, m_monster, m_trap, m_exit;
int m_monsterAILevel;
};

View File

@ -0,0 +1,14 @@
#include "Game.h"
Game::Game()
{
}
Game::~Game()
{
}
void Game::loadConfig(const std::string& filePath)
{
}

View File

@ -0,0 +1,27 @@
#pragma once
#include "Config.h"
#include <string>
class Game
{
private:
ConfigReader m_config;
ConfigData m_configData;
bool m_isRunning = true;
public:
Game();
~Game();
void loadConfig(const std::string& filePath,ConfigData& data);
void initMaze(ConfigData data);
void run();
};

View File

@ -0,0 +1,16 @@
#include "Maze.h"
Maze::Maze()
:width(0),height(0)
{
}
Maze::~Maze()
{
}
void Maze::setMazeSymbols(char wall, char empty, char player, char monster, char trap, char exit)
{
}

View File

@ -0,0 +1,36 @@
#pragma once
#include <vector>
#include<string>
struct Position {
int x, y;
bool operator==(const Position& other) const {
return x == other.x && y == other.y;
}
};
// 用于存储字符符号
struct MazeSymbols {
char wall, empty, player, monster, trap, exit;
};
class Maze
{
public:
Maze();
~Maze();
void setMazeSymbols(char wall, char empty, char player, char monster, char trap, char exit);
void generate(int w, int h, const MazeSymbols& sym);
void draw(const Position& playerPos, const std::vector<Position>& monsterPos) const;
bool isWalkable(const Position& p) const;
bool isExit(const Position& p) const;
bool checkTrap(const Position& p) const;
private:
int m_width, m_height;
std::vector<std::string> m_grid;
};

View File

View File

@ -0,0 +1 @@
#pragma once

View File

View File

@ -0,0 +1 @@
#pragma once

View File

@ -0,0 +1,11 @@
[Symbols]
Wall = #
Player = @
Monster = M
Trap = X
Exit = E
Empty = .
[Difficulty]
# 0: 随机移动1: BFS偏向2: A*精确追踪
MonsterAI = 1

View File

@ -0,0 +1,12 @@
#include "main.h"
int main()
{
std::cout << "Hello CMake." << std::endl;
Game game;
game.loadConfig("config.txt");
game.initMaze();
game.run();
return 0;
}

View File

@ -3,6 +3,8 @@
#pragma once #pragma once
#include "Game.h"
#include <iostream> #include <iostream>
// TODO: 在此处引用程序需要的其他标头。 // TODO: 在此处引用程序需要的其他标头。

View File

@ -1,12 +0,0 @@
// mazzGame.cpp: 定义应用程序的入口点。
//
#include "mazzGame.h"
int main()
{
std::cout << "Hello CMake." << std::endl;
return 0;
}