We already have MotionMessages and a MotionEngine. So it seems logical to re-use these structures for our ball.
What is actually going to be sending out the MotionMessages?
What is the main characteristic of the ball in Pong? That's right - it is continuously moving. In other words, it has velocity.
Let's make a VelocityComponent. In **game/components/velocity.ts**:
```ts
import { Component } from "encompass-ecs";
export class VelocityComponent extends Component {
public x: number;
public y: number;
}
```
Let's also create a VelocityEngine.
What does our VelocityEngine actually do? Basically, if something has both a PositionComponent and VelocityComponent, we want the PositionComponent to update based on the VelocityComponent every frame.
It turns out Encompass provides a structure for this pattern, called a Detector. Let's use it now.
In **game/engines/velocity.ts**:
```ts
import { Detector, Emits, Entity } from "encompass-ecs";
import { PositionComponent } from "game/components/position";
import { VelocityComponent } from "game/components/velocity";
import { MotionMessage } from "game/messages/component/motion";
When an Entity has all of the components specified in **@Detects**, it begins to track the Entity. Each frame, it calls its *detect* method on that Entity.