Now the ball needs to bounce off of the paddle. What does that mean? If there is a horizontal collision, we reverse the horizontal velocity. Otherwise we reverse the vertical velocity.
In **PongFE/Engines/BounceEngine.cs**:
```cs
using System.Numerics;
using Encompass;
using PongFE.Components;
using PongFE.Messages;
namespace PongFE.Engines
{
[Reads(
typeof(BounceResponseComponent),
typeof(VelocityComponent)
)]
[Receives(typeof(BounceMessage))]
[Sends(typeof(UpdateVelocityMessage))]
public class BounceEngine : Engine
{
public override void Update(double dt)
{
foreach (ref readonly var message in ReadMessages<BounceMessage>())
{
if (HasComponent<BounceResponseComponent>(message.Entity) && HasComponent<VelocityComponent>(message.Entity))
{
ref readonly var velocityComponent = ref GetComponent<VelocityComponent>(message.Entity);
Vector2 newVelocity;
if (message.HitOrientation == HitOrientation.Horizontal)
{
newVelocity =
new Vector2(-velocityComponent.Velocity.X, velocityComponent.Velocity.Y);
}
else
{
newVelocity =
new Vector2(velocityComponent.Velocity.X, -velocityComponent.Velocity.Y);