#ifndef ASSETS_HPP #define ASSETS_HPP #include #include #include #include // Structs struct Rect { int x; int y; int width; int height; Rect(int x = 0, int y = 0, int width = 0, int height = 0) : x(x), y(y), width(width), height(height) {} Rect(const SDL_Rect& rect) : x(rect.x), y(rect.y), width(rect.w), height(rect.h) {} }; struct Tile { Rect srcRect; std::string assetName; }; // Classes class AssetManager { public: AssetManager(); ~AssetManager(); void load(const std::string& name, const std::string& filePath); SDL_Surface* getAsset(const std::string& name) const; void unloadAsset(const std::string& name); void clearAssets(); private: std::unordered_map assets; }; struct TileMap { public: TileMap(AssetManager& assetManager); ~TileMap(); void addTile(const std::string& name, const Tile& tile); Tile getTile(const std::string& name) const; SDL_Surface* getTileAsset(const std::string& name) const; Rect getTileRect(const std::string& name) const; void removeTile(const std::string& name); void clear(); private: std::unordered_map tiles; AssetManager& assetManager; }; #endif