mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 22:23:43 +00:00
Compare commits
2 Commits
9bb9d0fbcc
...
e215fbd5b6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e215fbd5b6 | ||
|
|
007538f760 |
@ -23,8 +23,13 @@ class SoundManager
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
SoundManager() {
|
SoundManager() {
|
||||||
|
if (this_instance == nullptr) {
|
||||||
this_instance = this;
|
this_instance = this;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
throw std::runtime_error("SoundManager instance already exists!");
|
||||||
|
}
|
||||||
|
}
|
||||||
~SoundManager() {
|
~SoundManager() {
|
||||||
for (auto& it : this->sound_cache) {
|
for (auto& it : this->sound_cache) {
|
||||||
Mix_FreeChunk(it.second);
|
Mix_FreeChunk(it.second);
|
||||||
@ -81,6 +86,10 @@ class SoundManager
|
|||||||
static void addSingleBackgroundMusic(BackgroundMusic backgroundMusic, const char* path);
|
static void addSingleBackgroundMusic(BackgroundMusic backgroundMusic, const char* path);
|
||||||
static void addBackgroundMusic(const std::map<BackgroundMusic, const char*> &backgroundMusic);
|
static void addBackgroundMusic(const std::map<BackgroundMusic, const char*> &backgroundMusic);
|
||||||
|
|
||||||
|
static SoundManager* getInstance() {
|
||||||
|
return this_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@ -185,6 +185,8 @@ void SoundManager::addBackgroundMusic(const std::map<BackgroundMusic, const char
|
|||||||
addSingleBackgroundMusic(track.first, track.second);
|
addSingleBackgroundMusic(track.first, track.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoundManager* SoundManager::this_instance = nullptr;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user