Yurim64

Untitled

Jun 6th, 2021 (edited)
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #ifndef ResourceHandler_hpp
  2. #define ResourceHandler_hpp
  3.  
  4. #include <SFML\\Graphics.hpp>
  5. #include <iostream>
  6. #include <filesystem>
  7. #include <string>
  8.  
  9. class ResourceHandler
  10. {
  11. public:
  12.     static std::vector<sf::Texture> ENTITIES;
  13.  
  14.     static void loadResources()
  15.     {
  16.         std::cout << "Loading Resource...\n";
  17.         std::string path = "../resources/textures/entity";
  18.         for (const auto &entry : std::filesystem::directory_iterator(path))
  19.         {
  20.             sf::Texture texture = sf::Texture();
  21.             std::string filePath = entry.path().generic_string();
  22.             if (texture.loadFromFile(filePath))
  23.             {
  24.                 ENTITIES.push_back(texture);
  25.                 std::cout << "Loadedi: " << entry.path() << std::endl;
  26.             }
  27.         }
  28.         std::cout << "Resource Loaded\n================================\n";
  29.     }
  30. };
  31. #endif
Add Comment
Please, Sign In to add comment