Files
game-engine/src/game/resource/resource_sound.c
2024-04-11 01:05:03 -04:00

45 lines
968 B
C

#include "resource_sound.h"
/* Initializes sound resource. */
bool
resource_sound_init(Resources* self, SoundType type)
{
if (!sound_init(&self->sounds[type], SOUND_PATHS[type]))
{
printf(STRING_RESOURCE_SOUND_ERROR, SOUND_PATHS[type]);
return false;
}
printf(STRING_RESOURCE_SOUND_INIT, SOUND_PATHS[type]);
return true;
}
/* Frees sound resources. */
void
resource_sound_free(Resources* self, SoundType type)
{
if (self->sounds[type].isInit)
{
sound_free(&self->sounds[type]);
printf(STRING_RESOURCE_SOUND_FREE, SOUND_PATHS[type]);
}
}
/* Given an array, initializes sound resources. */
void
resource_sound_state_init(Resources* self, const SoundType* types, u32 count)
{
for (s32 i = 0; i < (s32)count; i++)
resource_sound_init(self, types[i]);
}
/* Frees sound resources. */
void
resource_sound_state_free(Resources* self, const SoundType* types, u32 count)
{
for (s32 i = 0; i < (s32)count; i++)
resource_sound_free(self, types[i]);
}