WIP
This commit is contained in:
@@ -187,5 +187,7 @@ const DevTools: Component<{ gameContainer: HTMLElement }> = ({
|
||||
};
|
||||
|
||||
export function use(container: HTMLElement): void {
|
||||
// @ts-ignore - just for console access
|
||||
window.$ = (name: string) => currentScene.components.get(name);
|
||||
render(() => <DevTools gameContainer={container} />, document.body);
|
||||
}
|
||||
|
||||
+11
-11
@@ -412,7 +412,7 @@ function createCollision(): Collision {
|
||||
};
|
||||
}
|
||||
|
||||
const relVelocity = createVector();
|
||||
const relativeVel = createVector();
|
||||
export function moveAndCollide(
|
||||
id: string,
|
||||
velocity: Vector,
|
||||
@@ -420,7 +420,8 @@ export function moveAndCollide(
|
||||
): Array<Collision> {
|
||||
const colliders = $<Collider>("collider")!;
|
||||
const positions = $<Vector>("position")!;
|
||||
const velocities = $<Vector>("velocity");
|
||||
const velocities = $<Vector>("velocity")!;
|
||||
|
||||
const selfColl = colliders.get(id)!.value;
|
||||
const selfPos = positions.get(id)!.value;
|
||||
|
||||
@@ -434,13 +435,12 @@ export function moveAndCollide(
|
||||
|
||||
const otherColl = collider.value;
|
||||
const otherPos = positions.get(cid)!.value;
|
||||
const otherVel = velocities?.get(cid)?.value ?? ZERO;
|
||||
const otherVel = velocities.get(cid)?.value ?? ZERO;
|
||||
|
||||
relVelocity.x = velocity.x - otherVel.x;
|
||||
relVelocity.y = velocity.y - otherVel.y;
|
||||
relativeVel.x = velocity.x - otherVel.x;
|
||||
relativeVel.y = velocity.y - otherVel.y;
|
||||
|
||||
// no relative motion
|
||||
if (relVelocity.x === 0 && relVelocity.y === 0) {
|
||||
if (relativeVel.x === 0 && relativeVel.y === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -449,7 +449,7 @@ export function moveAndCollide(
|
||||
collision,
|
||||
selfColl,
|
||||
selfPos,
|
||||
relVelocity,
|
||||
relativeVel,
|
||||
otherColl,
|
||||
otherPos,
|
||||
delta,
|
||||
@@ -467,7 +467,7 @@ export function moveAndCollide(
|
||||
collision,
|
||||
selfColl,
|
||||
selfPos,
|
||||
relVelocity,
|
||||
relativeVel,
|
||||
otherColl,
|
||||
otherPos,
|
||||
delta,
|
||||
@@ -479,7 +479,7 @@ export function moveAndCollide(
|
||||
collision,
|
||||
selfColl,
|
||||
selfPos,
|
||||
relVelocity,
|
||||
relativeVel,
|
||||
otherColl,
|
||||
otherPos,
|
||||
delta,
|
||||
@@ -491,7 +491,7 @@ export function moveAndCollide(
|
||||
collision,
|
||||
selfColl,
|
||||
selfPos,
|
||||
relVelocity,
|
||||
relativeVel,
|
||||
otherColl,
|
||||
otherPos,
|
||||
delta,
|
||||
|
||||
Reference in New Issue
Block a user