This commit is contained in:
schmelczerandras 2020-11-04 16:01:17 +01:00
commit 99cdb62928
5 changed files with 338 additions and 431 deletions

View file

@ -1,6 +1,7 @@
import { vec2 } from 'gl-matrix';
export class BoundingBoxBase {
// axes aligned
export abstract class BoundingBoxBase {
constructor(
protected _xMin: number = 0,
protected _xMax: number = 0,

View file

@ -1,7 +1,7 @@
import { BoundingBoxBase } from '../bounding-boxes/bounding-box-base';
import { StaticPhysical } from '../physicals/static-physical';
// source: https://github.com/ubilabs/kd-tree-javascript/blob/master/kdTree.js
// source: https://github.com/ubilabs/kd-tree-javascript/blob/master/kdTree.js
class Node {
public left: Node | null = null;
public right: Node | null = null;

View file

@ -1,8 +1,9 @@
import { Circle } from 'shared';
import { BoundingBoxBase } from '../bounding-boxes/bounding-box-base';
import { ImmutableBoundingBox } from '../bounding-boxes/immutable-bounding-box';
export const getBoundingBoxOfCircle = (circle: Circle): BoundingBoxBase =>
new BoundingBoxBase(
new ImmutableBoundingBox(
circle.center.x - circle.radius,
circle.center.x + circle.radius,
circle.center.y - circle.radius,

View file

@ -1,7 +1,7 @@
import { vec2 } from 'gl-matrix';
import { Circle, GameObject, rotate90Deg } from 'shared';
import { CirclePhysical } from '../../objects/circle-physical';
import { reactsToCollision } from '../physicals/reacts-to-collision';
import { reactsToCollision } from './reacts-to-collision';
import { evaluateSdf } from './evaluate-sdf';
import { Physical } from '../physicals/physical';

View file

@ -0,0 +1,8 @@
import { GameObject } from 'shared';
export interface ReactsToCollision {
onCollision(other: GameObject): void;
}
export const reactsToCollision = (a: any): a is ReactsToCollision =>
a && 'onCollision' in a;