From adb0345df76763c0607367c9563ead8a1f674185 Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Fri, 31 May 2019 10:32:34 -0700 Subject: [PATCH] stuff --- content/pong/ball/bouncing/design.md | 2 +- content/pong/ball/bouncing/motion_engine.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/content/pong/ball/bouncing/design.md b/content/pong/ball/bouncing/design.md index 9370a7e..629b84c 100644 --- a/content/pong/ball/bouncing/design.md +++ b/content/pong/ball/bouncing/design.md @@ -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. diff --git a/content/pong/ball/bouncing/motion_engine.md b/content/pong/ball/bouncing/motion_engine.md index 2c21d6d..eb099cf 100644 --- a/content/pong/ball/bouncing/motion_engine.md +++ b/content/pong/ball/bouncing/motion_engine.md @@ -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";