Famous / Famous/engine

feat: Velocity System [Comments Wanted]

Open
#368 6 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
1.7k
Forks
249
PR merge metrics
No merged PRs in 30d

Description

I am going to get started on a `VelocitySystem`, it will be the same as all of the existing systems where it updates every frame. Unlike the existing component/system frameworks, **you must opt-in** by doing something like:

```
function MyCustomNode() {
Node.call(this);
this._velocityID = this.addComponent(new Velocity());
...
}
```

(Meaning if you `init` the node, the `Velocity` component will not come by default.)

There are several advantages to this approach, and it should generate very smooth velocity components. I'm thinking of using the `PhysicsEngine` and I might try to coerce it into generating the Velocities, but I'm open to other suggestions.

Then you would add logic something along the lines of:

```
MyCustomNode.prototype.onReceive = function onReceive(type, event) {
this.getVelocity().addEvent(type, event);
...
}
```

The `VelocitySystem` would take care of direction changes, pauses, increasing / decreasing speed, etc.

Please share any comments / questions / concerns.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.