Add hurt sounds, fix sound playing
This commit is contained in:
@@ -27,7 +27,7 @@ bool soundsPlay(SoundState *sounds, SoundType type) {
|
|||||||
|
|
||||||
i32 freeSlot = -1;
|
i32 freeSlot = -1;
|
||||||
for (i32 i = 0; i < SOUND_MAX_PLAYING; i++) {
|
for (i32 i = 0; i < SOUND_MAX_PLAYING; i++) {
|
||||||
if (IsSoundPlaying(sounds->playing[i])) {
|
if (!IsSoundPlaying(sounds->playing[i])) {
|
||||||
freeSlot = i;
|
freeSlot = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -36,6 +36,7 @@ bool soundsPlay(SoundState *sounds, SoundType type) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sounds->playing[freeSlot] = sounds->sounds[type];
|
||||||
PlaySound(sounds->playing[freeSlot]);
|
PlaySound(sounds->playing[freeSlot]);
|
||||||
SetSoundVolume(sounds->playing[freeSlot], sounds->soundVolume);
|
SetSoundVolume(sounds->playing[freeSlot], sounds->soundVolume);
|
||||||
sounds->soundLastPlayed[type] = time;
|
sounds->soundLastPlayed[type] = time;
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ void damageEvent(ecs_entity_t entity, DamageEvent event) {
|
|||||||
bloodEmitter.targetParticles = ecs_id(ParticleLayer1);
|
bloodEmitter.targetParticles = ecs_id(ParticleLayer1);
|
||||||
ecs_set_ptr(ECS, bloodEmitterEntity, ParticleEmitter, &bloodEmitter);
|
ecs_set_ptr(ECS, bloodEmitterEntity, ParticleEmitter, &bloodEmitter);
|
||||||
|
|
||||||
|
SoundState *sounds = ecs_singleton_get_mut(ECS, SoundState);
|
||||||
|
bool status = soundsPosPlay(sounds, center, getRandomSoundType(SOUND_HURT_1, SOUND_HURT_3));
|
||||||
|
|
||||||
Vector2 pos = {
|
Vector2 pos = {
|
||||||
event.hitbox.x + event.hitbox.width * 0.5f + randFloatRange(-2, 2),
|
event.hitbox.x + event.hitbox.width * 0.5f + randFloatRange(-2, 2),
|
||||||
event.hitbox.y + randFloatRange(2, 4)
|
event.hitbox.y + randFloatRange(2, 4)
|
||||||
|
|||||||
Reference in New Issue
Block a user