aboutsummaryrefslogtreecommitdiff
path: root/resource-manager/map_asset.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-09-30 10:56:13 +0200
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-09-30 10:56:13 +0200
commita08f5acf483d5371ccab70ba75c39ac6a5f96ce7 (patch)
tree433be57896814c82625066ff901b1c7bc951c951 /resource-manager/map_asset.cpp
parenta6f3b8c71513a1a7d416ec57627836ed4d9a7d94 (diff)
changed resource manager based on feedback
Diffstat (limited to 'resource-manager/map_asset.cpp')
-rw-r--r--resource-manager/map_asset.cpp65
1 files changed, 2 insertions, 63 deletions
diff --git a/resource-manager/map_asset.cpp b/resource-manager/map_asset.cpp
index 342edc3..bbabe2b 100644
--- a/resource-manager/map_asset.cpp
+++ b/resource-manager/map_asset.cpp
@@ -3,71 +3,10 @@
#include "map_asset.h"
-#include "TextureMap.h"
-#include "map_layer.h"
-#include <SDL_render.h>
-#include <cassert>
-#include <iostream>
-#include <iterator>
-#include <ostream>
-#include <string>
-#include <tmxlite/Layer.hpp>
-#include <tmxlite/Map.hpp>
-
-Map::Map(const std::string& path){
- if(m_Map.load(path)){
- std::cout << "Map loaded correctly " << std::endl;
- }
+Map::Map(const std::string& content){
+ this->m_content = content;
}
Map::~Map(){
- for(const auto& r : m_MapTextures){
- delete r;
- }
- m_MapTextures.clear();
-
- for(const auto& m : m_RenderLayers){
- delete m;
- }
- m_RenderLayers.clear();
-}
-
-
-void Map::SetRenderer(SDL_Renderer& renderer){
- this->m_Renderer = &renderer;
- this->SetMapTextures();
- this->SetMapLayers();
-}
-
-void Map::draw() const{
- for(const auto& l : m_RenderLayers){
- l->draw(m_Renderer);
- }
-}
-
-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)){
- std::cerr << "Failed opening " << ts.getImagePath() << "\n";
- }
- }
-}
-
-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);
- m_RenderLayers.back()->create(this->m_Map, i, this->m_MapTextures);
- }
- }
}