Код: Выделить всё
__ __ __ __ __
/ \__/ \__/ \__/~ \__/2 \
\__/ \__/ \__/ \__/2 \__/
/1 \__/~ \__/ \__/2 \__/2 \
\__/1 \__/ \__/ \__/2 \__/
/1 \__/# \__/~ \__/ \__/2 \
\__/1 \__/ \__/ \__/2 \__/
/1 \__/1 \__/~ \__/# \__/2 \
\__/1 \__/ \__/ \__/ \__/
/1 \__/ \__/ \__/ \__/ \
\__/ \__/ \__/ \__/ \__/
< /code>
У меня есть папка, состоящая 8 из них, поэтому функция случайным образом получает ее и использует ее в проекте.#include "mapreader.h"
#include
#include
#include
#include
MapReader::MapReader() : mapId(-1) {}
CellPosition::Type MapReader::charToCellType(QChar c) const
{
switch (c.unicode()) {
case '1': return CellPosition::Player1;
case '2': return CellPosition::Player2;
case '~': return CellPosition::Water;
case '#': return CellPosition::Stone;
default: return CellPosition::Empty;
}
}
bool MapReader::loadRandomMap(const QString& mapsFolder)
{
cellPositions.clear();
QDir directory(mapsFolder);
QStringList maps = directory.entryList(QStringList()
Подробнее здесь: [url]https://stackoverflow.com/questions/79606395/struggling-to-parse-a-txt-map-file-and-implement-that-in-qt-project[/url]