0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 09:03:42 +00:00
SDL_Minigame/include/SoundManager.h
ineslelin db44d4d619 updated SoundManager
- created constexpr for the options to play a sound once or loop it infinitely
- removed SoundTypes enum, changed playSound() to accept a string and a bool => allows for playSound() to be used more universally
2024-05-27 11:36:02 +02:00

43 lines
852 B
C++

#pragma once
#include <SDL_mixer.h>
#include <map>
#include <vector>
#include "ECS.h"
#include "TextureManager.h"
// enum SoundTypes
// {
// STEPS,
// THROW_EGG,
// };
class Game;
class SoundManager
{
public:
SoundManager() {}
~SoundManager() {
for (auto& it : this->sound_cache) {
Mix_FreeChunk(it.second);
}
for (auto& it : this->music_cache) {
Mix_FreeMusic(it.second);
}
}
SoundManager(SoundManager const&) = delete;
void operator=(SoundManager const&) = delete;
std::map<const char*, Mix_Music*> music_cache;
std::map<const char*, Mix_Chunk*> sound_cache;
Mix_Music* loadMusic(const char* fileName);
Mix_Chunk* loadSound(const char* fileName);
static void playSound(Game* game, /*SoundTypes sound*/ std::string sound, bool canOverlap, int loops);
// static void playMusic(...);
private:
};