Setup formatting

This commit is contained in:
schmelczerandras 2020-10-07 16:40:21 +02:00
parent d34f25295c
commit dd850d11d1
45 changed files with 230 additions and 190 deletions

View file

@ -1,11 +1,11 @@
import { vec2 } from 'gl-matrix';
export abstract class BoundingBoxBase {
export class BoundingBoxBase {
constructor(
protected _xMin: number = 0,
protected _xMax: number = 0,
protected _yMin: number = 0,
protected _yMax: number = 0
protected _yMax: number = 0,
) {}
public get 0(): number {

View file

@ -2,7 +2,7 @@ import { Physical } from '../physical';
import { BoundingBoxBase } from '../bounding-boxes/bounding-box-base';
export class BoundingBoxList {
constructor(private objects: Array<Physical> = []) { }
constructor(private objects: Array<Physical> = []) {}
public insert(object: Physical) {
this.objects.push(object);
@ -11,7 +11,7 @@ export class BoundingBoxList {
public remove(object: Physical) {
this.objects.splice(
this.objects.findIndex((i) => i === object),
1
1,
);
}

View file

@ -22,7 +22,7 @@ export class BoundingBoxTree {
private buildRecursive(
objects: Array<StaticPhysical>,
depth: number,
parent: Node
parent: Node,
): Node {
if (objects.length === 0) {
return null;
@ -71,7 +71,7 @@ export class BoundingBoxTree {
private findMaybeIntersecting(
boundingBox: BoundingBoxBase,
node: Node,
depth: number
depth: number,
): Array<StaticPhysical> {
if (node === null) {
return [];
@ -104,7 +104,7 @@ export class BoundingBoxTree {
object: StaticPhysical,
node: Node,
depth: number,
parent: Node
parent: Node,
): [Node, number] {
if (node === null) {
return [parent, depth - 1];

View file

@ -53,7 +53,7 @@ export class PhysicalContainer {
const array = this.objectsGroupedByAbilities.get(command);
array.splice(
array.findIndex((i) => i.id == object.gameObject.id),
1
1,
);
}
}

View file

@ -6,7 +6,7 @@ import { Physical } from './physical';
export const moveCircle = (
circle: CirclePhysical,
delta: vec2,
possibleIntersectors: Array<Physical>
possibleIntersectors: Array<Physical>,
): {
realDelta: vec2;
hitSurface: boolean;
@ -16,7 +16,8 @@ export const moveCircle = (
circle.center = vec2.add(circle.center, circle.center, delta);
const intersecting = possibleIntersectors.filter(
(b) => b.gameObject !== circle.gameObject && circle.areIntersecting(b) && b.canCollide
(b) =>
b.gameObject !== circle.gameObject && circle.areIntersecting(b) && b.canCollide,
);
if (intersecting.length === 0) {
@ -43,7 +44,7 @@ export const moveCircle = (
const distancesOfIntersectingPoints = distancesOfPoints.filter(
(d) =>
(d.closest.distance > 0 && d.closest.inverted) ||
(d.closest.distance < 0 && !d.closest.inverted)
(d.closest.distance < 0 && !d.closest.inverted),
);
if (distancesOfIntersectingPoints.length === 0) {
@ -59,14 +60,14 @@ export const moveCircle = (
vec2.scale(
pointDistance.point,
pointDistance.point,
(pointDistance.closest.inverted ? 1 : -1) * pointDistance.closest.distance
(pointDistance.closest.inverted ? 1 : -1) * pointDistance.closest.distance,
);
return pointDistance.point;
});
const approxNormal = deltas.reduce(
(sum, current) => vec2.add(sum, sum, current),
vec2.create()
vec2.create(),
);
vec2.scale(approxNormal, approxNormal, 1 / deltas.length);