From deda1c6b8cf1ca4ea4d0468abf50e48b214c9421 Mon Sep 17 00:00:00 2001 From: Albert Vaca Cintora Date: Thu, 14 Mar 2024 12:31:54 +0100 Subject: [PATCH] More 3d sounds --- src/bat.cpp | 2 +- src/common_bullet.h | 6 ++++-- src/fireslime.cpp | 2 +- src/missile.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bat.cpp b/src/bat.cpp index 86d97953..40fee86d 100644 --- a/src/bat.cpp +++ b/src/bat.cpp @@ -54,7 +54,7 @@ Bat::~Bat() } void Bat::Screech() const { - Assets::batScreech.Play(pos, Player::instance()->pos, Window::GAME_WIDTH*0.6); + Assets::batScreech.Play(pos, Player::instance()->pos, Window::GAME_WIDTH*0.6f); } void Bat::Update(float dt) diff --git a/src/common_bullet.h b/src/common_bullet.h index 797f7ed0..c544a8be 100644 --- a/src/common_bullet.h +++ b/src/common_bullet.h @@ -4,6 +4,8 @@ #include "assets_sounds.h" #include "gaemtilemap.h" #include "destroyedtiles.h" +#include "window_conf.h" +#include "player.h" // Takes the bullet radius into account to calculate collisions, // use SmallBulletTilemapCollision for single-pixel collisions @@ -27,7 +29,7 @@ bool BigBulletTilemapCollision(T* bullet, Tile::BreakResistance breakTilesPower return false; hit: if (tile.isBreakable(breakTilesPower)) { - Assets::breakBlock.Play(); + Assets::breakBlock.Play(bullet->pos, Player::instance()->pos, Window::GAME_WIDTH); DestroyedTiles::instance()->Destroy(t.x, t.y); } return true; @@ -49,7 +51,7 @@ bool SmallBulletTilemapCollision(T* bullet, Tile::BreakResistance breakTilesPowe return false; hit: if (tile.isBreakable(breakTilesPower)) { - Assets::breakBlock.Play(); + Assets::breakBlock.Play(bullet->pos, Player::instance()->pos, Window::GAME_WIDTH); DestroyedTiles::instance()->Destroy(t.x, t.y); } return true; diff --git a/src/fireslime.cpp b/src/fireslime.cpp index b88b9bee..c1d8f9f7 100644 --- a/src/fireslime.cpp +++ b/src/fireslime.cpp @@ -112,7 +112,7 @@ void FireSlime::Update(float dt) if (ReceiveDamageFromPlayer(Bounds(), false)) { DieWithSmallExplosion(this); //single hit - Assets::soundSlimyDead.Play(); + Assets::soundSlimyDead.Play(pos, Player::instance()->pos); return; } diff --git a/src/missile.cpp b/src/missile.cpp index 399db0e4..d986b859 100644 --- a/src/missile.cpp +++ b/src/missile.cpp @@ -24,7 +24,7 @@ Missile::Missile(vec position, float angleDegs) , anim(AnimLib::MISSILE) { vel = vec::FromAngleDegs(angleDegs, kSpeed); - soundChannel = Assets::soundMissile.Play(); + soundChannel = Assets::soundMissile.Play(position, Player::instance()->pos, Window::GAME_WIDTH); } void Missile::Update(float dt)