integrating tileson with the project for tmx parsing

This commit is contained in:
Alan Youngblood
2023-07-19 17:10:10 -04:00
parent 8aa79741e4
commit 352034790c
19 changed files with 4944 additions and 154 deletions

View File

@ -15,6 +15,7 @@
#include <iostream>
#include <string>
#include <tuple>
#include "../tileson/tileson.hpp"
//#include "../../libtmx-parser/src/tmxparser.h"
class TileMapComponent : public Component
@ -23,6 +24,7 @@ public:
SDL_Texture* texture;
SDL_Rect srcRect, destRect;
//tmxparser::TmxMap map;
//tileson::Tileson map;
int globalScale;
std::vector<SDL_Rect> tileSet;
std::vector<SDL_Rect> destRects;
@ -40,8 +42,23 @@ public:
SDL_DestroyTexture(texture);
}
TileMapComponent(/*tmxparser::TmxMap loadedMap,*/ int gScale, int offsetX, int offsetY)
TileMapComponent(/*tileson::Tileson loadedMap,*/ int gScale, int offsetX, int offsetY)
{
// ***********************************************************************************
// TILESON ~~~~~~~~~~~
tson::Tileson t;
std::unique_ptr<tson::Map> map = t.parse(fs::path("../../assets/maps/testmap.json"));
if(map->getStatus() == tson::ParseStatus::OK)
{
printf("Parsed the map file okay.");
//Gets the layer called "Object Layer" from the "ultimate_demo.json map
tson::Layer *objectLayer = map->getLayer("Object Layer"); //This is an Object Layer
}
// *******************************************************************************************
/*map = loadedMap;
std::string texturePath = "assets/textures/tiles/" + loadedMap.tilesetCollection[0].name + ".png";
Game::assets->AddTexture(map.tilesetCollection[0].name, texturePath.c_str());