1
General / Help with SFML Book
« on: August 21, 2017, 10:27:57 pm »
Hi all,
I am following the SFML Game Development book, however, my C++ knowledge is still average, therefore, I am finding it difficult understanding the ResourceManager part of the section, i was wondering, is it possible to build games without a resource manager and what is the best way to just add sprites and textures. Below is the resourceManager thing im talking about, i just want to try continue with the book by avoiding this but im not sure if thats possible
I am following the SFML Game Development book, however, my C++ knowledge is still average, therefore, I am finding it difficult understanding the ResourceManager part of the section, i was wondering, is it possible to build games without a resource manager and what is the best way to just add sprites and textures. Below is the resourceManager thing im talking about, i just want to try continue with the book by avoiding this but im not sure if thats possible
template <typename Resource, typename Identifier>
class ResourceHolder
{
public:
void load(Identifier id, const std::string& filename);
template <typename Parameter>
void load(Identifier id, const std::string& filename, const Parameter& secondParam);
Resource& get(Identifier id);
const Resource& get(Identifier id) const;
private:
void insertResource(Identifier id, std::unique_ptr<Resource> resource);
private:
std::map<Identifier, std::unique_ptr<Resource>> mResourceMap;
};
class ResourceHolder
{
public:
void load(Identifier id, const std::string& filename);
template <typename Parameter>
void load(Identifier id, const std::string& filename, const Parameter& secondParam);
Resource& get(Identifier id);
const Resource& get(Identifier id) const;
private:
void insertResource(Identifier id, std::unique_ptr<Resource> resource);
private:
std::map<Identifier, std::unique_ptr<Resource>> mResourceMap;
};