73 lines
1.8 KiB
C
73 lines
1.8 KiB
C
#ifndef PIXELDEFENSE_SOUNDS_H
|
|
#define PIXELDEFENSE_SOUNDS_H
|
|
|
|
#include <breeze.h>
|
|
#include <flecs.h>
|
|
#include <raylib.h>
|
|
|
|
typedef enum SoundType {
|
|
SOUND_HURT_1,
|
|
SOUND_HURT_2,
|
|
SOUND_HURT_3,
|
|
SOUNDS_ORE_PUNCH_1,
|
|
SOUNDS_ORE_PUNCH_2,
|
|
SOUNDS_ORE_PUNCH_3,
|
|
SOUNDS_ORE_PUNCH_4,
|
|
SOUNDS_ORE_PUNCH_5,
|
|
SOUNDS_WHEAT_PUNCH_1,
|
|
SOUNDS_WHEAT_PUNCH_2,
|
|
SOUNDS_WHEAT_PUNCH_3,
|
|
SOUNDS_WHEAT_PUNCH_4,
|
|
SOUNDS_WHEAT_PUNCH_5,
|
|
SOUNDS_WOOD_PUNCH_1,
|
|
SOUNDS_WOOD_PUNCH_2,
|
|
SOUNDS_WOOD_PUNCH_3,
|
|
SOUNDS_WOOD_PUNCH_4,
|
|
SOUNDS_WOOD_PUNCH_5,
|
|
SOUND_COUNT
|
|
} SoundType;
|
|
|
|
static SoundType getRandomSoundType(SoundType min, SoundType max) {
|
|
BZ_ASSERT(min <= max && min >= 0 && max < SOUND_COUNT);
|
|
return GetRandomValue(min, max);
|
|
}
|
|
|
|
typedef struct SoundState {
|
|
Rectangle cameraBounds;
|
|
Sound sounds[SOUND_COUNT];
|
|
// How long it needs to wait,
|
|
// before playing the same sound
|
|
f32 soundLastPlayed[SOUND_COUNT];
|
|
f32 soundInterval[SOUND_COUNT];
|
|
|
|
bool musicLoaded;
|
|
Music music;
|
|
|
|
f32 masterVolume;
|
|
f32 musicVolume;
|
|
f32 soundVolume;
|
|
} SoundState;
|
|
|
|
void soundsApplyVolume(SoundState *sounds, f32 master, f32 music, f32 sound);
|
|
|
|
void soundsLoad(SoundState *sounds, SoundType type, f32 interval, const char *path);
|
|
bool soundsPlay(SoundState *sounds, SoundType type);
|
|
bool soundsPosPlay(SoundState *sounds, Vector2 position, SoundType type);
|
|
|
|
void soundsUnloadAll(SoundState *sounds);
|
|
|
|
void soundsUpdate(SoundState *sounds, Rectangle cameraBounds);
|
|
|
|
void soundsLoadMusicStream(SoundState *sounds, const char *path);
|
|
void soundsPlayMusicStream(SoundState *sounds);
|
|
void soundsPauseMusicStream(SoundState *sounds);
|
|
void soundsResumeMusicStream(SoundState *sounds);
|
|
void soundsUnloadMusicStream(SoundState *sounds);
|
|
|
|
|
|
extern ECS_COMPONENT_DECLARE(SoundState); // defined in main.c
|
|
|
|
|
|
|
|
#endif //PIXELDEFENSE_SOUNDS_H
|