VERY hacky positional audio
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -59,6 +59,9 @@ struct World {
|
||||
U32 propCount;
|
||||
U32 hitboxCount;
|
||||
|
||||
Audio_Context *audio;
|
||||
U32 audio_handles[2];
|
||||
|
||||
//// Player
|
||||
Player player;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user