Game Engine 2D Platformer
ResourceManager.hpp
Go to the documentation of this file.
1 /*
2  * @file ResourceManager.hpp
3  * @brief ResourceManager class interface
4  * @date 2021-03-12
5  ***********************************************/
6 #ifndef ResourceManager_hpp
7 #define ResourceManager_hpp
8 #include <SDL2/SDL.h>
9 #include <SDL2_ttf/SDL_ttf.h>
10 // #include <SDL2/SDL_mixer.h>
11 #include <SDL2_mixer/SDL_mixer.h>
12 #include <SDL2_image/SDL_image.h>
13 #include <unordered_map>
14 #include <string>
15 #include <map>
16 #include <iostream>
17 #include <fstream>
18 #include <string>
23 {
24 private:
28  std::map<std::string, SDL_Texture *> textureMap;
29 
33  std::map<std::string, SDL_Surface *> surfaceMap;
34 
38  std::map<std::string, TTF_Font *> fontMap;
39 
43  std::map<std::string, Mix_Music *> soundMap;
44 
48  std::map<std::string, Mix_Chunk *> soundEffectMap;
49 
53  std::map<std::string, std::string> languageMap;
54 
58  int language;
59 
63  ResourceManager() {}
64 
65 public:
70  static ResourceManager &getInstance();
71 
77  SDL_Texture *loadTexture(std::string filePath, SDL_Renderer *renderer);
78 
84  SDL_Surface *loadSurface(std::string filePath, SDL_Renderer *renderer);
85 
91  TTF_Font *loadFont(std::string filePath, int fontSize);
92 
98  Mix_Music *loadMusic(std::string filePath);
104  Mix_Chunk *loadWAV(std::string filePath);
105 
111  void setWords(std::string english, std::string french);
112 
118  std::string getWords(std::string phrase);
119 
124  void setLanguage(int languageCode);
128  void loadWords();
129 };
130 #endif
The resource manager is responsible for handling and managing resources regarding the game.
Definition: ResourceManager.hpp:23
static ResourceManager & getInstance()
Method used to get instance of ResourceManager class.
Definition: ResourceManager.cpp:8
void loadWords()
Method to load the words from multiple scripts in the script folder.
Definition: ResourceManager.cpp:130
Mix_Music * loadMusic(std::string filePath)
Method used to load Mix_Music object of respective music from its path.
Definition: ResourceManager.cpp:70
std::string getWords(std::string phrase)
Method used to get words based on the language, i.e English or French.
Definition: ResourceManager.cpp:108
TTF_Font * loadFont(std::string filePath, int fontSize)
Method used to load TTF_Font object of respective font from its path.
Definition: ResourceManager.cpp:47
void setWords(std::string english, std::string french)
Metohd used to set translation words in LanguageMap.
Definition: ResourceManager.cpp:102
SDL_Texture * loadTexture(std::string filePath, SDL_Renderer *renderer)
Method used to load Spritesheet of Images from their path.
Definition: ResourceManager.cpp:14
SDL_Surface * loadSurface(std::string filePath, SDL_Renderer *renderer)
Method used to load Spritesheet of Images from their path.
Definition: ResourceManager.cpp:31
Mix_Chunk * loadWAV(std::string filePath)
Method used to load Mix_Chunk object of respective music from its path.
Definition: ResourceManager.cpp:86
void setLanguage(int languageCode)
Method to set language so other methods can know which language phrase to return.
Definition: ResourceManager.cpp:125