添加基础文件
parent
be44a69100
commit
71d17de0e7
|
|
@ -14,7 +14,7 @@ project ("mazzGame")
|
|||
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)
|
||||
set_property(TARGET mazzGame PROPERTY CXX_STANDARD 20)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#include "Game.h"
|
||||
|
||||
Game::Game()
|
||||
{
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
}
|
||||
|
||||
void Game::loadConfig(const std::string& filePath)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -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();
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
};
|
||||
|
|
@ -0,0 +1 @@
|
|||
#pragma once
|
||||
|
|
@ -0,0 +1 @@
|
|||
#pragma once
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
[Symbols]
|
||||
Wall = #
|
||||
Player = @
|
||||
Monster = M
|
||||
Trap = X
|
||||
Exit = E
|
||||
Empty = .
|
||||
|
||||
[Difficulty]
|
||||
# 0: 随机移动,1: BFS偏向,2: A*精确追踪
|
||||
MonsterAI = 1
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Game.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// TODO: 在此处引用程序需要的其他标头。
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
// mazzGame.cpp: 定义应用程序的入口点。
|
||||
//
|
||||
|
||||
#include "mazzGame.h"
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello CMake." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue