#include "raylib.h"
#include "sounds.h"

Sound explosion_sound;
Sound pickup_coin_sound;

void load_sounds(void)
{
	InitAudioDevice();

	Wave explosion_wave = LoadWaveFromMemory(".wav", (const unsigned char *)explosion_wav, explosion_wav_len);
	explosion_sound = LoadSoundFromWave(explosion_wave);
	UnloadWave(explosion_wave);

	Wave pickup_coin_wave = LoadWaveFromMemory(".wav", (const unsigned char *)pickup_coin_wav, pickup_coin_wav_len);
	pickup_coin_sound = LoadSoundFromWave(pickup_coin_wave);
	UnloadWave(pickup_coin_wave);
}

void play_explosion_sound()
{
	if (!IsSoundPlaying(explosion_sound))
	{
		PlaySound(explosion_sound);
	}
}

void play_pickup_coin_sound()
{
	if (!IsSoundPlaying(pickup_coin_sound))
	{
		PlaySound(pickup_coin_sound);
	}
}

void unload_sounds(void)
{
	UnloadSound(explosion_sound);
	UnloadSound(pickup_coin_sound);

	CloseAudioDevice();
}

