mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 09:03:42 +00:00
Compare commits
2 Commits
d7329953c2
...
ca77b8f7e2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca77b8f7e2 | ||
|
|
1dc00408de |
@ -68,7 +68,7 @@ class SoundManager
|
|||||||
*
|
*
|
||||||
* Handles how often track can loop, as well as the volume at which the specified track should play and if it fades in.
|
* Handles how often track can loop, as well as the volume at which the specified track should play and if it fades in.
|
||||||
*/
|
*/
|
||||||
static void playMusic(BackgroundMusic sound, int loops, int volume, int ms);
|
static void playMusic(BackgroundMusic sound, int loops, int volume, int milliseconds);
|
||||||
|
|
||||||
static void setSoundVolume(int volume, int channel); //!< Volume handling for sound effects (either all or on a specific channel)
|
static void setSoundVolume(int volume, int channel); //!< Volume handling for sound effects (either all or on a specific channel)
|
||||||
static void setMusicVolume(int volume); //!< Volume handling for music track
|
static void setMusicVolume(int volume); //!< Volume handling for music track
|
||||||
@ -81,9 +81,16 @@ class SoundManager
|
|||||||
|
|
||||||
static void fadeOutMusic(int ms); //!< Handles fading out a music track
|
static void fadeOutMusic(int ms); //!< Handles fading out a music track
|
||||||
|
|
||||||
static void addSingleSoundEffect(SoundEffects soundEffect, const char* path);
|
/*!
|
||||||
|
* \brief Initializes sound-effects and adds them to a cache
|
||||||
|
*
|
||||||
|
*/
|
||||||
static void addSoundEffects(const std::map<SoundEffects, const char*> &effects);
|
static void addSoundEffects(const std::map<SoundEffects, const char*> &effects);
|
||||||
static void addSingleBackgroundMusic(BackgroundMusic backgroundMusic, const char* path);
|
|
||||||
|
/*!
|
||||||
|
* \brief Initializes background-music and adds them to a cache
|
||||||
|
*
|
||||||
|
*/
|
||||||
static void addBackgroundMusic(const std::map<BackgroundMusic, const char*> &backgroundMusic);
|
static void addBackgroundMusic(const std::map<BackgroundMusic, const char*> &backgroundMusic);
|
||||||
|
|
||||||
static SoundManager* getInstance() {
|
static SoundManager* getInstance() {
|
||||||
@ -96,4 +103,7 @@ class SoundManager
|
|||||||
std::map<BackgroundMusic, Mix_Music*> music_cache;
|
std::map<BackgroundMusic, Mix_Music*> music_cache;
|
||||||
std::map<SoundEffects, Mix_Chunk*> sound_cache;
|
std::map<SoundEffects, Mix_Chunk*> sound_cache;
|
||||||
static SoundManager* this_instance;
|
static SoundManager* this_instance;
|
||||||
|
|
||||||
|
static void addSingleBackgroundMusic(BackgroundMusic backgroundMusic, const char* path);
|
||||||
|
static void addSingleSoundEffect(SoundEffects soundEffect, const char* path);
|
||||||
};
|
};
|
||||||
@ -83,7 +83,7 @@ void SoundManager::playSound(SoundEffects sound, bool canOverlap, int loops, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundManager::playMusic(BackgroundMusic music, int loops, int volume, int ms)
|
void SoundManager::playMusic(BackgroundMusic music, int loops, int volume, int milliseconds)
|
||||||
{
|
{
|
||||||
if (!this_instance->music_cache.contains(music)) {
|
if (!this_instance->music_cache.contains(music)) {
|
||||||
std::cerr << "Error playing music: music not found" << std::endl;
|
std::cerr << "Error playing music: music not found" << std::endl;
|
||||||
@ -93,9 +93,9 @@ void SoundManager::playMusic(BackgroundMusic music, int loops, int volume, int m
|
|||||||
if (Mix_PlayingMusic() != 0 || Mix_Fading() == Mix_Fading::MIX_FADING_IN)
|
if (Mix_PlayingMusic() != 0 || Mix_Fading() == Mix_Fading::MIX_FADING_IN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(ms > 0)
|
if(milliseconds > 0)
|
||||||
{
|
{
|
||||||
Mix_FadeInMusic(this_instance->music_cache.at(music), loops, ms);
|
Mix_FadeInMusic(this_instance->music_cache.at(music), loops, milliseconds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user