feat: Ball Hit Sound Effect

This commit is contained in:
Syntriax 2024-02-05 12:31:41 +03:00
parent b1582ab5c2
commit d5a904fe8f
3 changed files with 21 additions and 1 deletions

View File

@ -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<SoundEffect>("Hit");
}
protected override void OnFirstActiveFrame()
{
@ -84,6 +96,8 @@ public class BallBehaviour : BehaviourOverride
else
rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal);
soundEffect.Play();
SendBallData();
}

View File

@ -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

BIN
Game/Content/Hit.wav Normal file

Binary file not shown.