Remove sound playing slots, as they do not work

This commit is contained in:
2024-02-10 16:26:48 +01:00
parent 1b28a93d91
commit c738ce5c14
2 changed files with 5 additions and 20 deletions

View File

@@ -4,9 +4,9 @@ void soundsApplyVolume(SoundState *sounds, f32 master, f32 music, f32 sound) {
SetMasterVolume(master); SetMasterVolume(master);
if (sounds->musicLoaded) if (sounds->musicLoaded)
SetMusicVolume(sounds->music, music); SetMusicVolume(sounds->music, music);
for (i32 i = 0; i < SOUND_MAX_PLAYING; i++) { for (i32 i = 0; i < SOUND_COUNT; i++) {
if (IsSoundPlaying(sounds->playing[i])) if (IsSoundPlaying(sounds->sounds[i]))
SetSoundVolume(sounds->playing[i], sound); SetSoundVolume(sounds->sounds[i], sound);
} }
sounds->masterVolume = master; sounds->masterVolume = master;
@@ -25,20 +25,8 @@ bool soundsPlay(SoundState *sounds, SoundType type) {
if (time - lastPlayedTime < sounds->soundInterval[type]) if (time - lastPlayedTime < sounds->soundInterval[type])
return false; return false;
i32 freeSlot = -1; PlaySound(sounds->sounds[type]);
for (i32 i = 0; i < SOUND_MAX_PLAYING; i++) { SetSoundVolume(sounds->sounds[type], sounds->soundVolume);
if (!IsSoundPlaying(sounds->playing[i])) {
freeSlot = i;
break;
}
}
if (freeSlot == -1) {
return false;
}
sounds->playing[freeSlot] = sounds->sounds[type];
PlaySound(sounds->playing[freeSlot]);
SetSoundVolume(sounds->playing[freeSlot], sounds->soundVolume);
sounds->soundLastPlayed[type] = time; sounds->soundLastPlayed[type] = time;
return true; return true;
} }

View File

@@ -32,12 +32,9 @@ static SoundType getRandomSoundType(SoundType min, SoundType max) {
return GetRandomValue(min, max); return GetRandomValue(min, max);
} }
#define SOUND_MAX_PLAYING 16
typedef struct SoundState { typedef struct SoundState {
Rectangle cameraBounds; Rectangle cameraBounds;
Sound sounds[SOUND_COUNT]; Sound sounds[SOUND_COUNT];
Sound playing[SOUND_MAX_PLAYING];
// How long it needs to wait, // How long it needs to wait,
// before playing the same sound // before playing the same sound
f32 soundLastPlayed[SOUND_COUNT]; f32 soundLastPlayed[SOUND_COUNT];