From d5a904fe8f978c13f5c8f25d7b5b797a46eb07d6 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Mon, 5 Feb 2024 12:31:41 +0300 Subject: [PATCH] feat: Ball Hit Sound Effect --- Game/Behaviours/BallBehaviour.cs | 16 +++++++++++++++- Game/Content/Content.mgcb | 6 ++++++ Game/Content/Hit.wav | Bin 0 -> 2208 bytes 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Game/Content/Hit.wav diff --git a/Game/Behaviours/BallBehaviour.cs b/Game/Behaviours/BallBehaviour.cs index 3e5b6df..cebf123 100644 --- a/Game/Behaviours/BallBehaviour.cs +++ b/Game/Behaviours/BallBehaviour.cs @@ -1,13 +1,19 @@ using System; + +using Microsoft.Xna.Framework.Content; + using LiteNetLib; + using Pong.Network; + using Syntriax.Engine.Core; using Syntriax.Engine.Physics2D; using Syntriax.Engine.Physics2D.Abstract; +using Microsoft.Xna.Framework.Audio; namespace Pong.Behaviours; -public class BallBehaviour : BehaviourOverride +public class BallBehaviour : BehaviourOverride, IMonoGameContentLoader { public Vector2D StartDirection { get; private set; } = Vector2D.Zero; public float Speed { get; set; } = 500f; @@ -16,6 +22,12 @@ public class BallBehaviour : BehaviourOverride private readonly Random random = new(); private IRigidBody2D rigidBody = null!; private INetworkCommunicator communicator = null!; + private SoundEffect soundEffect = null!; + + public void LoadContent(ContentManager content) + { + soundEffect = content.Load("Hit"); + } protected override void OnFirstActiveFrame() { @@ -84,6 +96,8 @@ public class BallBehaviour : BehaviourOverride else rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal); + soundEffect.Play(); + SendBallData(); } diff --git a/Game/Content/Content.mgcb b/Game/Content/Content.mgcb index d1b9814..f14b8e8 100644 --- a/Game/Content/Content.mgcb +++ b/Game/Content/Content.mgcb @@ -13,6 +13,12 @@ #---------------------------------- Content ---------------------------------# +#begin Hit.wav +/importer:WavImporter +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:Hit.wav + #begin UbuntuMono.spritefont /importer:FontDescriptionImporter /processor:FontDescriptionProcessor diff --git a/Game/Content/Hit.wav b/Game/Content/Hit.wav new file mode 100644 index 0000000000000000000000000000000000000000..9bc1f991c5bf99c95713e06cc94800b45e14016b GIT binary patch literal 2208 zcmbu;`&SY{6bJD2H-GF;=wIoaQZyqnAH561N6AZA((-}e@l{zQp;)G2B`Km%M1UZ^ z`oFsO&dkp4irP7SJhH>g{oa|gyR*aP4$uj1q1)&V2pt|A9PID!SF2-&`Mc;Ix=$XUeXK_N`i#wFS-(?oxdz#7hbOgH zQQ5BghO*Gbx!vv*K3ICP<)qxZW+_x7k0*>TLb*(DPgH*Z*_M?;t;V}5-nL?)5Oj(o zxLmxHI*V$rlr0t^Q1}h1V1)K=F9}k z`TbEyfNVCK$z&oja&ixr@cE@R%w%?UcDBJ=ul`)TSnMJ*ewACoP&%F70;v>jrw{28 zFccwn4FC+KQk!4{h@>H945^rsmLc^WCBgb@89Xx;2t3mylI!3b_zL32oZN^;T1XoV zq8SK&0c$9ch^VGR>UQHniWxtK65umhMJtoIqqdJ27&G{7$RxG`K9OZK%%bN9sn2t1 z>LdC{u%}e2V$``FC7| z%o)?C#MtymEulBUoDej0sTDHKjh-<53cQqNXJ>=@(22n56JvUzY0Z={u4VO=|2__K Q;R&;FI3yPT|2jVY7Y%GE!~g&Q literal 0 HcmV?d00001