From 85d9552871b1bbf2df86f9f20d93d5bac575dd12 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 6 Oct 2022 23:37:35 +0200 Subject: a --- test/json.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test') diff --git a/test/json.cpp b/test/json.cpp index 5e60b7ee..b98c9ae2 100644 --- a/test/json.cpp +++ b/test/json.cpp @@ -5,9 +5,31 @@ #include "serialize/json-helper.hpp" #include "compat/assert.hpp" #include "tile-atlas.hpp" +#include "tile.hpp" +#include "chunk.hpp" #include "loader.hpp" namespace Magnum::Examples { + +static chunk make_test_chunk() +{ + auto metal1 = loader.tile_atlas("share/game/images/metal1.tga", {2, 2}), + metal2 = loader.tile_atlas("share/game/images/metal2.tga", {2, 2}), + metal3 = loader.tile_atlas("share/game/images/metal3.tga", {2, 2}); + constexpr auto N = TILE_MAX_DIM; + chunk c; + c.foreach_tile([&](tile& x, std::size_t k, local_coords pt) { + const auto& atlas = pt.x > N/2 && pt.y >= N/2 ? metal1 : metal2; + x.ground_image = { atlas, (std::uint8_t)(k % atlas->num_tiles().product()) }; + }); + constexpr auto K = N/2; + c[{K, K }].wall_north = { metal3, 0 }; + c[{K, K }].wall_west = { metal3, 0 }; + c[{K, K+1}].wall_north = { metal3, 0 }; + c[{K+1, K }].wall_west = { metal3, 0 }; + return c; +} + bool app::test_json() // NOLINT(readability-convert-member-functions-to-static) { bool ret = true; @@ -22,6 +44,14 @@ bool app::test_json() // NOLINT(readability-convert-member-functions-to-static) ret &= json_helper::to_json(v2i_1, output_dir/"vec2i_1.json"); ret &= json_helper::to_json(v2i_2, output_dir/"vec2i_2.json"); } + { + Magnum::Math::Vector3 vec{0.f/0, -1.f/0, 123.f}; + ret &= json_helper::to_json(vec, output_dir/"vec3_inf.json"); + } + { + const auto chunk = make_test_chunk(); + ret &= json_helper::to_json(chunk, output_dir/"chunk-1.json"); + } return ret; } -- cgit v1.2.3