VERY hacky positional audio

This commit is contained in:
2025-10-06 22:17:41 +01:00
parent 59f643b72c
commit df2c02a6a9
7 changed files with 49 additions and 12 deletions

View File

@@ -164,6 +164,16 @@ void PlayerUpdate(F32 delta, Player *player) {
dir = V2f_Scale(NormaliseV2F(dir), PLAYER_SPEED*delta);
player->collision.pos.x += dir.x;
player->collision.pos.y += dir.y;
V2f test;
test.x = player->collision.pos.x - 14;
test.y = player->collision.pos.y - 14;
F32 len = V2f_Dot(test, test);
F32 vol = Max(0.0f, 1.0f - (len / 25.0f));
Audio_ChangeVolume(player->world->audio, player->world->audio_handles[1], vol);
Audio_ChangeVolume(player->world->audio, player->world->audio_handles[0], 1.0f - vol);
}
void PlayerDraw(D_Context *draw, Player *player) {