Remove sound playing slots, as they do not work
This commit is contained in:
@@ -4,9 +4,9 @@ void soundsApplyVolume(SoundState *sounds, f32 master, f32 music, f32 sound) {
|
||||
SetMasterVolume(master);
|
||||
if (sounds->musicLoaded)
|
||||
SetMusicVolume(sounds->music, music);
|
||||
for (i32 i = 0; i < SOUND_MAX_PLAYING; i++) {
|
||||
if (IsSoundPlaying(sounds->playing[i]))
|
||||
SetSoundVolume(sounds->playing[i], sound);
|
||||
for (i32 i = 0; i < SOUND_COUNT; i++) {
|
||||
if (IsSoundPlaying(sounds->sounds[i]))
|
||||
SetSoundVolume(sounds->sounds[i], sound);
|
||||
}
|
||||
|
||||
sounds->masterVolume = master;
|
||||
@@ -25,20 +25,8 @@ bool soundsPlay(SoundState *sounds, SoundType type) {
|
||||
if (time - lastPlayedTime < sounds->soundInterval[type])
|
||||
return false;
|
||||
|
||||
i32 freeSlot = -1;
|
||||
for (i32 i = 0; i < SOUND_MAX_PLAYING; i++) {
|
||||
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);
|
||||
PlaySound(sounds->sounds[type]);
|
||||
SetSoundVolume(sounds->sounds[type], sounds->soundVolume);
|
||||
sounds->soundLastPlayed[type] = time;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -32,12 +32,9 @@ static SoundType getRandomSoundType(SoundType min, SoundType max) {
|
||||
return GetRandomValue(min, max);
|
||||
}
|
||||
|
||||
#define SOUND_MAX_PLAYING 16
|
||||
|
||||
typedef struct SoundState {
|
||||
Rectangle cameraBounds;
|
||||
Sound sounds[SOUND_COUNT];
|
||||
Sound playing[SOUND_MAX_PLAYING];
|
||||
// How long it needs to wait,
|
||||
// before playing the same sound
|
||||
f32 soundLastPlayed[SOUND_COUNT];
|
||||
|
||||
Reference in New Issue
Block a user