import { CollisionType } from "game/components/collision_types";
import { Collision } from "lua-lib/bump";
export class CollisionMessage extends Message {
public entity_one: Entity;
public entity_two: Entity;
public collision_type_one: CollisionType;
public collision_type_two: CollisionType;
public entity_one_new_x: number;
public entity_one_new_y: number;
public entity_two_new_x: number;
public entity_two_new_y: number;
public collision_data: Collision;
}
```
Let's break down what we want collision detection to actually do.
First, we tell the Collision World about the current positions of the objects. Next we check each object for collisions by using the "check" method, which takes the proposed new position of the object and gives us collision information in return.
Why are we comparing the collision types? Let's say we want to have a BallWallCollisionMessage. Obviously we will want to know which entity in the collision represents the ball and which one represents the wall. So we just sort them at this step for convenience.
Let's make sure that our enum is sorted in alphabetical order.
The "initialize" method gives the Engine a reference to the Collision World that needs to be shared by everything that deals with collision. Let's make sure to call the "initialize" method from **game.ts**: