@@ -53,16 +53,16 @@ namespace
5353 constexpr std::array<float , 10 > MAX_WALL_HEIGHTS = {4 , 3 , 2 , 1 , 2 , 3 , 4 , 4 , 4 , 3 };
5454 constexpr std::array<float , 10 > PLATFORM_HEIGHTS = {0 , 1 , 2 , 3 };
5555 constexpr std::array<glm::vec2, 4 > TRI_WALL_OFFSETS = {
56- glm::vec2{0 , -4 },
57- {0 , 4 },
58- {-4 , 0 },
59- {4 , 0 },
56+ glm::vec2{0 , -4 * TILE_SIZE_F },
57+ {0 , 4 * TILE_SIZE_F },
58+ {-4 * TILE_SIZE_F , 0 },
59+ {4 * TILE_SIZE_F , 0 },
6060 };
6161 constexpr std::array<glm::vec2, 4 > TRIWALL_START_OFFSETS = {
62- glm::vec2{0 , 4 },
63- {0 , -4 },
64- {4 , 0 },
65- {-4 , 0 },
62+ glm::vec2{0 , 4 * TILE_SIZE_F },
63+ {0 , -4 * TILE_SIZE_F },
64+ {4 * TILE_SIZE_F , 0 },
65+ {-4 * TILE_SIZE_F , 0 },
6666 };
6767
6868 std::pair<float , float > extract_wall_base_and_height (const nlohmann::json& height)
@@ -138,7 +138,7 @@ namespace
138138 auto extract_vec2 (float x, float y)
139139 {
140140 // The legacy format has each square as 5 units wide, so the values must be divided by this
141- return glm::vec2{x, y} / 5 .0f ;
141+ return glm::vec2{x, y} / 5 .0f * TILE_SIZE_F ;
142142 }
143143
144144} // namespace
@@ -229,7 +229,7 @@ void from_json(const nlohmann::json& json, LegacyTriWall& wall)
229229
230230 // TODO: Directions 5,6,7,8 are diagonal and need handling
231231 int direction = json[1 ][2 ];
232- auto offset = direction <= 4 ? TRI_WALL_OFFSETS[direction - 1 ] : glm::vec2{0 , -2 };
232+ auto offset = direction <= 4 ? TRI_WALL_OFFSETS[direction - 1 ] : glm::vec2{0 , -2 * TILE_SIZE_F };
233233 start += direction <= 4 ? TRIWALL_START_OFFSETS[direction - 1 ] : glm::vec2{0 , 0 };
234234
235235 wall_params.line .start = start;
@@ -272,7 +272,7 @@ void from_json(const nlohmann::json& json, LegacyPlatform& platform)
272272 platform_props.depth = static_cast <float >(props[0 ]) * 2 ;
273273
274274 platform_params.position = extract_vec2 (position[0 ], position[1 ]) -
275- glm::vec2{platform_props.width / 2 .0f };
275+ glm::vec2{( platform_props.width * TILE_SIZE_F) / 2 .0f };
276276
277277 if (props.size () > 1 )
278278 {
@@ -365,27 +365,27 @@ void from_json(const nlohmann::json& json, LegacyRamp& ramp)
365365 ramp_props.depth = 4 ;
366366 ramp_props.width = 2 ;
367367 ramp_props.direction = Direction::Forward; // confirmed
368- ramp_params.position .x -= 1 ;
368+ ramp_params.position .x -= TILE_SIZE_F ;
369369 break ;
370370 case 2 :
371371 ramp_props.depth = 4 ;
372372 ramp_props.width = 2 ;
373373 ramp_props.direction = Direction::Back;
374- ramp_params.position .y -= 4 ;
375- ramp_params.position .x -= 1 ;
374+ ramp_params.position .y -= 4 * TILE_SIZE_F ;
375+ ramp_params.position .x -= TILE_SIZE_F ;
376376 break ;
377377 case 3 :
378378 ramp_props.depth = 2 ;
379379 ramp_props.width = 4 ;
380- ramp_params.position .y -= 1 ;
380+ ramp_params.position .y -= TILE_SIZE_F ;
381381 ramp_props.direction = Direction::Left; // confirmed
382382 break ;
383383 case 4 :
384384 ramp_props.depth = 2 ;
385385 ramp_props.width = 4 ;
386386 ramp_props.direction = Direction::Right;
387- ramp_params.position .x -= 4 ;
388- ramp_params.position .y -= 1 ;
387+ ramp_params.position .x -= 4 * TILE_SIZE_F ;
388+ ramp_params.position .y -= TILE_SIZE_F ;
389389
390390 break ;
391391
@@ -451,7 +451,7 @@ void convert_legacy_level(const std::filesystem::path& path)
451451 std::println (" Converting to JSON took {}s ({}ms)" , time, time * 1000 .0f );
452452
453453 // Uncomment to inspect the converted JSON
454- std::ofstream out_file_og ((path.parent_path () / path.stem ()).string () + " .json" );
454+ // std::ofstream out_file_og((path.parent_path() / path.stem()).string() + ".json");
455455 // out_file_og << legacy_json;
456456 clock.restart ();
457457
0 commit comments