diff --git a/SFMLEngine/makingAGameTick/app b/SFMLEngine/makingAGameTick/app index f17f686..db3781e 100755 Binary files a/SFMLEngine/makingAGameTick/app and b/SFMLEngine/makingAGameTick/app differ diff --git a/SFMLEngine/makingAGameTick/game.cpp b/SFMLEngine/makingAGameTick/game.cpp index 6b8ca6b..e25f397 100644 --- a/SFMLEngine/makingAGameTick/game.cpp +++ b/SFMLEngine/makingAGameTick/game.cpp @@ -4,7 +4,7 @@ #include #include #include "constants.hpp" -#include "resources.cpp" +#include "resources.hpp" #include "basic.cpp" diff --git a/SFMLEngine/makingAGameTick/game.o b/SFMLEngine/makingAGameTick/game.o index 624a22e..5fc86b3 100644 Binary files a/SFMLEngine/makingAGameTick/game.o and b/SFMLEngine/makingAGameTick/game.o differ diff --git a/SFMLEngine/makingAGameTick/resources.hpp b/SFMLEngine/makingAGameTick/resources.hpp new file mode 100644 index 0000000..bfbbf0e --- /dev/null +++ b/SFMLEngine/makingAGameTick/resources.hpp @@ -0,0 +1,27 @@ +#ifndef RESOURCES_HPP +#define RESOURCES_HPP + +#include +// Mostly Chapter 2 +// Handles resource management +namespace Textures // This gives us a scope for the enumerators which allows us to write Textures::Airplane instead of just Airplane to avoid name collisions in the global scope +{ + enum ID { Landscape, Airplane, Missile }; +} + +class TextureHolder +{ + public: + void load(Textures::ID id, const std::string& filename); + sf::Texture& get(Textures::ID id); + const sf::Texture& get(Textures::ID id) const; + private: + std::map< Textures::ID, std::unique_ptr > mTextureMap; + // unique_ptr are class templates that act like pointers, this allows us to work with heavyweight objects without copying them all the time, or we can store classes that are non-cpyable like sf::Shader +}; + + + +#include "resources.inl" + +#endif // RESOURCES_HPP diff --git a/SFMLEngine/makingAGameTick/resources.cpp b/SFMLEngine/makingAGameTick/resources.inl similarity index 66% rename from SFMLEngine/makingAGameTick/resources.cpp rename to SFMLEngine/makingAGameTick/resources.inl index 6ca9833..f773553 100644 --- a/SFMLEngine/makingAGameTick/resources.cpp +++ b/SFMLEngine/makingAGameTick/resources.inl @@ -1,24 +1,6 @@ -#ifndef RESOURCES_CPP -#define RESOURCES_CPP +#ifndef RESOURCES_INL +#define RESOURCES_INL -#include -// Mostly Chapter 2 -// Handles resource management -namespace Textures // This gives us a scope for the enumerators which allows us to write Textures::Airplane instead of just Airplane to avoid name collisions in the global scope -{ - enum ID { Landscape, Airplane, Missile }; -} - -class TextureHolder -{ - public: - void load(Textures::ID id, const std::string& filename); - sf::Texture& get(Textures::ID id); - const sf::Texture& get(Textures::ID id) const; - private: - std::map< Textures::ID, std::unique_ptr > mTextureMap; - // unique_ptr are class templates that act like pointers, this allows us to work with heavyweight objects without copying them all the time, or we can store classes that are non-cpyable like sf::Shader -}; void TextureHolder::load(Textures::ID id, const std::string& filename) // Function to load a resource, it takes one parameter for filename and one for identifier @@ -45,4 +27,4 @@ const sf::Texture& TextureHolder::get(Textures::ID id) const // we need to be ab return *found -> second; // We have to access the second member of the pointer, then we deference it and get a texture } -#endif //RESOUIRCES_CPP +#endif // RESOURCES_INL