Integrating JSON, testing with externally-defining tile data.

This commit is contained in:
2025-03-19 03:56:10 -04:00
parent 10e82cd4aa
commit ba39db02d3
6 changed files with 66 additions and 2 deletions

View File

@@ -0,0 +1,11 @@
[
{
},
{
},
{
}
]

View File

@@ -0,0 +1,23 @@
[
{
"mnemonic-id" : "stone",
"display-name" : "",
"solid": true,
"does-random-ticc": false,
"does-forced-ticc": false,
"color": "#FFFFFF",
"pallet": []
},
{
"mnemonic-id" : "stone",
"display-name" : "",
"solid": true,
"does-random-ticc": false,
"does-forced-ticc": false,
"color": "#FFFFFF",
"pallet": [],
"random-ticc-func": "zzyyzz",
"forced-ticc-func": "zzyyzz",
"drops" : null
}
]

View File

@@ -22,9 +22,33 @@
#include <Core/Tile.hpp>
#include <JGL/logger/logger.h>
std::string read_file(const std::string& file_path)
{
std::ifstream file(file_path, std::ios::binary);
if (!file)
throw std::runtime_error("We couldn't find the file: " + file_path);
std::streamsize file_size;
file.seekg(0, std::ios::end);
file_size = file.tellg();
file.seekg(0, std::ios::beg);
std::string file_content(file_size, '\0');
file.read(&file_content[0], file_size);
file.close();
return file_content;
}
int main(int argc, char** argv) {
std::string content = read_file("data/tiles/base_tiles.json");
auto [text, parse_error] = json::parse(content);
// Hide logs from engine components so we can focus on CaveGame.
JGL::Logger::Warning.EnableConsole(false);