pull/1/head
Evan Hemsley 2019-05-31 10:32:34 -07:00
parent 4dcb05d8e6
commit adb0345df7
2 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,7 @@ We already have MotionMessages. Let's keep those, but redirect them slightly. We
Let's have the MotionEngine consolidate all the MotionMessages per-component, send out an UpdatePositionMessage with that final delta, but then also send out a CollisionCheckMessage for everything that has a BoundingBoxComponent.
Finally, a CollisionResolveEngine figures out what two kinds of objects collided and emits a Message in response. We can then implement Engines that read each of those kinds of Messages.
Finally, a CollisionDispatchEngine figures out what two kinds of objects collided and emits a Message in response. We can then implement Engines that read each of those kinds of Messages.
Whew! That's a lot! You might be wondering why we're doing all this work just to get some objects reacting to each other.

View File

@ -4,7 +4,11 @@ date: 2019-05-28T18:01:49-07:00
weight: 500
---
Let's rewrite our MotionEngine.
Here's the process we'll follow for our MotionEngine:
We associate MotionMessages with their PositionComponents. We consolidate them to get a total "x_delta" and a "y_delta". We create an UpdatePositionMessage containing these values. Next, we create CollisionCheckMessages containing the delta values if the PositionComponent's entity has a BoundingBoxComponent.
Finally, we go over all BoundingBoxComponents that didn't have MotionMessages associated with them and create CollisionCheckMessages for those too. Otherwise things that didn't move wouldn't be collision checked, and that would not be correct.
In **game/messages/collision_check.ts**:
@ -31,11 +35,7 @@ export class UpdatePositionMessage extends Message implements ComponentMessage {
}
```
Here's the process we'll follow for our MotionEngine:
We associate MotionMessages with their PositionComponents. We consolidate them to get a total "x_delta" and a "y_delta". We create an UpdatePositionMessage containing these values. Next, we create CollisionCheckMessages containing the delta values if the PositionComponent's entity has a BoundingBoxComponent.
Finally, we go over all BoundingBoxComponents that didn't have MotionMessages associated with them and create CollisionCheckMessages for those too. Otherwise things that didn't move wouldn't be collision checked, and that would not be correct.
Let's rewrite our MotionEngine.
```ts
import { Emits, Engine, Reads } from "encompass-ecs";