From a6f3b8c71513a1a7d416ec57627836ed4d9a7d94 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Wed, 25 Sep 2024 16:38:14 +0200 Subject: fully working map,textures and spritesheets togheter --- resource-manager/main.cpp | 7 +++++-- resource-manager/map_asset.cpp | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/resource-manager/main.cpp b/resource-manager/main.cpp index d0e8312..a301114 100644 --- a/resource-manager/main.cpp +++ b/resource-manager/main.cpp @@ -31,13 +31,11 @@ int main() { ResourceManager * rm = new ResourceManager(); - /* Texture* img = rm->Load("../img.png"); img->setTexture(*renderer); SpriteSheet* SS = rm->Load("../spritesheet_test.png"); SS->set_spritesheet_data(*renderer, 1, 4); - */ Map* map = rm->Load("../../asset/tiled/demo.tmx"); map->SetRenderer(*renderer); @@ -61,6 +59,11 @@ int main() { SDL_RenderClear(renderer); + SDL_RenderCopy(renderer, img->getTexture(), NULL, NULL); + SS->select_sprite(sprite, 0); + SDL_Rect pos = {10,10,32,64}; + SS->draw_selected_sprite(renderer, &pos); + map->draw(); SDL_RenderPresent(renderer); } delete rm; diff --git a/resource-manager/map_asset.cpp b/resource-manager/map_asset.cpp index ab19e59..342edc3 100644 --- a/resource-manager/map_asset.cpp +++ b/resource-manager/map_asset.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -49,6 +50,8 @@ void Map::SetMapTextures(){ const auto& tileSets = m_Map.getTilesets(); assert(~tileSets.empty()); + std::cout << "Processing SetMapTextures " << std::endl; + for (const auto& ts : tileSets ) { m_MapTextures.emplace_back(new TextureMap); if(!m_MapTextures.back()->loadFromFile(ts.getImagePath(), m_Renderer)){ @@ -60,6 +63,7 @@ void Map::SetMapTextures(){ void Map::SetMapLayers(){ const auto& mapLayers = m_Map.getLayers(); + std::cout << "Processing SetMapLayers " << std::endl; for(auto i = 0u; i < mapLayers.size(); ++i){ if (mapLayers[i]->getType() == tmx::Layer::Type::Tile) { m_RenderLayers.emplace_back(new MapLayer); -- cgit v1.2.3