Breakout
ResourceManager.h
Go to the documentation of this file.
1 #ifndef ResourceManager_h
2 #define ResourceManager_h
3 #include <SDL2/SDL.h>
4 #include <unordered_map>
5 #include <string>
6 #include <SDL2_ttf/SDL_ttf.h>
7 #include <SDL2/SDL_mixer.h>
8 #include <map>
13 private:
17  std::map<const char*, SDL_Surface*> map;
18 
22  std::map<const char*, TTF_Font*> fontMap;
23 
27  std::map<const char*, Mix_Music*> soundMap;
28 
32  std::map<const char*, Mix_Chunk*> soundEffectMap;
33 
37  std::map<std::string, std::string> languageMap;
38 
39  int language;
40 
41 
45  ResourceManager() {}
46 
47 public:
52  static ResourceManager& getInstance();
53 
59  SDL_Surface* loadTexture(const char* filePath);
60 
66  TTF_Font* loadFont(const char* filePath);
67 
73  Mix_Music* loadMusic(const char* filePath);
79  Mix_Chunk* loadWAV(const char* filePath);
80 
86  void setWords(std::string english, std::string french);
87 
93  const char* getWords(const char* phrase);
94 
99  void setLanguage(int languageCode);
103  void loadWords();
104 
105 
106 
107 };
108 #endif
The resource manager is responsible for handling and managing resources regarding the game.
Definition: ResourceManager.h:12
Mix_Music * loadMusic(const char *filePath)
Method used to load Mix_Music object of respective music from its path.
Definition: ResourceManager.cpp:52
static ResourceManager & getInstance()
Method used to get instance of ResourceManager class.
Definition: ResourceManager.cpp:10
void loadWords()
Method to load the words from multiple scripts in the script folder.
Definition: ResourceManager.cpp:101
void setWords(std::string english, std::string french)
Metohd used to set translation words in LanguageMap.
Definition: ResourceManager.cpp:78
TTF_Font * loadFont(const char *filePath)
Method used to load TTF_Font object of respective font from its path.
Definition: ResourceManager.cpp:31
const char * getWords(const char *phrase)
Method used to get words based on the language, i.e English or French.
Definition: ResourceManager.cpp:84
Mix_Chunk * loadWAV(const char *filePath)
Method used to load Mix_Chunk object of respective music from its path.
Definition: ResourceManager.cpp:65
SDL_Surface * loadTexture(const char *filePath)
Method used to load Spritesheet of Images from their path.
Definition: ResourceManager.cpp:15
void setLanguage(int languageCode)
Method to set language so other methods can know which language phrase to return.
Definition: ResourceManager.cpp:97
GLsizei const GLchar *const * string
Definition: glad.h:2926